Monitoring Linux servers with Nagios and NRPE

Monitor linux hosts Nagios using le plugin NRPE. This is an Ubuntu install.

nrpe plugin

On your server Nagios…

Ubuntu/Debian:

# sudo apt-get install nagios-nrpe-plugin

We must check too (commands.cfg):

...
######
# NRPE
######

# 'check_nrpe' command definition
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
...

On the monitored server ...

Under Ubuntu/Debian:

# sudo apt-get install nagios-nrpe-server
# sudo apt-get install nagios-plugins

Next, we need to set up the Nagios server to be able to check our machine.

sudo nano /etc/nagios/nrpe.cfg

and change

allowed_hosts=127.0.0.1

to

allowed_hosts=127.0.0.1,x.x.x.x

where “x.x.x.x” is the ip address of your nagios server. Now restart the nrep daemon so it reloads the settings

Under Ubuntu/Debian start the service :

# /etc/init.d/nagios-nrpe-server start

next, we should check and make sure that the service is actually running. We can do this two ways

sudo ps -Al | grep nrpe

This will show a line where the process is started. If it just comes back without stating anything something is wrong. Another check is to make sure you machine is listening on the nrpe port

netstat -an | grep 5666

Some checks to do from the Nagios server

Go on Nagios derver under (/usr/lib/nagios/plugins) and test plugin NRPE:

# ./check_nrpe -H Adresse_IP_du_serveur_Linux
NRPE v2.7

If all is ok it will answer with NRPE Vn.n

We can test directly from server the NRPE Services:

# ./check_nrpe -H Adresse_IP_du_serveur_Linux -c check_load

Configure Nagios Server Models…

Edit (hosts.cfg default) and add a Linux host :

define host {
use generic-host
host_name linus
alias Ma machine Linux
address 192.168.0.7
}

Then add NRPE services (dans le fichier services.cfg), Some examples:

# Charge CPU
define service{
use generic-service
host_name remotehost
service_description CPU Load
check_command check_nrpe!check_load
}

# Memoire
define service{
use generic-service
host_name remotehost
service_description Memory
check_command check_nrpe!check_mem
}

To add new plugins to be executed byNRPE, edit /etc/nagios/nrpe.cfg and add a line by service:

...
command[check_disk]=/usr/lib/nagios/plugins/check_disk -w 20 -c 10 -p /dev/hda
...

Do not forget to launch service every time we update (nrpe.cfg):

# /etc/init.d/nagios-nrpe-server start

Cheers

extradrmtech

Since 20 years I work on Database Architecture and data migration protocols. I am also a consultant in Web content management solutions. I am an experienced web-developer with over 10 years developing PHP/MySQL, C#, VB.Net applications ranging from simple web sites to extensive web-based business applications. When not writing code, I like to dance salsa and swing and have fun with my little family.

You may also like...