How to Add Linux Host to Nagios Monitoring Server Using NRPE Plugin

Nagios is an open-source monitoring system that helps system administrators monitor the performance and availability of various network resources, including hosts, services, and network devices. NRPE (Nagios Remote Plugin Executor) is a plugin used to monitor remote hosts or devices from the Nagios server by executing monitoring plugins on the remote host and returning results to the Nagios server.

This guide demonstrates how to add a Linux host to your Nagios monitoring infrastructure using the NRPE plugin for comprehensive system monitoring.

Prerequisites

Before beginning the setup, ensure the following requirements are met:

  • Nagios Core installed and configured on the monitoring server

  • A Linux machine to monitor with network connectivity to the Nagios server

  • Root or sudo access on both the Nagios server and the target Linux host

  • Firewall configured to allow communication on port 5666 (NRPE default port)

Architecture Overview

Nagios NRPE Monitoring Architecture Nagios Server ? Web Interface ? Configuration ? Alerting Linux Host ? NRPE Daemon ? Nagios Plugins ? System Checks check_nrpe results Port 5666 (TCP) Network Connection

Step 1: Installing NRPE on the Linux Host

Install the NRPE daemon and Nagios plugins on the target Linux host using your distribution's package manager:

Ubuntu/Debian

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

CentOS/RHEL

sudo yum install nrpe nagios-plugins-all
# OR for newer versions
sudo dnf install nrpe nagios-plugins-all

Step 2: Configuring NRPE on the Linux Host

Edit the NRPE configuration file to allow connections from your Nagios server and define monitoring commands:

sudo nano /etc/nagios/nrpe.cfg

Modify the following key parameters:

# Allow connections from Nagios server
allowed_hosts=127.0.0.1,192.168.1.10

# Define monitoring commands
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_disk_root]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /
command[check_total_procs]=/usr/lib/nagios/plugins/check_procs -w 250 -c 400
command[check_zombie_procs]=/usr/lib/nagios/plugins/check_procs -w 5 -c 10 -s Z

Replace 192.168.1.10 with your actual Nagios server IP address.

Start and Enable NRPE Service

sudo systemctl start nrpe
sudo systemctl enable nrpe
sudo systemctl status nrpe

Step 3: Configuring Nagios Server

On the Nagios server, create a configuration file for the Linux host:

sudo nano /usr/local/nagios/etc/objects/linux-host.cfg

Define the Host

define host {
    use                     linux-server
    host_name               webserver-01
    alias                   Web Server 01
    address                 192.168.1.20
    max_check_attempts      5
    check_period            24x7
    notification_interval   30
    notification_period     24x7
}

Define Service Checks

define service {
    use                     generic-service
    host_name               webserver-01
    service_description     Current Users
    check_command           check_nrpe!check_users
    check_interval          5
    retry_interval          3
}

define service {
    use                     generic-service
    host_name               webserver-01
    service_description     Current Load
    check_command           check_nrpe!check_load
    check_interval          5
    retry_interval          3
}

define service {
    use                     generic-service
    host_name               webserver-01
    service_description     Root Disk Space
    check_command           check_nrpe!check_disk_root
    check_interval          5
    retry_interval          3
}

define service {
    use                     generic-service
    host_name               webserver-01
    service_description     Total Processes
    check_command           check_nrpe!check_total_procs
    check_interval          5
    retry_interval          3
}

Verify Configuration and Restart Nagios

sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
sudo systemctl restart nagios

Step 4: Testing the Connection

Test the NRPE connection from the Nagios server to ensure proper communication:

/usr/local/nagios/libexec/check_nrpe -H 192.168.1.20
NRPE v3.2.1

Test specific commands:

/usr/local/nagios/libexec/check_nrpe -H 192.168.1.20 -c check_users
/usr/local/nagios/libexec/check_nrpe -H 192.168.1.20 -c check_load

Monitoring Results

Access the Nagios web interface by navigating to http://your-nagios-server/nagios in your web browser. You should see the newly added Linux host under the Hosts section with its associated service checks displaying current status information.

Nagios Monitoring Status Dashboard Host: webserver-01 (192.168.1.20) - UP ? Current Users: OK - 3 users currently logged in ? Current Load: OK - load average: 0.15, 0.18, 0.12 ? Root Disk Space: WARNING - 85% used (15% free) ? Total Processes: OK - 157 processes running Last Updated: 2024-01-15 14:30:25

Security Considerations

Firewall Configuration: Configure your firewall to allow connections only from the Nagios server IP address on port 5666.

SSL/TLS Encryption: Enable SSL encryption in NRPE for secure communication by setting ssl_version=TLSv1.2+ in the configuration.

Command Restrictions: Only define necessary monitoring commands in the NRPE configuration to minimize security exposure.

Troubleshooting

Enable debug logging by adding debug=1 to /etc/nagios/nrpe.cfg and check logs at /var/log/messages or /var/log/syslog.

Common issues include firewall blocking port 5666, incorrect IP addresses in allowed_hosts, or missing plugins in the specified paths.

Conclusion

Adding Linux hosts to Nagios monitoring using NRPE provides comprehensive system monitoring capabilities. This setup enables real-time monitoring of critical system metrics like CPU load, disk usage, and running processes. Proper configuration ensures reliable monitoring and timely alerts for maintaining system health and performance.

Updated on: 2026-03-17T09:01:38+05:30

3K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements