Nagios, Nconf and Nrpe on Debian/Ubuntu part 3/3

NRPE Configuration

Remote machine configuration: Create a new nagios user and assign a password.

/usr/sbin/useradd nagios
passwd nagios

Download and extract nagios plugins

wget https://www.nagios-plugins.org/download/nagios-plugins-1.5.tar.gz

apt-get install libssl-dev
tar zxvf nagios-plugins-1.5.tar.gz
cd nagios-plugins-1.5

Compile and install the plugins.

./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install

Plugin permissions need to be fixed, so run these commands.

chown nagios.nagios /usr/local/nagios
chown -R nagios.nagios /usr/local/nagios/libexec

Installs the NRPE daemon as a service on xinetd.

apt-get install xinetd

wget http://sourceforge.net/projects/nagios/files/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz
tar zxvf nrpe-2.15.tar.gz
cd nrpe-2.15

./configure --with-ssl=/usr/bin/openssl --with-ssl-lib=/usr/lib/i386-linux-gnu/
make all 

For 64bit users:

ln -s /usr/lib/x86_64-linux-gnu/libssl.so /usr/lib/libssl.so
./configure
make all 

Install the NRPE plugin (for testing), daemon, and the daemon config file examples.

make install-plugin
make install-daemon
make install-daemon-config

Install the NRPE daemon service on xinetd.

make install-xinetd

Edit the file /etc/xinetd.d/nrpe and add the IP address of the server where Nagios is installed in the only_from section.

only_from = 127.0.0.1 <nagios_ip_address>

Save and exit

:wq

Add this line for NRPE daemon to /etc/services

nrpe 5666/tcp # NRPE

Save and exit

:wq

Restart xinetd service

service xinetd restart

Test NRPE locally Make sure NRPE daemon is running under xinetd

netstat -at | grep nrpe

The output should be something like this:

tcp 0 0 *:nrpe *:* LISTEN

Configuration in Nagios Machine:

Install NRPE plugin on the machine where nagios is

wget http://sourceforge.net/projects/nagios/files/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz
tar zxvf nrpe-2.15.tar.gz
cd nrpe-2.15

./configure --with-ssl=/usr/bin/openssl --with-ssl-lib=/usr/lib/i386-linux-gnu/
make all
make install-plugin

for 64bit users:

ln -s /usr/lib/x86_64-linux-gnu/libssl.so /usr/lib/libssl.so
./configure
make all
make install-plugin

Test communication between the host machine and the remote machine.

/usr/local/nagios/libexec/check_nrpe -H <ip_address_remote_machine>

The output should look like this:

NRPE v2.15

Configure Nconf with NRPE commands (some of them) In the file /usr/local/nagios/etc/nrpe.cfg you can see these lines:

#Check current users
command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10

#Current Load
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20

#Root Partitions
command[check_sda1]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/sda1

#ZombieProcesses
command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z

#TotalProcesses
command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 150 -c 200

#SwapUsage
command[check_remote_swap]=/usr/local/nagios/libexec/check_swap -w 70% -c 90% 

Before using check_disk make sure you have the right path to /dev/xxx as in the example:

df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 109G 18G 86G 17% /

Configure Nconf to use NRPE: In the Nconf menu click on ADD in the checkcommands option and write

check command name: check_users
default service name: Check Users
check command line: $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_users

Default service template: generic_service

Then click on submit.

Now the command is ready to be added as a service in one of the machines to monitor.