Wednesday, October 30, 2024

How to Install Nagios NRPE on Ubuntu Server 24.04



Nagios is a powerful tool for monitoring your IT infrastructure. It helps keep track of system performance and alerts you to any issues. This guide will walk you through how to install and configure the Nagios NRPE (Nagios Remote Plugin Executor) client on Ubuntu 24.04. We'll also show you how to add a host on the Nagios server for monitoring.

You'll need:

  • A server running Ubuntu 24.04

  • A Nagios server already set up and running

  • A basic understanding of Linux commands

First, make sure your system is up to date. Open the terminal and run:

sudo apt update
sudo apt upgrade
    

Install the NRPE client and Nagios plugins by running:

      sudo apt install nagios-nrpe-server nagios-plugins
    

Edit the NRPE configuration file to allow connections from your Nagios server. Open the file using a text editor:

      sudo nano /etc/nagios/nrpe.cfg
    

Find the line that starts with allowed_hosts and add your Nagios server IP address. It should look like this:

      allowed_hosts=127.0.0.1,<Nagios_Server_IP>
    

Save and close the file (press CTRL + X, then Y, and Enter).

Start the NRPE service and enable it to start on boot:

sudo systemctl start nagios-nrpe-server
sudo systemctl enable nagios-nrpe-server
    

Ensure NRPE is working correctly by running the following command from your Nagios server. Replace <Client_IP> with the IP address of your Ubuntu server:

      /usr/lib/nagios/plugins/check_nrpe -H <Client_IP>
    

You should see a response like this:

      NRPE v4.0.3
    

Now, let's add the Ubuntu server as a host in Nagios for monitoring.

On your Nagios server, create a configuration file for the new host. For example:

      sudo nano /usr/local/nagios/etc/servers/ubuntu24.cfg
    

Add the following configuration to the file. Replace <Host_Name> and <Client_IP> with appropriate values.

      define host {
	use                             linux-server
	host_name                       <Host_Name>
	alias                           Ubuntu 24.04 Server
	address                         <Client_IP>
	max_check_attempts              5
	check_period                    24x7
	notification_interval           30
	notification_period             24x7
}
    

To monitor services like disk usage, CPU load, and memory usage, add the following configuration in the same file:

      define service {
	use                             generic-service
	host_name                       <Host_Name>
	service_description             Check Disk
	check_command                   check_nrpe!check_disk
}

define service {
	use                             generic-service
	host_name                       <Host_Name>
	service_description             Check Load
	check_command                   check_nrpe!check_load
}

define service {
	use                             generic-service
	host_name                       <Host_Name>
	service_description             Check Memory
	check_command                   check_nrpe!check_mem
}
    
Restart the Nagios service to apply the changes:
      sudo systemctl restart nagios
    

You have successfully installed and configured the Nagios NRPE client on Ubuntu 24.04. You also added your Ubuntu server as a host on the Nagios server for monitoring. Now, Nagios will keep an eye on your server's health and alert you if anything goes wrong.

0 comments:

Post a Comment