SkillPilotAI

SNMP tools: snmpwalk, snmpget, snmpset, snmpbulkwalk, snmptable, snmptranslate, snmptrap (2/2)

Part 2 of the Net-SNMP tools: snmpgetnext, snmpbulkget and snmpbulkwalk for fetching many values, snmptable and snmptranslate for reading tables and OIDs, snmptrap and snmpinform for notifications, and the helper tools snmpstatus, snmpdf, snmpnetstat, snmpdelta and snmptest.

270.1 Why is it used?

  • GETBULK fetches a whole table in a few round trips instead of one request per value.
  • snmptable and snmptranslate turn raw OIDs into readable tables and names.
  • Traps/informs let a device report events; helper tools give quick health, sockets, disks and counter rates.
  • All come from Net-SNMP (Linux, macOS); not built into Windows.

270.2 How it works: GETNEXT vs GETBULK

Walking ifTable of router1
  1. 1.snmpwalk: NMS sends GETNEXT, router1 returns ONE next value

  2. 2.Repeat per value: 45 requests for 44 variables

  3. 3.snmpbulkwalk: one GETBULK, many values packed in one reply

  4. 4.Default -Cr10: 5 requests

  5. 5.-Cr50: the whole table in 1 request

Counted with the agent's snmpInPkts counter

  • Lab: router1 192.168.70.10 (snmpd), nms 192.168.70.20 (snmptrapd on UDP 162).
  • labview read-only for the lab subnet; labwrite only from the NMS with view systemonly (system group); v3 user asha SHA + AES; snmptrapd logs only traps with community labview.
Terminal
# router1: /etc/snmp/snmpd.confagentAddress udp:192.168.70.10:161view systemonly included .1.3.6.1.2.1.1rocommunity labview 192.168.70.0/24rwcommunity labwrite 192.168.70.20 -V systemonlycreateUser asha SHA "*****" AES "*****"rouser asha priv# nms: /etc/snmp/snmptrapd.confauthCommunity log labview

270.3 snmpgetnext, snmpbulkget, snmpbulkwalk

  • snmpgetnext returns the object AFTER the given OID: sysName.0 -> sysLocation; ifDescr.1 -> ifDescr.3 (index 2 does not exist).
  • Giving sysDescr and sysName without .0 returns both values in one request.
  • snmpbulkget: -Cn N non-repeaters (default 0), -Cr N max-repetitions (default 10).
  • snmpbulkwalk: -Cp count, -Ci include the given OID, -Cc no increasing-OID check; no OID = whole MIB-2.
Terminal
snmpgetnext -v2c -c labview 192.168.70.10 IF-MIB::ifDescr.1snmpgetnext -v2c -c labview 192.168.70.10 sysDescr sysNamesnmpbulkget -v2c -c labview -Cn1 -Cr3 -Os 192.168.70.10 sysUpTime IF-MIB::ifDescrsnmpbulkget -v1 -c labview 192.168.70.10 system
Output
IF-MIB::ifDescr.3 = STRING: eth0SNMPv2-MIB::sysDescr.0 = STRING: Lab router1 (net-snmp agent)SNMPv2-MIB::sysName.0 = STRING: router1sysUpTimeInstance = Timeticks: (2750) 0:00:27.50ifDescr.1 = STRING: loifDescr.3 = STRING: eth0ifType.1 = INTEGER: softwareLoopback(24)snmpbulkget: Cannot send V2 PDU on V1 session (Sub-id not found: (top) -> system)
Terminal
snmpwalk -v2c -c labview 192.168.70.10 IF-MIB::ifTablesnmpbulkwalk -v2c -c labview 192.168.70.10 IF-MIB::ifTablesnmpbulkwalk -v2c -c labview -Cr50 192.168.70.10 IF-MIB::ifTable
Output
snmpwalk IF-MIB::ifTable: agent snmpInPkts 21 -> 67 = 45 requestssnmpbulkwalk IF-MIB::ifTable (default -Cr10): agent snmpInPkts 68 -> 74 = 5 requestssnmpbulkwalk -Cr50 IF-MIB::ifTable: agent snmpInPkts 75 -> 77 = 1 requests
ToolPDUVersionsUse
snmpgetnextGETNEXTv1, v2c, v3The next object
snmpwalkGETNEXT (loop)v1, v2c, v3Subtree, one value per request
snmpbulkgetGETBULKv2c, v3Many values in one request
snmpbulkwalkGETBULK (loop)v2c, v3Fast subtree walk

