Nagios Remote Monitoring

Nagios is awesome. I recently configured a VPS to monitor all the servers in a hosting facility. Although I've been using Nagios for several years, I hadn't used the NRPE plugin until now. It's quite easy to add support on the Nagios server and the monitored host (both CentOS 5) using packages from the RPMforge repository, which includes all of Dag Wieers' builds. I'll document the process here.

Although not required, CentOS recommendeds using the Priorities Yum plugin to prevent conflicts when using third-party repositories. I haven't experienced conflicts requiring repository prioritization, however it does seem like a good facility.

Install the RPMforge repository package. Download the appropriate version for the system architecture (i386 or x86_64) directly, or browse all releases (DAG RPMs). With the RPMforge repository available, install the Nagios NRPE plugin on the monitoring server:

yum install nagios-plugins-nrpe

On the host to be monitored, install the NRPE daemon and plugins:

yum install nagios-plugins nagios-nrpe

The package includes configuration file (/etc/nagios/nrpe.cfg) with verbose comments to explain its settings. The following is a simple file to get started measuring some basic system health metrics.

# $Id$ pid_file=/var/run/nrpe.pid server_port=5666 nrpe_user=nagios nrpe_group=nagios command_timeout=60 command[check_load]=/usr/lib/nagios/plugins/check_load -w 15,10,5 -c 30,25,20 command[check_disk_root]=/usr/lib/nagios/plugins/check_disk -w 20 -c 10 -p /dev/mapper/vg.01-root command[check_disk_var]=/usr/lib/nagios/plugins/check_disk -w 20 -c 10 -p /dev/mapper/vg.01-var command[check_total_procs]=/usr/lib/nagios/plugins/check_procs -w 150 -c 200

Enable and start the NRPE daemon on the host to be monitored:

chkconfig nrpe on service nrpe start

Finally, modify the firewall to allow the Nagios server to request data from its IP of, say, 10.1.1.120:

-A INPUT -m state --state NEW -m tcp -p tcp -s 10.1.1.120 --dport 5666 -j ACCEPT

On the Nagios server, create a configuration to monitor the remote host. Here's an example snippet:

# $Id$ # vim: ts=4 define host{ use remote-host host_name server address 10.1.1.60 } define service{ use nrpe-service host_name server service_description Current Load check_command check_nrpe!check_load } ...

That's about all it takes to start processing remote Nagios plugins through the NPRE. Enjoy.

Update: The contrib/check_mem.pl plugin didn't work correctly. I suspect the format of the data returned by vmstat has changed since it was written in 2002. Not surprising. I could have hacked on it myself, but I found a replacement Perl script at Unixdaemon that does the job. It pulls data from free (from the sameprocps package).