TUT:snmpgetnext

From Net-SNMP Wiki
Revision as of 19:33, 23 January 2007 by Wes (Talk | contribs)

Jump to: navigation, search

snmpgetnext

The snmpgetnext command, which is similar in usage to the snmpget command, is used to retrieve the next oid in the mib tree of data. Instead of returing the data you requested, it returns the next OID in the tree and its value:

 % snmpgetnext -v 2c -c demopublic test.net-snmp.org system.sysUpTime.0
 system.sysContact.0 = Wes Hardaker wjhardaker@ucdavis.edu


You could use the snmpgetnext command to manually walk down the mib tree in the remote host, by always specifying the last OID that you saw on the command line for the next command:

 % snmpgetnext -v 2c -c demopublic test.net-snmp.org system.sysUpTime.0
 system.sysContact.0 = Wes Hardaker wjhardaker@ucdavis.edu
 % snmpgetnext -v 2c -c demopublic test.net-snmp.org system.sysContact.0
 system.sysName.0 = net-snmp
 % snmpgetnext -v 2c -c demopublic test.net-snmp.org system.sysName.0
 system.sysLocation.0 = UCDavis


In fact, the snmpwalk command described in the next section, implements exactly this but in one command! Unlike the snmpget command, the snmpgetnext command does return data for a OID which is too short or is missing the index part of the OID. For instance, if you remember from the last snmpget discussion, if you left off the .0 on the end of the OID you were requesting on a snmpget command, you were issued an error. With snmpgetnext, you're still issued an answer, because you will always get the next value in the tree, regardless of weather or not you specified a valid OID for a variable or not:

 % snmpgetnext -v 2c -c demopublic test.net-snmp.org system.sysUpTime
 system.sysUpTime.0 = Timeticks: (586978184) 67 days, 22:29:41.84
 % snmpgetnext -v 2c -c demopublic test.net-snmp.org system
 system.sysDescr.0 = HP-UX net-snmp B.10.20 A 9000/715
 % snmpgetnext -v 2c -c demopublic test.net-snmp.org .1.3.6
 system.sysDescr.0 = HP-UX net-snmp B.10.20 A 9000/715

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.

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!

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.

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.

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:

Operating System Specific Tutorials