Log in Go to the main page Page Discussion History Go to the file list Go to the site toolbox

Snmpget command

From NetworkCommands



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

Image:Vm-power-on-medium.png 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

Image:Vm-power-on-medium.png 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

Image:utilities-terminal-medium.png Typical Output

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

Image:accessories-text-editor-v2-medium.png 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

Image:icemon-medium.png Related Commands

Other commands in the net-snmp application suite;

Image:icemon-medium.png 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.


Image:internet-group-chat-small.png We really do appreciate all feedback so please do send your comments, suggestions or corrections to steve#networkstuff.eu (replacing the # with an @)



Site Toolbox:

Personal tools
This page was last modified on 5 September 2008, at 13:28. - This page has been accessed 58 times. - Disclaimers - About NetworkCommands
Powered by MediaWiki