check_netsnmp plugin for Nagios

(download)

Motivation. There are several common parameters we want to monitor for (almost) every computer in our network:

snmpd, provided by free net-snmp package, provides a convenient way to collect this information and export it by means of SNMP protocol. It also allows one to specify the critical values for the above parameters and automatically sets error flag to indicate the error occurred and provides error message which describes it. Using snmpd it is also possible to execute custom scripts which allows to monitor parameters which are not available in standard mibs.

check_netsnmp plugin for Nagios is written in perl, uses no external commands and requires utils module, available from Naguios-plugins distribution, and Net::SNMP module, available from CPAN.

Usage. Put check_netsnmp plugin to the directory in which you installed nagios-plugins (typically $USER1$ variable points to it).

  1. Monitoring free disk space. Used in conjunction with disk keyword in snmpd.conf. Imagine that you have two mount points on the monitored machine: / and /var and you want to be sure / has more than 20% free space and /var has more that 30% free space. Put the following lines to the snmpd.conf:
    disk / 20%
    disk /var 30%
    
    Next, define the following command in your Nagios configuration:
    define command{
            command_name    check_disk
            command_line    $USER1$/check_netsnmp -H $HOSTADDRESS$ -o disk
    }
    
    and add the relevant service:
    define service{
            use                     generic-service
            host_name               host.name.ru
            service_description     disks
            check_command           check_disk
    }
    
    The same procedure applies to checking swap, processes and load averages (use with swap, proc and load keywords in snmpd.conf).
  2. Monitoring free mbuf clusters. This is a bit harder since there are no corresponding mibs in snmpd. Here is where snmpd's exec keyword may be used. Write your own script which checks for mbuf clusters and returns 0 if there are enough of them free, and 1 if there are not. An example may be found here. Then put the folowing line in your snmpd.conf:
    exec .1.3.6.1.4.1.2021.8.3 MBufMon /usr/local/share/snmp/exec/mbufmon.sh
    
    Define the following command in your Nagios configuration:
    define command{
            command_name    check_mbufmon
            command_line    $USER1$/check_netsnmp -H $HOSTADDRESS$ -o 3
    }
    
    You may use the full OID instead of just 3 here, if you export the result of mbufmon.sh under nonstandard OID. .1.3.6.1.4.1.2021.8. is prepended to 3 in this example automatically. Finally, add the service to check for mbufs:
    define service{
            use                     generic-service
            host_name               host.name.ru
            service_description     MBufMon
            check_command           check_mbufmon
    }
    

Please send your comments and suggestions to me.