TUT:snmpwalk
The snmpwalk command is designed to perform a sequence of chained GETNEXT requests automatically, rather than having to issue the necessary snmpgetnext requests by hand.
Contents
Basic Usage
The command takes a single OID, and will display a list of all the results which lie within the subtree rooted on this OID:
% snmpwalk -v 2c -c demopublic test.net-snmp.org system SNMPv2-MIB::sysDescr.0 = HP-UX net-snmp B.10.20 A 9000/715 SNMPv2-MIB::sysObjectID.0 = OID: enterprises.ucdavis.ucdSnmpAgent.hpux10 SNMPv2-MIB::sysUpTime.0 = Timeticks: (586998396) 67 days, 22:33:03.96 SNMPv2-MIB::sysContact.0 = Wes Hardaker wjhardaker@ucdavis.edu SNMPv2-MIB::sysName.0 = net-snmp SNMPv2-MIB::sysLocation.0 = UCDavis SNMPv2-MIB::sysORLastChange.0 = Timeticks: (0) 0:00:00.00 SNMPv2-MIB::sysORIndex.1 = 1 SNMPv2-MIB::sysORIndex.2 = 2 SNMPv2-MIB::sysORIndex.3 = 3 SNMPv2-MIB::sysORIndex.4 = 4 SNMPv2-MIB::sysORIndex.5 = 5 SNMPv2-MIB::sysORID.1 = OID: SNMPv2-MIB::snmpMIB SNMPv2-MIB::sysORID.2 = OID: SNMP-VIEW-BASED-ACM-MIB::vacmBasicGroup SNMPv2-MIB::sysORID.3 = OID: SNMP-FRAMEWORK-MIB::snmpFrameworkMIBCompliance SNMPv2-MIB::sysORID.4 = OID: SNMP-MPD-MIB::snmpMPDCompliance SNMPv2-MIB::sysORID.5 = OID: SNMP-USER-BASED-SM-MIB::usmMIBCompliance SNMPv2-MIB::sysORDescr.1 = The Mib module for SNMPv2 entities. SNMPv2-MIB::sysORDescr.2 = View-based Access Control Model for SNMP. SNMPv2-MIB::sysORDescr.3 = The SNMP Management Architecture MIB. SNMPv2-MIB::sysORDescr.4 = The MIB for Message Processing and Dispatching. SNMPv2-MIB::sysORDescr.5 = The MIB for the SNMP User-based Security Model. SNMPv2-MIB::sysORUpTime.1 = Timeticks: (0) 0:00:00.00 SNMPv2-MIB::sysORUpTime.2 = Timeticks: (0) 0:00:00.00 SNMPv2-MIB::sysORUpTime.3 = Timeticks: (0) 0:00:00.00 SNMPv2-MIB::sysORUpTime.4 = Timeticks: (0) 0:00:00.00 SNMPv2-MIB::sysORUpTime.5 = Timeticks: (0) 0:00:00.00
This command can also be used with a single MIB object, or even an exact instance OID - returning the obvious value:
% snmpwalk -v 2c -c demopublic test.net-snmp.org sysDescr SNMPv2-MIB::sysDescr.0 = HP-UX net-snmp B.10.20 A 9000/715 % snmpwalk -v 2c -c demopublic test.net-snmp.org sysDescr.0 SNMPv2-MIB::sysDescr.0 = HP-UX net-snmp B.10.20 A 9000/715
Conversely, it's also possible to start the walk at a higher level, retrieving more than one group of information.
% snmpwalk -v 2c -c demopublic test.net-snmp.org .iso
would typically retrieve all the information known to an agent. (Omitted here, for obvious reasons!)
Walking tables
Note that the first example above contains both scalar and table instances. >Snmpwalk can also be used for retrieving a single column of a table, by specifying the column object as the starting point.
% snmpwalk -v 2c -c demopublic test.net-snmp.org sysORID SNMPv2-MIB::sysORID.1 = OID: SNMPv2-MIB::snmpMIB SNMPv2-MIB::sysORID.2 = OID: SNMP-VIEW-BASED-ACM-MIB::vacmBasicGroup SNMPv2-MIB::sysORID.3 = OID: SNMP-FRAMEWORK-MIB::snmpFrameworkMIBCompliance SNMPv2-MIB::sysORID.4 = OID: SNMP-MPD-MIB::snmpMPDCompliance SNMPv2-MIB::sysORID.5 = OID: SNMP-USER-BASED-SM-MIB::usmMIBCompliance
Note that all the values for one column are retrieved before moving on to the next (as seen earlier). This is precisely the behaviour described in the snmpgetnext tutorial, but sometimes comes as a surprise to those new to SNMP.
The same approach can be used for retrieving the full contents of a table. (Although snmptable might be more useful in this case).
Problems
If the agent does not implement anything within the specified OID, then the snmpwalk command may return without displaying anything at all, or it may display a vaguely informative message, depending on the SNMP version being used:
% snmpwalk -v 1 -c demopublic test.net-snmp.org ifXTable (nothing displayed) % snmpwalk -v 2c -c demopublic test.net-snmp.org ifXTable IF-MIB::ifXTable = No Such Object available on this agent at this OID
Alternatively, if the OID specified is later than the last MIB instance that the agent implements, a slightly different message may be displayed:
% snmpwalk -v 1 -c demopublic test.net-snmp.org .2.0 End of MIB % snmpwalk -v 2c -c demopublic test.net-snmp.org ifXTable joint-iso-ccitt.0 = No more variables left in this MIB View (It is past the end of the MIB tree)
But in each case, the meaning is the same - the agent had nothing relevant to display.
Tutorial Sections
About the SNMP Protocol
These tutorial links talk about SNMP generically and how the protocol itself works. They are good introductory reading material and the concepts are important to understand before diving into the later tutorials about Net-SNMP itself.
- How SNMP Works: About the protocol itself (GETs, GETNEXTs, etc)
- What data is in SNMP: All about SNMP Management Information Bases (MIBs)
- Securing SNMP: How to use the SNMP protocol securely
Net-SNMP Command Line Applications
These tutorial pages discuss the command line tools provided in the Net-SNMP suite of tools. Nearly all the example commands in these tutorials works if you try it yourself, as they're all examples that talk to our online Net-SNMP test agent. Given them a shot!
- snmptranslate: learning about the MIB tree.
- snmpget: retrieving data from a host.
- snmpgetnext: retrieving unknown indexed data.
- snmpwalk: retrieving lots of data at once!
- snmptable: displaying a table.
- snmpset: peforming write operations.
- snmpbulkget: communicates with a network entity using SNMP GETBULK request
- snmpbulkwalk: retrieve a sub-tree of management values using SNMP GETBULK requests.
- snmptrap: Sending and receiving traps, and acting upon them.
- Traps/informs with SNMPv3/USM: Sending and receiving SNMPv3/USM TRAPs and INFORMs
- Sending Traps/Informs via AgentX: Sending notifications from the command line through snmpd
- Common command line options:
- Writing mib2c config files
Application Configuration
All of our applications support configuration to allow you to customize how they behave.
Net-SNMP Daemons
Net-SNMP comes with two long-running daemons: a SNMP agent (snmpd) for responding to management requests and a notification receiver (snmptrapd) for receiving SNMP notifications.
- SNMP Agent (snmpd) Configuration
- SNMP Notification Receiver (snmptrapd)
- Agent Monitoring
Coding Tutorials
Net-SNMP comes with a highly flexible and extensible API. The API allows you to create your own commands, add extensions to the agent to support your own MIBs and perform specialized processing of notifications.
- Client / Manager Coding Tutorials
- Agent Coding Tutorials
- The Agent Architecture page might be worth reading before or after the agent coding tutorials, and describes how the Agent Helpers work under the hood.
- Writing a mib module to serve information described by an SNMP MIB, and how to compile it into the net-snmp snmpd agent.
- Writing a Dynamically Loadable Object that can be loaded into the SNMP agent.
- Writing a Subagent that can be run to attach to the snmpd master agent.
- Writing a perl plugin to extend the agent using the NetSNMP::agent module.
- Writing shell scripts to extend the agent
- Using mib2c to help write an agent code template for you
- Header files and autoconf
Debugging SNMP Applications and Agents
All our tools and applications have extensive debugging output. These tutorials talk about how the debugging system works and how you can add your own debugging statements to you code:
- Debugging output printed using the -D command line option
- Using -Ddump to display packet breakdowns
- Debugging using GDB
Operating System Specific Tutorials
- Building With Visual Studio 2005 Express
- Building Net-SNMP 64-bit with Visual C++ 2010 Express
- Net-Snmp on Ubuntu
- Net-SNMP and lm-sensors on Ubuntu 10.04
- Net-SNMP for windows: