Net-SNMP Tutorial -- snmpget
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.
Earlier versions of the ucd-snmp utilities used SNMPv1 by default and expected the community name to follow the host name. The net-snmp versions of these tools now typically use SNMPv3 by default, and require both the version and the community string to be given as command line options (as illustrated in these examples). 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:
Last modified: Thursday, 26-May-2011 23:21:32 UTC
For questions regarding web content and site functionality, please write to the net-snmp-users mail list.