Nagios sysctl plugin for FreeBSD
This is a small Nagios plugin written in PERL and designed to monitor the state of FreeBSD sysctl oid values.
Usage
This plugin monitors the value of a particular FreeBSD kernel sysctl oid you specify.
Select a specific sysctl to monitor. The oid and it's value will be shown in Nagios' report window.
Optionally, specify a value modifier for a value comparison against the oid's current value. These modifiers can be one of the following:-
lt - less than, gt - greater than, eq - equal to, ne - not equal to
and follow this with a value/string to compare against.
When an oid's value does not match the specified range given, a CRITICAL error will be produced.
Usage: check_sysctl[lt/gt/eq/ne value/string]
Example: check_sysctl kern.maxnvodes
OK kern.maxvnodes: 69131
Example: check_sysctl kern.maxnvodes gt 70000
CRITICAL kern.maxvnodes: 69131 (less than 70000)
To monitor a system remotely with this plugin, 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_sysctl]=/usr/local/libexec/nagios/check_sysctl kern.maxvnodes
(The above example creates a command that will check the status of kern.maxvnodes in the kernel.)
Next, install the plugin to the nagios plug in directory, and set its permissions (if necessary):-
# cp check_sysctl /usr/local/libexec/nagios
# chmod 555 /usr/local/libexec/nagios/check_sysctl
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_sysctl
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_sysctl
And that's it!