How to Configure Nagios NRPE on Ubuntu 22.04

0
Hello there, fellow SysAdmins! Today, I'm going to walk you through the process of setting up the Nagios NRPE client on your Ubuntu 22.04 system. Nagios is a fantastic open-source monitoring solution that allows you to keep a close eye on your servers and network infrastructure. The Nagios Remote Plugin Executor (NRPE) is a crucial component that lets you execute Nagios plugins on remote systems. With this guide, you'll be well on your way to monitoring your system effectively.


Before we dive into the installation and configuration, make sure you have an Ubuntu 22.04 server with sudo access, stable internet, a running Nagios server. If you need  to setup Nagios server, you can refer to the Nagios documentation. Or you need any help please comment down below. I will create a separate blog for this. Now, let's get started!

Step 1: Update Your System

To kick things off, we need to ensure our system is up to date. Open your terminal and enter the following command:

apt update && sudo apt upgrade -y

Step 2: Install Nagios NRPE Client

The Nagios NRPE packages are conveniently available in the default repositories on Ubuntu systems. Installing them is a breeze. Open your terminal and use these commands:

apt install nagios-nrpe-server nagios-plugins
 
The 'nagios-nrpe-server' package sets up the NRPE service on your system, while 'nagios-plugins' provides the monitoring scripts that the NRPE client uses when requested by the Nagios server.

Step 3: Configuring Nagios Client

Now, let's configure the Nagios client. We need to specify which Nagios servers are allowed to send requests to the client. For example, if your Nagios server's IP address is 192.168.1.100, you should add this IP to the allowed hosts list. To do this, open the NRPE configuration file at '/etc/nagios/nrpe.cfg' with this command:

vi /etc/nagios/nrpe.cfg

Look for the 'allowed_hosts' section and add your Nagios server's IP address:

allowed_hosts=127.0.0.1, 192.168.X.X

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

Update Command Definitions for NRPE

Now, you'll want to define all the commands that the Nagios server will use. Some commands are pre-configured, while others need customization. Open the '/etc/nagios/nrpe.cfg' configuration file and find the COMMAND DEFINITIONS section:

vi /etc/nagios/nrpe.cfg

** Verify the entries you wants to monitor:

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 the NRPE daemon to apply the changes:

systemctl restart nagios-nrpe-server

Allow  Firewall

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

firewall-cmd --permanent --zone=public --add-port=5666/tcp
firewall-cmd --reload
 
At last, By following these steps, you'll be able to monitor your Ubuntu system's performance and health with the powerful and popular open-source monitoring solution, Nagios. It's a valuable tool for ensuring the stability and reliability of your servers and network infrastructure.

Post a Comment

0Comments
Post a Comment (0)