Before the installation we have a look at the design chart of the nrpe:

The NRPE addon consists of two pieces:
• The  check_nrpe plugin, which resides on the local monitoring Host
• The  NRPE daemon, which runs on the remote Linux/Unix machine

When Nagios needs to monitor a resource of service from a remote Linux/Unix machine:
• Nagios will execute the check_nrpe plugin and tell it what service needs to be checked
• The check_nrpe plugin contacts the NRPE daemon on the remote host over an (optionally) SSL  protected connection
• The NRPE daemon runs the appropriate Nagios plugin to check the service or resource

• The results from the service check are passed from the NRPE daemon back to the check_nrpe plugin,  which then returns the check results to the Nagios process.

Linux Client

You can install the plugin on a Linux server that will be monitored. In addition, you also need to plugin executor NRPE.

On Remote machine

1.  Library installation and Account Setup:

yum install openssl openssl-devel gcc xinetd

useradd nagios

2. Install Nagios Plugins:

Download the latest nagios-plugins-x.x.x.tar.gz : http://nagios-plugins.org/download/

Extract the Nagios plugins source code tarball.
# tar xzf nagios-plugins-2.1.1.tar.gz
# cd nagios-plugins-2.1.1
Note: on some systems, you will have to run the extract this way:
# gunzip -c nagios-plugins-2.1.1.tar.gz | tar xf -
Compile and install the plugins.
# ./configure
# make
# make install
Depending on the version of the plugins, the permissions on the plugin directory and the plugins may need to be fixed at this point. If so run the following commands:
# chown nagios.nagios /usr/local/nagios
# chown -R nagios.nagios /usr/local/nagios/libexec

3. Install NRPE (Nagios Remote plugin executor)

Manually:

Download Load NRPE : https://exchange.nagios.org/directory/Addons/Monitoring-Agents/NRPE–2D-Nagios-Remote-Plugin-Executor/details

tar -xvf nrpe-3.0.1.tar.gz
./configure
make all
make install-daemon

make install-init

In /etc/services add entry:
nrpe 5666/tcp #NRPE Nagios Client

Copy nrpe.xinetd from nrpe samplefiles to /etc/xinetd.d

Configure /etc/xinetd.d/nrpe.xinetd

change the only_from =xxx.xxx.xxx.xx to the IP of the nagios monitor server.

Restart xinetd:

service xinetd restart

 mkdir /usr/local/nagios/etc/

Copy the nrpe.cfg from the sample-conf to  /usr/local/nagios/etc/nrpe.cfg

Then configure:

allowed_hosts=127.0.0.1, xxx.xxx.xxx.xxxmak

xxx.xxx.xxx.xxx is the nagios monitoring server’s IP address.

dont_blame_nrpe=1

common out these lines (around lines 287) to disable the hard-coded command:

#command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10
#command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20
#command[check_hda1]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/hda1
#command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z
#command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 150 -c 200

Uncommon these lines to allow parameters

command[check_users]=/usr/local/nagios/libexec/check_users -w $ARG1$ -c $ARG2$
command[check_load]=/usr/local/nagios/libexec/check_load -w $ARG1$ -c $ARG2$
command[check_disk]=/usr/local/nagios/libexec/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$
command[check_procs]=/usr/local/nagios/libexec/check_procs -w $ARG1$ -c $ARG2$ -s $ARG3$

Install from yum(2.15 as of now)

sudo yum install  -y nrpe nagios-plugins-{ping,disk,users,procs,load,swap,ssh}
vi /etc/nagios/nrpe.cfg
 # line 81: add access permission (specify Nagios server)

allowed_hosts=127.0.0.1,10.0.0.30
# line 97: permit arguments of commands

dont_blame_nrpe=1
# line 210: comment out all

