NRPE is a client side application for executing Nagios plugins. The Nagios server communicate with remote system over TCP Port 5666 using this plugin.
NRPE must be installed on all the remote systems needs to monitor by Nagios server. Nagios server sends instruction to the NRPE server using check_nrpe
plugin.
Install Nagios Client on Ubuntu
NRPE packages are available under the default repositories on Ubuntu systems. Open a terminal and run the following command to install:
sudo apt update
sudo apt install nagios-nrpe-server nagios-plugins
Here nagios-nrpe-server package install service on system and nagios-plugins provides monitoring scripts, which is called with NRPE client on request of Nagios server.
Configure Nagios Client
In NRPE configuration, first we need to nrpe to which nagios servers it accepts requests, For example your Nagios server IP is 192.168.1.100, then add this IP to allowed hosts list. Edit NRPE configuration file /etc/nagios/nrpe.cfg and make the necessary changes like below:
sudo nano /etc/nagios/nrpe.cfg
allowed_hosts=127.0.0.1, 192.168.1.100
We can allow multiple Nagios servers by a comma-separated list.
Next, restart NRPE service. Now it is ready to listen to requests from Nagios server (assuming you have allowed TCP Port 5666 from your Nagios Server on any firewalls, if you use them).
sudo systemctl restart nagios-nrpe-server
Verify Connection from Nagios
Let’s verify the connection between the Nagios server and NRPE client machine. Login to your Nagios server and check the Nagios server can communicate with NRPE service properly.
Use check_nrpe command on the Nagios server under the plugins directory. The command will be like as below here 192.168.1.11 is the IP address of client machine.
check_nrpe -H 192.168.1.11
NRPE v4.0.0
The output “NRPE v4.0.0” shows that the Nagios server successfully communicated with NRPE.
Update Command Definitions for NRPE
You must have define all the commands to be used by Nagios server. Some of them are pre-configured with the installation. You may required to change command definitions as per your system’s configuration. Also, you can add more customized commands to monitor your server.
Edit the /etc/nagios/nrpe.cfg configuration file and search for COMMAND DEFINITIONS secitons. Here you can define or update check commands.
sudo nano /etc/nagios/nrpe.cfg
/etc/nagios/nrpe.cfg
command[check_users]=/usr/lib/nagios/plugins/check_users -w 5 -c 10
command[check_load]=/usr/lib/nagios/plugins/check_load -w 15,10,5 -c 30,25,20
command[check_hda1]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /dev/hda1
command[check_zombie_procs]=/usr/lib/nagios/plugins/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/lib/nagios/plugins/check_procs -w 150 -c 200
Save the configuration file and restart NRPE daemon to apply changes:
sudo systemctl restart nagios-nrpe-server
Ref: https://tecadmin.net/how-to-install-nrpe-on-ubuntu-20-04/