Logo
Home page Net-SNMP

Archive Search:

Require all words?

Site Search:
Google

UCD-SNMP Tutorial -- snmpget

Note: Much of this tutorial requires ucd-snmp-4.2.2 or higher!, so make sure you get it before running the commands found in this tutorial.

Note: A new tutorial for net-snmp 5.0 and above is available as well. The commands is the ucd-snmp specific tutorial will not work as expected if you are using net-snmp and not ucd-snmp.


The snmpget command can be used to retrieve data from a remote host given its host name, authentication information and an OID. As a simple example:


In the above example, test.net-snmp.org is the host name we wanted to talk to, using the SNMP community string demopublic and we requested the value of the OID system.sysUpTime.0.

All of the ucd-snmp utilities use SNMPv1 by default and expects the community name to follow the host name. SNMPv2c, which is similar in nature to SNMPv1 with small modifications, still used clear-text community names as "passwords" to authenticate the issuer of the command. The result from a command using the SNMPv2c version would have been the same:


All of the utilities allow abbreviation of the OIDs and do random searches by default, and hence you can only specify a small portion of the oid if you would prefer:


A common mistake when using the snmpget command is to leave off the index into the data you're looking for. In the above commands, the variable requested by the OID is a scalar and the index to scalars is always a simple '0' (zero), hence the trailing '.0' in all the oids above. If you had left it off, you would have gotten an error. Note that the errrors differ slightly between SNMPv1 and SNMPv2c:


Multiple variables can be retrieved in one transaction as well:



Valid CSS!


Last modified: Wednesday, 01-Aug-2018 04:41:28 UTC
For questions regarding web content and site functionality, please write to the net-snmp-users mail list.