Nagios GEOM plugin for FreeBSD
This is a small Nagios plugin written in PERL and designed to monitor the state of FreeBSD GEOM devices (specifically mirrors and striped volumes) from Nagios.
Usage
The check_geom plugin relies on the use of the nrpe. The Nagios server does an nrpe call to the remote FreeBSD server, and asks it to run the check_geom plugin. The remote FreeBSD server checks the status of the volume requested and sends this information back to the Nagios server. Nagios then displays the results to it's web page.
The plugin is designed to accept checks to any GEOM class, however, to all intents and purposes, it has only been tested with the "mirror" and "stripe" classes. Support will need to be added for the RAID3 and other GEOM classes in future. (Obviously enough you can't really call the "label" class and get a meaningful result!)
The plug in accepts two arguments. The GEOM class you are monitoring, and the name of the volume.
Usage: check_geom (geom class) (volume)
The plugin returns an OK result if the volume is functioning OK. In the case of a hard disk failure or volume dissapearance/non-existance, the plug in will almost always result in a CRITICAL event. In this version, WARNING events are only ever issued if you still have at least two components still functioning in a mirrored volume. This situation may arise if you are rebuilding your mirror (you will also see the "percent complete" rebuild details in Nagios), or if your three-or-more component volume has suffered a disk failure in one of its components, still leaving at least two or more components available for redundancy.
Install the nrpe plug in on your operating system (For FreeBSD, use the port at /usr/ports/net-mgmt/nrpe2), copy the file at /usr/local/etc/nrpe.cfg_sample to /usr/local/etc/nrpe.cfg, and add something like this command definition at the bottom of the file:
command[check_gm0]=/usr/local/libexec/nagios/check_geom mirror gm0
(The above example creates a command that will check the status of the gm0 mirror.)
Next, install the plugin to the nagios plug in directory, and set its permissions (if necessary):-
# cp check_geom /usr/local/libexec/nagios
# chmod 555 /usr/local/libexec/nagios/check_geom
Edit /etc/rc.conf and add the following line to enable nrpe2.
nrpe2_enable="YES"
Now the daemon can be started at boot time, or manually from /usr/local/etc/rc.d/nrpe2.sh
# /usr/local/etc/rc.d/nrpe2.sh start
On the Nagios side, you can detect that the plugin is working by issuing the follwing command and checking it's output:-
# check_nrpe -H $HOSTADDRESS -c check_gm0
Once that is functioning, it is simply a matter of creating a service.cfg entry on your nagios server and calling the plugin thusly:-
check_command check_nrpe!check_gm0
And that's it!