270.4 snmptable and snmptranslate

  • snmptable prints a MIB table in columns: -Cb brief headings, -Ci index per line, -Cw N max width (splits into parts), -Cf , + -CH = CSV.
  • snmptranslate never talks to an agent; it only reads local MIB files.
  • -On name -> number, number -> name; -IR label without module; -Onf full path; -Tp tree; -Td description; -TB regex search; - reads OIDs from stdin.
Terminal
snmptable -v2c -c labview -Cb -Ci -Cw 80 192.168.70.10 IF-MIB::ifTablesnmptable -v2c -c labview -Cf , -CH 192.168.70.10 IF-MIB::ifTable
Output
SNMP table: IF-MIB::ifTable index Index Descr             Type   Mtu      Speed      PhysAddress     1     1    lo softwareLoopback 65536   10000000                      3     3  eth0   ethernetCsmacd  1500 4294967295 12:f9:4d:ef:f:f5 1,lo,softwareLoopback,65536,10000000,,up,up,0:0:00:00.00,0,0,0,0,0,0,0,0,0,0,0,0,SNMPv2-SMI::zeroDotZero3,eth0,ethernetCsmacd,1500,4294967295,12:f9:4d:ef:f:f5,up,up,0:0:00:00.00,10038,111,0,0,0,0,14747,94,0,0,0,0,SNMPv2-SMI::zeroDotZero
Terminal
snmptranslate -On SNMPv2-MIB::sysLocation.0snmptranslate -Onf -IR ifOperStatussnmptranslate -Td IF-MIB::ifOperStatussnmptranslate -TB 'if.*Octets'snmpwalk -v2c -c labview -On 192.168.70.10 sysName | snmptranslate -
Output
IF-MIB::ifOperStatusifOperStatus OBJECT-TYPE  -- FROM	IF-MIB  SYNTAX	INTEGER {up(1), down(2), testing(3), unknown(4), dormant(5), notPresent(6), lowerLayerDown(7)}   MAX-ACCESS	read-only  STATUS	current IF-MIB::ifOutOctetsIF-MIB::ifInOctetsIF-MIB::ifHCOutOctetsIF-MIB::ifHCInOctetsIP-MIB::ipIfStatsHCOutMcastOctets
  • snmpset recap: labwrite changed sysLocation to 'SiteA rack 4'; labview got noAccess; labwrite got noAccess on ifAdminStatus because its view allows only the system group.

270.5 snmptrap and snmpinform

Trap vs inform
  1. 1.Link goes down on router1

  2. 2.Trap: router1 sends to NMS UDP 162, no reply (fire and forget)

  3. 3.If the trap is dropped, router1 never knows

  4. 4.Inform: NMS sends an acknowledgement back

  5. 5.No ack (e.g. wrong community) -> retry, then Timeout

  • v2c format: AGENT UPTIME TRAP-OID [OID TYPE VALUE]...; '' means the host's own uptime.
  • v1 format: ENTERPRISE-OID AGENT-ADDR GENERIC SPECIFIC UPTIME; generic 3 = linkUp.
  • v3 trap: -u user -l authPriv -a SHA -x AES; snmpinform = snmptrap -Ci.
  • Varbind types: i, u, c (Counter32), s, x, d, n, o, t, a, b.
Terminal
# on router1, to nms UDP 162snmptrap -v 2c -c labview 192.168.70.20:162 '' IF-MIB::linkDown IF-MIB::ifIndex.2 i 2 IF-MIB::ifAdminStatus.2 i 1 IF-MIB::ifOperStatus.2 i 2snmpinform -v 2c -c labview 192.168.70.20:162 '' SNMPv2-MIB::warmStart SNMPv2-MIB::sysLocation.0 s 'SiteA rack 4'snmpinform -v 2c -c wrongcomm -t 1 -r 1 192.168.70.20:162 '' SNMPv2-MIB::coldStart
Output
2026-11-10 21:50:50 UDP: [192.168.70.10]:41579->[192.168.70.20]:162 [UDP: [192.168.70.10]:41579->[192.168.70.20]:162]:DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (167587) 0:27:55.87SNMPv2-MIB::snmpTrapOID.0 = OID: SNMPv2-MIB::warmStartSNMPv2-MIB::sysLocation.0 = STRING: SiteA rack 4# on router1$ snmpinform -v 2c -c wrongcomm -t 1 -r 1 192.168.70.20:162 '' SNMPv2-MIB::coldStartsnmpinform: Timeout

