[[snmp]]
 

Using MIB files with SNMP

This is the easiest way to use SNMP - get the MIB file for the device in question and refer to it.

snmpget hostname public -m /usr/share/snmp/mibs/mib-device.txt STUFF-MIB::ThingIwantToRead

For example, with our UPS:

snmpget ups public -m /home/kelman/stdupsv1.mib UPS-MIB::upsSecondsOnBattery

returns: upsMIB.upsObjects.upsBattery.upsSecondsOnBattery = 0, which with | awk ‘{print $NF}’ will return the value you want, which can then be stored, graphed or checked against for alerting.

Examples

We have a Powerware ConnectUPS with a Web/SNMP card. It’s a 3 phase 50KVA device, and each phase can be monitored for it’s percentage load. By browsing through the stdupsv1.mib file that came on the CD with the UPS, we find the following entry:

upsOutputPercentLoad OBJECT-TYPE
    SYNTAX  INTEGER (0..200) -- UNITS percent  
    ACCESS  read-only
    STATUS  mandatory
    DESCRIPTION
             "The percentage of the UPS power capacity presently
               being used on this output line, i.e., the greater of
               the percent load of true power capacity and the
               percent load of VA."
    ::= { upsOutputEntry  5 }

As we have 3 output lines, we want to monitor the load on each one and graph it. A quick snmpget of each line reveals:

# /usr/bin/snmpget ups public -m /home/kelman/stdupsv1.mib UPS-MIB::upsOutputPercentLoad.1
upsMIB.upsObjects.upsOutput.upsOutputTable.upsOutputEntry.upsOutputPercentLoad.1 = 17
# /usr/bin/snmpget ups public -m /home/kelman/stdupsv1.mib UPS-MIB::upsOutputPercentLoad.2
upsMIB.upsObjects.upsOutput.upsOutputTable.upsOutputEntry.upsOutputPercentLoad.2 = 41
# /usr/bin/snmpget ups public -m /home/kelman/stdupsv1.mib UPS-MIB::upsOutputPercentLoad.3
upsMIB.upsObjects.upsOutput.upsOutputTable.upsOutputEntry.upsOutputPercentLoad.3 = 76

The values all look reasonable and, more importantly, match the values seen on the web interface. This means we are reading the right SNMP entries, so we can go on. (Double checking values with another source is always very handy so you don’t end up graphing the number of furlongs per fornight by accident). So, to graph these values, we use RRDTool. Running the SNMPGets every 10 minutes will be fine, and awk can cut out the extraneous output of SNMPGet. See my RRDTool page for more information.

We also want to check the UPS estimated run time remaining, and send out an email if it drops below 10 minutes (ie, the UPS has been running on batteries for some time). Run this every so often (every 10 minutes) from cron and it’ll keep you informed.

if [ "`/usr/bin/snmpget ups public -m /home/kelman/stdupsv1.mib UPS-MIB::upsEstimatedMinutesRemaining | awk '{print $NF}'`" -lt "10" ]; then\
echo "The UPS is running out of battery run time" | mail root  ; fi
 
snmp.txt · Last modified: 2007/05/31 14:34 by gavin
 
Recent changes RSS feed Valid XHTML 1.0 Valid CSS Driven by DokuWiki