If you’re looking to monitor your CentOS/RHEL servers using Nagios, you’ll need to install the NRPE (Nagios Remote Plugin Executor) service. NRPE allows Nagios to execute plugins on remote hosts and monitor their health status.
In this article, we’ll walk you through the process of installing Nagios Remote Plugin Executor on CentOS/RHEL 9/8/7.
To see how to install this agent on Ubuntu, click here.
Prerequisites
Before you begin, make sure you have the following prerequisites:
- A CentOS/RHEL 9/8/7 server with root access
- Internet connectivity
Step 1: Install EPEL Repository
First, we need to install the EPEL (Extra Packages for Enterprise Linux) repository, which contains the NRPE package.
To install EPEL, run the following command :
[root@Linux ~]# dnf install epel-release
For RHEL 8/9 use dnf command instead.
Run the following command to check if the repository is added successfully :
[root@Linux ~]# yum repolist
Step 2: Install NRPE
Now that the EPEL repository is installed, we can install the NRPE package using the following command :
[root@Linux ~]# yum install nrpe nagios-plugins-nrpe -y
Step 3: Configure NRPE
After installing our agent, we need to configure it to communicate with Nagios. We’ll need to edit the nrpe.cfg file to specify the Nagios server’s IP address and define the plugins to execute.
[root@Linux ~]# vi /etc/nagios/nrpe.cfg
Locate the following lines in the file :
allowed_hosts=127.0.0.1,::1
Replace the allowed_hosts line with the IP address of your Nagios server, like this:
allowed_hosts=192.168.5.2
Then, command lines to define the plugins to execute. For exemple to define a command to check the load average, users and disk usage, you would add the following line :
command[check_load]=/usr/lib64/nagios/plugins/check_load -w 15,10,5 -c 30,25,20 command[check_users]=/usr/lib64/nagios/plugins/check_users -w 5 -c 10 command[check_disk]=/usr/lib64/nagios/plugins/check_disk -w 20% -c 10% -p /dev/sda1
Step 4: Start NRPE
Now that Nagios agent is installed and configured, we can start the service and enable it to start automatically at boot :
[root@Linux ~]# systemctl start nrpe [root@Linux ~]# systemctl enable nrpe
Step 5: Configure Firewall
If you’re running a firewall on your server, you’ll need to allow incoming traffic on port 5666, which NRPE uses to communicate with Nagios.
[root@Linux ~]# firewall-cmd --add-port=5666/tcp --permanent [root@Linux ~]# firewall-cmd --reload
Step 6: Verify Installation
To verify that the Nagios agent is installed and working correctly, run the following command :
[root@Linux ~]# /usr/lib64/nagios/plugins/check_nrpe -H 127.0.0.1
If the NRPE configuration is correct, the output should be similar to the following :
NRPE v4.1.0
Also, you can use the check_nrpe plugin on the Nagios server to execute a plugin on the remote server :
[root@Linux ~]# /usr/lib64/nagios/plugins/check_nrpe -H 192.168.5.101 -c check_load
If Nagios agent is installed and configured correctly, you should see output similar to the following :
OK - load average: 0.00, 0.01, 0.05|load1=0.000;15.000;30.000;0; load5=0.010;10.000;25.000;0; load15=0.050;5.000;20.000;
nmap : les 12 commandes que vous devez connaître
Protocole du routage
Définir temporairement une adresse IP sur un OS Linux
Samba : Installation et Configuration sur Ubuntu 22.04
Fail2Ban : How to protect Linux services