What sucks, who sucks and you suck

Nagios SNMP Plugins

2004-05-17

Nagios is a great network monitoring frontend. NET-SNMP is a good SNMP implementation for the backend. Somehow, nobody appears to have yet connected the two in any useful, simple way. If you feel that you ought to be able to use SNMP to perform remote host monitoring checks in Nagios, here are two such plugins that monitor load and disk space.

Nagios has some useful plugins for monitoring host state, but most of them only operate on a local system. To run them against remote systems, you need to use either the NRPE plugin (extra setup) or the check_by_ssh plugin (setup, shell access, protocol overhead) to execute the same plugins remotely. SNMP is supposed to be tailormade for remote monitoring and it should be more lightweight than the existing solutions, so why not leverage that instead? Furthermore, NET-SNMP is a portable, open implementation that gives easy access to host operating data.

Prerequisites

Working installation of Nagios on your monitoring server.

Working installation of NET-SNMP on all your hosts, running the snmpd daemon with the UCD-SNMP MIB enabled. The configuration should at least allow your monitoring server to read values. (You will need the snmpget and snmpdf utilities on the Nagios server.)

Warning: some assembly required. Check the downloaded files over and edit any required settings first (e.g. command paths).

check_snmp_load: This Perl script is a modified version of one of the standard Nagios plugins. It uses the NET-SNMP snmpget command to read the 1, 5 & 15 minute load averages of a remote system via the laLoad entries in the UCD-SNMP MIB.

check_snmpdf: This is a rewritten version of the existing check_disk plugin (which only checks space on the local system). The link is to the C source file. To compile it, drop it into the plugins/ subdirectory in your nagios-plugins build tree. Then either copy, paste and edit appropriate rules in the Makefile in that directory and type “make check_snmpdf”, or enter the compiler commands directly:
$ gcc -DHAVE_CONFIG_H -I. -I.. -I../lib -O -c check_snmpdf.c
$ gcc -O -L. -o check_snmpdf check_snmpdf.o utils.o
../lib/libnagiosplug.a popen.o -lsnprintf -lsnprintf
(Assuming you’ve previously built the rest of the plugins.)

Both commands give usage help with the -h switch. Install the new commands with the other Nagios plugins and add new entries to the Nagios checkcommands.cfg file. E.g.:
define command{
command_name check_snmp_load
command_line $USER1$/check_snmp_load -H $HOSTADDRESS$ -C public -S 2 c -w $ARG1$ -c $ARG2$
}
define command{
command_name check_snmp_disk
command_line $USER1$/check_snmpdf -H $HOSTADDRESS$ -C public -S 2c -w $ARG1$ -c $ARG2$
}
(These examples assume that your SNMP v2 read community name is the default, public; you should use something else in your own site and define the name as a macro in resources.cfg.) Add new service checks that use the new commands as normal.

Caveats

No warranties; free to use or modify; if it breaks, you get to keep the pieces; etc.

I don’t plan to offer ongoing support for these, although if anyone wishes to send me bug fixes or simple enhancements then I’ll try to integrate them.

Both these commands spawn extra processes to read the actual SNMP values; on a large Nagios setup, this will add considerable overhead. One fix would be to use the appropriate native API libraries for NET-SNMP.

The load check uses the same figures that uptime outputs, which is claimed not to be the most accurate representation of “system load”.

2007-11-05: Haven’t tested these yet, but these Nagios snmp plugins appear to be the same thing done right and with more monitoring options.

Nagios SNMP plugins to check disks and processes using the host monitoring in the SNMP daemon itself. Written in C using the NET-SNMP library. Requires GNU autoconf/automake to build (err…that’s not how it’s supposed to work), or hack a config.h together from another already-configured autoconf package.