Nagios is a powerful open-source monitoring solution that allows you to monitor your servers and network infrastructure. The Nagios Remote Plugin Executor (NRPE) is a client-side component that allows the execution of Nagios plugins on remote systems. This guide will walk you through the installation and configuration of the Nagios NRPE client on Ubuntu 22.04.

Advertisement

Prerequisites

  • Ubuntu 22.04 server with sudo access
  • Nagios server up and running (for further instructions, consult the Nagios documentation)

Step 1: Update Your System

Before installing any software, it’s essential to update your system. Open a terminal and run the following command:

sudo apt update && sudo apt upgrade -y  

Step 2: Install Nagios NRPE Client

The Nagios Remote Plugin Executor (NRPE) packages are readily available in the default repositories on Ubuntu systems. To install them, open a terminal and enter the following command:

sudo apt update 
sudo apt install nagios-nrpe-server nagios-plugins  

The `nagios-nrpe-server` package installs the NRPE service on the system, while nagios-plugins provides monitoring scripts that are called by the NRPE client upon request from the Nagios server.

Step 3: Configuring Nagios Client

In the NRPE configuration, we need to specify to which Nagios servers the client accepts requests. For example, if the Nagios server’s IP is 192.168.1.100, add this IP to the allowed hosts list. Edit the NRPE configuration file located at `/etc/nagios/nrpe.cfg` and make the necessary changes, as shown below:

sudo nano /etc/nagios/nrpe.cfg  

Search for `allowed_hosts` and add your Nagios server IP address.

You can allow multiple Nagios servers by providing a comma-separated list.

Next, restart the NRPE service to apply the changes:

sudo systemctl restart nagios-nrpe-server  

Step 4: Verify Connection from Nagios

To verify the connection between the Nagios server and the NRPE client, log in to your Nagios server and check if it can communicate with the NRPE service properly.

Use the `check_nrpe` command on the Nagios server, located in the plugins directory, to check the connection. The command will be like this, where 192.168.1.11 is the IP address of the client machine:

check_nrpe -H 192.168.1.11  

If successful, the output should be “NRPE v4.0.0”, indicating that the Nagios server has successfully communicated with NRPE.

Step 5: Update Command Definitions for NRPE

You must define all the commands to be used by the Nagios server. Some of them are pre-configured with the installation, while others need to be updated or customized as per your system’s configuration.

Edit the `/etc/nagios/nrpe.cfg` configuration file and search for the COMMAND DEFINITIONS section. Here, you can define or update check commands as needed, as shown below:

sudo nano /etc/nagios/nrpe.cfg  

Search for below command options and update according to your need.

Save the configuration file and restart the NRPE daemon to apply the changes:

sudo systemctl restart nagios-nrpe-server  

Step 6: Adjust Firewall

By default, the NRPE service listens on port 5666. Use the following commands to open the firewall port for the NRPE service:

sudo firewall-cmd --permanent --zone=public --add-port=5666/tcp  
sudo firewall-cmd --reload  

Conclusion

In conclusion, setting up the Nagios client on an Ubuntu system is a straightforward process that involves installing the NRPE packages, configuring the NRPE client, verifying the connection between the Nagios server and the NRPE client, updating command definitions for NRPE, and adjusting the firewall to allow incoming requests on port 5666. By following the steps outlined in this tutorial, you can easily monitor your Ubuntu system’s performance and health using Nagios, which is a powerful and popular open-source monitoring solution.

Share.
Leave A Reply

Exit mobile version