NRPE Install and Configuration
This assumes nagios has been installed and configured already. I needed to add nagios monitoring for some remote linux servers. I had only dabbled with nagios before and had setup PING only for testing if a server was up or down. But we now required service testing and HD monitoring.
REMOTE CLIENT INSTALL
Installed on Ubuntu 10.04.3 LTS
Update the system
apt-get update
apt-get upgrade
Install the NRPE server
apt-get install nagios-nrpe-server
This will ask if you want to install a bunch of extra packages – hit Y
Verify the service has started
ps aux | grep nrpe
You should see a command running from /usr/sbin/nrpe
Test a command you want to run. In my case, I wanted to check the /dev/mapper/pve-data drive
/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /dev/mapper/pve-data
DISK OK
Edit the NRPE configuration file
nano /etc/nagios/nrpe.cfg
Look for allowed_hosts=127.0.0.1
Change to allowed_hosts=127.0.0.1,IPADDRESSOFNAGIOSSERVER
I then added the following command
command[check_disk]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /dev/mapper/pve-data
Save the configuration, then restart the service
/etc/init.d/nagios-nrpe-server restart
NAGIOS SERVER CONFIGURATION
Download the latest version of NRPE from http://exchange.nagios.org/directory/Addons/Monitoring-Agents/NRPE–2D-Nagios-Remote-Plugin-Executor/details
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.12.tar.gz
tar zvxf nrpe-2.12.tar.gz
cd nrpe-2.12
./configure --enable-command-args
make all
make install-plugin
Verify connectivity with the remote system from Nagios
/usr/local/nagios/libexec/check_nrpe -H IP.OF.SER.VER
If this spits back NRPE v2.12 then you’re in business. If not, then it won’t connect.
We now have to make a command for Nagios to use NRPE
nano /usr/local/nagios/etc/objects/commands.cfg
Add the following
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
Save and close
Now we can create the remote machine configuration file
Then restart the Nagios service and test
For CentOS/RHEL (RPM)
Navigate to http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
Find the latest release for your distribution (ie RHEL6 and CentOS6 x64 is http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm)
Copy the link location
Open a command shell terminal window on your CentOS/RHEL machine
rpm -Uvh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
yum install nagios-nrpe nagios-plugins-nrpe
df -h
find the name of the drive you want to monitor (or drives, ie /dev/mapper/vg_centos-lv_root)
nano /etc/nagios/nrpe.cfg
Find allowed_hosts=127.0.0.1
Change to allowed_hosts=127.0.0.1,10.4.0.253
Find command[check_hda1]
Add a line underneath to be command[check_disk]=/usr/lib64/nagios/plugins/check_disk -w 20% -c 10% -p /dev/mapper/vg_centos-lv-root (same as df -h output)
Verify your command will work:
/usr/lib64/nagios/plugins/check_disk -w 20% -c 10% -p /dev/mapper/vg_centos-lv-root
nano /etc/xinetd.d/nrpe
Find allowed_hosts=127.0.0.1
Change to allowed_hosts=127.0.0.1,10.4.0.253
nano /etc/services
Add nrpe 5666/tcp # nrpe (follow along with the template)
service nrpe restart
And to have this automatically start:
chkconfig --add nrpe
chkconfig nrpe on
I ran the test from nagios (/usr/local/nagios/libexec/check_nrpe -H IP.OF.Server) and was receiving an error:
CHECK_NRPE: Error – Could not complete SSL handshake.
Change the allowed_hosts to only be the IP of the nagios server, not localhost, then service nrpe restart
Add to the nagios monitoring server
Profit!