Nagios ZFS plugin for FreeBSD 7+/Solaris 10+

This is a small Nagios plugin written in PERL and designed to monitor the state of ZFS zpools from Nagios. As far as testing goes, I've actually only tested this plugin on FreeBSD 7-CURRENT, but it should work just as easily in Solaris. (If ZFS gets ported to other OSes, the script may need an update to reflect this)

Usage

The check_zfs plugin relies on the use of the nrpe. The Nagios server does an nrpe call to the remote server, and asks it to run the check_zfs plugin. The remote server checks the status of the zpool requested and sends this information back to the Nagios server. Nagios then displays the results to it's web page.

The plugin is designed only to monitor the status of zpools, and whether they are ONLINE (which is good) or DEGRADED (which is not good) or worse (which will result in a critical alert). The plugin can be told to only display the overall zpool health, or include the status of virtual and real devices as well.

The plugin accepts two arguments -- namely, The name of the zpool you are monitoring, and the level of verbose output you want from it.

Usage: check_zfs (zpool name) (verbosity level 1-3)

Verbose levels:-
(1) Display only zpool health and pool size statistics
(2) In addition, display problem devices when zpool health is not OK
(3) Display all zpool related device status regardless of zpool health

The plugin returns an OK result if the zpool is functioning OK. In the case of a disk failure or zpool device disappearance, as long as the zpool itself is still reliably holding data even in a DEGRADED mode, Nagios will display warnings. Critical events will typically only occur when your zpool has failed or is unavailable (or was never there to begin with!)

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_zeedata]=/usr/local/libexec/nagios/check_zfs zeedata 2
(The above example creates a command that will check the status of the zeedata zpool, with a verbosity level of 2.)

Next, install the plugin to the nagios plug in directory, and set its permissions (if necessary):-
# cp check_zfs /usr/local/libexec/nagios
# chmod 555 /usr/local/libexec/nagios/check_zfs

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_zeedata

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_zeedata

And that's it!

Hosted by www.Geocities.ws

1