Nagios Remote Plugin Executor

Page content

In this article I will show you how to add Remote Linux machine and it’s services to Nagios Monitoring host using NRPE agent.

What is NRPE

NRPE allows you to remotely execute Nagios plugins on other Linux/Unix machines.

Example image

NRPE Client

yum install nrpe nagios-plugins-all
# OR
apt-get install nagios-nrpe-server nagios-plugins

NRPE Client Config

nano /etc/nagios/nrpe.cfg
...
only_from = 127.0.0.1 localhost <nagios_ip_address>
...
command[check_users]=/usr/lib64/nagios/plugins/check_users -w 5 -c 10
command[check_load]=/usr/lib64/nagios/plugins/check_load -r -w 8.0,7.5,7.0 -c 11.0,10.0,9.0
command[check_disk]=/usr/lib64/nagios/plugins/check_disk -w 15% -c 10% /
command[check_mem]=/usr/lib64/nagios/plugins/check_mem -w 75% -c 90%
command[check_total_procs]=/usr/lib64/nagios/plugins/check_procs -w 300 -c 400
command[check_swap]=/usr/lib64/nagios/plugins/check_swap -w 10 -c 5

NRPE Client Logging

nano /etc/nagios/nrpe.cfg
log_facility=local1
debug=1

nano  /etc/rsyslog.conf
local1.*                                                /var/log/nrpe.log

Start NRPE Client

systemctl start nrpe
systemctl enable nrp

ss -altn | grep 5666
LISTEN   0         5                   0.0.0.0:5666             0.0.0.0:*       
LISTEN   0         5                      [::]:5666                [::]:*

/usr/lib64/nagios/plugins/check_nrpe -H 127.0.0.1 -c check_total_procs
PROCS OK: 105 processes | procs=105;300;400;0;

NRPE Server

yum install nagios-plugins-nrpe
# createcustom commands for nrpe
nano /etc/nagios/commands.cfg
define command {
    command_name check_nrpe
    command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
nano /etc/nagios/conf.d/nrpe-test.cfg
        define host{
        use                    generic-host
        host_name              devopstales
        address                192.168.0.20
}


define service{
        use                     generic-service
        host_name               tecmint
        service_description     CPU Load
        check_command           check_nrpe!check_load
        }

Restart nagios

nagios -v /etc/nagios/nagios.cfg

Total Warnings: 0
Total Errors:   0

service nagios restart
comments powered by Disqus