Snmpget command
From RZWiki
snmpget is a part of the net-snmp application suite. It is used to perform SNMP GET requests, which retrieve information from a device. This article only deals with command syntax using SNMP versions 1 and 2c.
For details of useful MIBs and OIDs you might want to query a device for using this tool, see the SNMP MIB & OID Guide article.
Contents |
Usage Syntax
snmpget -v version -c community-string hostname-or-ip [mib::]oid
The listed parameters are;
- -v version - specify the SNMP version to be used; 1 or 2c
- -c community-string - specify the clear text community string used by the device to authenticate requests
- hostname-or-ip - specify the hostname or IP address of the device you wish to query
- [mib::] - optionally, specify a MIB module the following OID is specified in
- oid - specify the OID you wish to query/request
Usage Examples
All examples shown use a read-only community string of public and query host 1.2.3.4.
snmpget -v 2c -c public 1.2.3.4 mib-2.4 7.1.1.1.1.11.1
Typical Output
noinclude/noinclude
SNMPv2-SMI::mib-2.47.1.1.1.1.11.1 = STRING: "XXX099903VN"
Troubleshooting Problems
Instance Identifier Missing
Frequently, the OID you've specified doesn't include an instance identifier which is required by SNMP. Try adding an instance identifier of .0 to the OID, as demonstrated below;
Without an instance identifier:
snmpget -v 2c -c public 1.2.3.4 1.3.6.1.4.1.9.9.43.1.1.2
CISCO-CONFIG-MAN-MIB::ccmHistoryRunningLastSaved = No Such Instance currently exists at this OID
With an instance identifier:
snmpget -v 2c -c public 1.2.3.4 1.3.6.1.4.1.9.9.43.1.1.2.0
CISCO-CONFIG-MAN-MIB::ccmHistoryRunningLastSaved.0 = Timeticks: (3985895529) 461 days, 7:55:55.29
It's A Table
You'll see the No Such Instance currently exists at this OID error if you use snmpget to query a table, are you? If you're unsure if the OID is a table, simply try replacing the snmpget command with the snmptable command, keeping all other parameters the same, and see if you get the same error.
Alternatively, analyse the OID name displayed, it's normally obvious you're querying a table and you should be using the snmptable command instead, as demonstrated below;
snmpget -v 2c -c public 1.2.3.4 1.3.6.1.4.1.9.9.106.1.2.1
CISCO-HSRP-MIB::cHsrpGrpTable = No Such Object available on this agent at this OID
Usage Notes
In depth tutorials for the entire net-snmp suite can be found here: http://net-snmp.sourceforge.net/wiki/index.php/Tutorials
The snmpget tutorial can be found here: http://net-snmp.sourceforge.net/wiki/index.php/TUT:snmpget
Related Commands
Other commands in the net-snmp application suite;
Related Articles
For details of useful MIBs and OIDs you might want to query a device for using this tool, see the SNMP MIB & OID Guide article.
(replacing the # with an @) |






