next up previous contents
Next: Net-SNMP CLI Tool Options Up: The Net-SNMP CLI Previous: Probing a device: SNMP   Contents

Polling Individual OIDs: SNMP GETs

The Net-SNMP tool snmpget can retrieve the value of an OID and return it STDOUT in any form that you wish. It can be used for debugging applications or called directly from a scripting language to create "quick and dirty" SNMP monitoring applications.

Lets use the snmpget tool by passing an OID to it:

$ snmpget -v1 -c public -m "./APC-POWERNET.txt" 10.10.1.224 \
> PowerNet-MIB::upsAdvInputLineVoltage.0
PowerNet-MIB::upsAdvInputLineVoltage.0 = Gauge32: 118
$

In this example I used the APC MIB (APC-POWERNET.txt) for the UPS Input Line Voltage of my APC with the IP address of 10.10.1.224. I can see from the output that the current voltage is 118VAC.

I could have just as easily called for this OID directly using it's numeric OID and thus not needed the MIB. This is a useful way of writing SNMP applications that don't need the MIB. We can pass snmpget an output option that would display the fully qualified numeric OID which we could then use in our script, so that if we moved that script to another system we wouldn't have to worry about the MIB. Obviously, the only problem with doing this is that if the SNMP agent on the target device is ever updated and we're not using the MIB to retrieve values we might start probing the wrong OID and getting bad data. For this reason you should generally use the MIB if possible.


next up previous contents
Next: Net-SNMP CLI Tool Options Up: The Net-SNMP CLI Previous: Probing a device: SNMP   Contents
2004-11-23