# command[check_users]=/usr/lib64/nagios/plugins/check_users -w 5 -c 10
# command[check_load]=/usr/lib64/nagios/plugins/check_load -w 15,10,5 -c 30,25,20
# command[check_hda1]=/usr/lib64/nagios/plugins/check_disk -w 20% -c 10% -p /dev/hda1
# command[check_zombie_procs]=/usr/lib64/nagios/plugins/check_procs -w 5 -c 10 -sZ
# command[check_total_procs]=/usr/lib64/nagios/plugins/check_procs -w 150 -c 200
# line 223: uncomment all

command[check_users]=/usr/lib64/nagios/plugins/check_users -w $ARG1$ -c $ARG2$
command[check_load]=/usr/lib64/nagios/plugins/check_load -w $ARG1$ -c $ARG2$
command[check_disk]=/usr/lib64/nagios/plugins/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$
command[check_procs]=/usr/lib64/nagios/plugins/check_procs -w $ARG1$ -c $ARG2$ -s $ARG3$
[root@node01 ~]# systemctl start nrpe

[root@node01 ~]# systemctl enable nrpe
Firewall settings

On legacy Linux:

Open firewall /etc/sysconfig/iptables

or On centos 7

firewall-cmd --zone=public --add-port=5666/tcp --permanent
on Nagios Server

Make sure you have plugin check_nrpe in /usr/local/nagios/libexec, if not install it by the steps: https://support.nagios.com/kb/article.php?id=569

Copy template

cp /usr/local/nagios/etc/objects/localhost.cfg  /usr/local/nagios/etc/objects/linuxclient.cfg

Configure /usr/local/nagios/etc/nagios.cfg

Add the new configured template ” linuxclient.cfg” to the nagios.cfg:

cfg_file=/usr/local/nagios/etc/objects/linuxclient.cfg

Modify the linuxclient.cfg file:

1.  Replace the localhost with linuxclient: 1,$ s/localhost/linuxclient/g

2.  Configure the resources we need to monitor:

Note that the original one is using check_local_disk, check_local_procs, etc, you need to change to check_nrpe!check_disk

Create a command definition

Before that, You’ll need to create a command definition in one of your Nagios object configuration files in order to use  the check_nrpe plugin. Open the sample commands.cfg file for editing…

# vimacs /usr/local/nagios/etc/commands.cfg
and add the following definition to the file:

define command{
 command_name check_nrpe
 command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
 }
Configure the host file

You are now ready to start adding services that should be monitored on the remote machine to the Nagios configuration

 # create new

define host{
    use                    linux-server
    host_name              linuxclient
    alias                  linuxclient
    address                192.168.90.29
    }
define service{
    use                    generic-service
    host_name              linuxclient
    service_description    PING
    check_command          check_ping!100.0,20%!500.0,60%
    }

# for free disk

define service{
    use                    generic-service
    host_name              linuxclient
    service_description    Root Partition
    check_command          check_nrpe!check_disk\!20%\!10%\!/
    }

# for current users

define service{
    use                    generic-service
    host_name              linuxclient
    service_description    Current Users
    check_command          check_nrpe!check_users\!20\!50
    }

# for total processes

define service{
    use                    generic-service
    host_name              linuxclient
    service_description    Total Processes
    check_command          check_nrpe!check_procs\!250\!400\!RSZDT
    }

# for current load

define service{
    use                    generic-service
    host_name              linuxclient
    service_description    Current Load
    check_command          check_nrpe!check_load\!5.0,4.0,3.0\!10.0,6.0,4.0
    }

Restart nagios:

service nagios restart
Add New command on the remote Linux Host:

If you want to check other disk space by new command, such as root / :

On the Remote machine:

Open the file: /usr/local/nagios/etc/nrpe.cfg

Add following line

command[check_root]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /

reload the nrpe service:

sudo service nrpe restart

On the monitoring machine:

Then ran this command on the monitoring nagios server after editing nrpe.cfg on remote machine:

/usr/local/nagios/libexec/check_nrpe -H ('linux1' ip address of linux host to monitor) -c check_root

On my remote host configuration file /usr/local/nagios/etc/object/linux.cfg, add command:

check_command check_nrpe!check_root

Reload the nagios service:

sudo service nagios restart