270.6 Helper tools: snmpstatus, snmpdf, snmpnetstat, snmpdelta, snmptest

ToolWhat it showsKey options
snmpstatussysDescr, uptime, interface count, packets-Cf
snmpdfMemory/disk usage like df (HOST-RESOURCES-MIB)-Ch (MiB/GiB), -CH (MB/GB), -Cu (UCD dskTable)
snmpnetstatRemote netstat: sockets, routes, interfaces-Ca, -Cn, -Cr, -Ci, -Cs, -Cw 5
snmpdeltaChange of a counter per period (rate)-Cp SECS, -Cs, -CT, -CS, -Cm, -CP N
snmptestInteractive GET/GETNEXT/SET prompt$G $N $S $B $I $T $D $Q
Terminal
snmpstatus -v2c -c labview 192.168.70.10snmpdf -v2c -c labview -Ch 192.168.70.10 | head -6snmpdf -v2c -c labview -Cu 192.168.70.10snmpnetstat -v2c -c labview -Cn -Ca 192.168.70.10
Output
[UDP: [192.168.70.10]:161->[0.0.0.0]:60824]=>[Lab router1 (net-snmp agent)] Up: 0:01:56.27Interfaces: 2, Recv/Trans packets: 126/113 | IP: 2989/1552Description              Size       Used  Available Used%Physical memory       7.67GiB    2.40GiB    5.27GiB   31%Virtual memory        9.67GiB    2.40GiB    7.27GiB   24%Description              Size (kB)            Used       Available Used%Failed to locate any partitions.Proto Local Address               Remote Address                PIDudp4  127.0.0.11.48801            *.*                             0udp4  192.168.70.10.161           *.*                            57
  • -Cu failed because router1 has no UCD disk monitoring configured.
  • Counters like ifInUcastPkts only grow, so the raw value says nothing about rate; snmpdelta prints only the change.
Terminal
timeout 4 snmpdelta -v2c -c labview -Cs -CT -Cp 1 192.168.70.10 IF-MIB::ifInUcastPkts.3 IF-MIB::ifOutUcastPkts.3printf '$S\nsysLocation.0\ns\nSiteA\n\n$Q\n' | snmptest -v2c -c labwrite 192.168.70.10
Output
192.168.70.10	IF-MIB::ifInUcastPkts.3	IF-MIB::ifOutUcastPkts.3[21:51:32 11/10]	12.00	12.00[21:51:33 11/10]	0.00	0.00[21:51:34 11/10]	0.00	0.00 Variable: Request type is Set RequestVariable: Type [i|u|s|x|d|n|o|t|a]: Value: Variable: Received Get Response from UDP: [192.168.70.10]:161->[0.0.0.0]:35152SNMPv2-MIB::sysLocation.0 = STRING: SiteAVariable: Quitting,  Goodbye

270.7 Common mistakes

  • Thinking snmpbulkwalk works everywhere: GETBULK exists only in v2c/v3; with -v1 you get 'Cannot send V2 PDU on V1 session'.
  • Taking snmptrap exit code 0 as proof of delivery: it only means the packet was sent.
  • Reading raw counters instead of deltas when you want a rate.
  • Expecting snmptranslate to query a device: it only reads local MIBs, so vendor MIBs must be loaded (-m, -M).

270.8 Interview tips

  • Trap vs inform: both go agent -> manager on UDP 162; trap = fire and forget, inform = ack + retry (reliable, a bit more cost).
  • GETBULK cuts round trips: ifTable took 45 requests with walk, 5 with bulkwalk, 1 with -Cr50.
  • On v1-only devices use snmpwalk (GETNEXT).
  • snmptable -Cf , -CH exports a table as CSV; snmpdelta gives per-second rates.