Monitoring with SNMP

Configure SNMP agent on Linux

We want to allow Nagios to monitor via the snmp agent(snmpd) on the target.

Suppose we want to use the community public to access the agent. And we want to grant access to tree .iso.org.dod.internet.mgmt(OID .1.3.6.1.2), /etc/snmp/snmpd.conf must have:

# map community "public" to security name "notConfigUser":
com2sec notConfigUser  default  public

# Second, map "notConfigUser" into group "notConfigGroup":
group   notConfigGroup v1       notConfigUser
group   notConfigGroup v2c      notConfigUser

# Third, create a "systemview" to represent OID tree ".1.3.6.1.2" :
view    mgmtview    included   .1.3.6.1.2

# Finally, grant "notConfigGroup" read-only access to the "mgmtview":
#       group          context sec.model sec.level prefix read       write notif
access  notConfigGroup ""      any       noauth    exact  mgmtview   none  none

If you want to create a view effectively of all objects (everything under .iso), set it as:

view    fullview included   .1

Add custom SNMP extension

Suppose you want to check software raid status via snmp.

First, create a check script/program:

#!/bin/bash

# check it
cat /proc/mdstat | egrep -q "U_|_U"
RETVAL=$?

if [ $RETVAL -eq 0 ]; then
        echo "CRITICAL: The arrays have at least one drive failed!"
        exit 2
else
        echo "OK: The arrays are functioning normally."
        exit 0
fi

echo "UNKNOWN: Unexpected check result."
exit 3             

Then, define it in /etc/snmp/snmpd.conf:

exec softraid /bin/bash /usr/local/bin/check_raid.sh

Entries defined in UCD-SNMP-MIB will be created.

Query the entries:

$ snmpwalk -v 1 localhost -c public .1.3.6.1.4.1.2021.8
UCD-SNMP-MIB::extIndex.1 = INTEGER: 1
UCD-SNMP-MIB::extNames.1 = STRING: softraid
UCD-SNMP-MIB::extCommand.1 = STRING: /bin/bash /usr/local/bin/check_raid.sh
UCD-SNMP-MIB::extResult.1 = INTEGER: 0
UCD-SNMP-MIB::extOutput.1 = STRING: OK: The arrays are functioning normally.
UCD-SNMP-MIB::extErrFix.1 = INTEGER: 0
UCD-SNMP-MIB::extErrFixCmd.1 = STRING:

Or in GUI view:

By the above, we know the entries are added as instance 1. So, to query the status of the softraid, we check oid:
.1.3.6.1.4.1.2021.8.1.100.1

Configure SNMP agent on Windows

Setup check command for SNMP extension

nagios/monitoring_with_snmp.txt · Last modified: 2011-01-08 13:55 by admin
Back to top
GNU Free Documentation License 1.3
chimeric.de = chi`s home Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0