Nagios Remote Host Monitoring

Post Date: October 09, 2018
Last Updated: September 28, 2026

Introduction

Nagios can monitor remote Linux servers and provide alerts when important services or system resources require attention.

Using NRPE (Nagios Remote Plugin Executor), the Nagios monitoring server can execute monitoring plugins on a remote Linux host and collect information such as:

  • CPU load
  • Disk usage
  • Memory usage
  • Running processes
  • Server uptime
  • SSH availability
  • Web server availability
  • Application services

This guide explains how to configure NRPE on a remote Linux server and add that server to Nagios monitoring.

Note: The original guide uses older RHEL/CentOS packages and NRPE versions. The commands may need adjustment for newer Linux distributions and current Nagios/NRPE installations.

Prerequisites

You need:

  • A Linux server to monitor.
  • A Nagios monitoring server.
  • Root or sudo access on both servers.
  • Network connectivity between the Nagios server and remote host.
  • TCP port 5666 allowed between the two servers.
  • Nagios and Nagios Plugins installed on the monitoring server.

Part 1: Configure the Remote Linux Host

Step 1: Install Required Packages

On a RHEL/CentOS-based remote server:

yum install -y gcc glibc glibc-common gd gd-devel make net-snmp openssl-devel

Install xinetd if your NRPE setup uses it:

yum install -y xinetd

Modern NRPE installations may use systemd instead of xinetd.

Step 2: Create the Nagios User

Create the nagios user:

useradd nagios

If the user already exists, you can skip this step.

Step 3: Download Nagios Plugins

Create a working directory:

mkdir -p /root/nagios
cd /root/nagios

Download the Nagios Plugins package:

wget https://www.nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz

Extract the package:

tar -xzf nagios-plugins-2.2.1.tar.gz

Move into the extracted directory:

cd nagios-plugins-2.2.1

Configure and compile the plugins:

./configure
make
make install

Set the required permissions:

chown -R nagios:nagios /usr/local/nagios/libexec

Step 4: Install NRPE

Download the NRPE source package:

cd /root/nagios
wget https://github.com/NagiosEnterprises/nrpe/releases/download/nrpe-3.1.1/nrpe-3.1.1.tar.gz

Extract it:

tar -xzf nrpe-3.1.1.tar.gz

Move into the directory:

cd nrpe-3.1.1

Configure and compile:

./configure
make all

Install the NRPE plugin and daemon:

make install-plugin
make install-daemon
make install-daemon-config

Step 5: Configure NRPE

Edit the NRPE configuration:

vi /usr/local/nagios/etc/nrpe.cfg

Configure the Nagios monitoring server IP in the allowed hosts configuration.

For example:

allowed_hosts=127.0.0.1,<NAGIOS_SERVER_IP>

Replace <NAGIOS_SERVER_IP> with the actual IP address of your Nagios server.

Step 6: Configure NRPE Port

NRPE normally listens on TCP port 5666.

Verify that the service is configured to use this port.

If your installation uses /etc/services, the entry is:

nrpe 5666/tcp NRPE

Step 7: Start NRPE

If NRPE is configured as a systemd service:

systemctl enable nrpe
systemctl start nrpe

Check its status:

systemctl status nrpe

If the installation uses xinetd instead:

systemctl restart xinetd

Step 8: Verify NRPE

Check whether port 5666 is listening:

ss -lntp | grep 5666

You can also test NRPE locally:

/usr/local/nagios/libexec/check_nrpe -H 127.0.0.1

A successful response should return the installed NRPE version.

Part 2: Configure the Firewall

Allow TCP port 5666 from the Nagios monitoring server.

For firewalld:

firewall-cmd --permanent --add-port=5666/tcp
firewall-cmd --reload

For better security, restrict access to the Nagios server rather than opening the port to all sources.

For example, using firewalld rich rules:

firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="<NAGIOS_SERVER_IP>" port protocol="tcp" port="5666" accept'
firewall-cmd --reload

Replace <NAGIOS_SERVER_IP> with the monitoring server’s IP address.

Part 3: Configure the Nagios Monitoring Server

Step 1: Install NRPE Plugin

On the Nagios monitoring server, download and install the NRPE plugin if it is not already available.

The important component for remote checks is:

check_nrpe

Verify that it exists:

ls -l /usr/local/nagios/libexec/check_nrpe

Step 2: Test the Remote Host

From the Nagios server, test communication with the remote server:

/usr/local/nagios/libexec/check_nrpe -H <REMOTE_SERVER_IP>

A successful response should display the NRPE version.

You can also test individual checks:

/usr/local/nagios/libexec/check_nrpe -H <REMOTE_SERVER_IP> -c check_load

Step 3: Add the Remote Host to Nagios

Create a configuration file for the remote server:

vi /usr/local/nagios/etc/servers/example_01.cfg

Add the host configuration:

define host {
    use                     linux-server
    host_name               example_01
    alias                   example_01
    address                 XXX.XXX.XXX.XXX
    max_check_attempts      5
    check_period            24x7
    notification_interval   30
    notification_period     24x7
}

Replace the IP address with the actual remote server IP.

Step 4: Configure Services

Ping

define service {
    use                     generic-service
    host_name               example_01
    service_description     PING
    check_command           check_ping!100.0,20%!500.0,60%
}

SSH

define service {
    use                     generic-service
    host_name               example_01
    service_description     SSH
    check_command           check_ssh
}

HTTP

define service {
    use                     generic-service
    host_name               example_01
    service_description     HTTP
    check_command           check_tcp!80
}

Load

define service {
    use                     generic-service
    host_name               example_01
    service_description     Load
    check_command           check_nrpe!check_load
}

Disk Usage

define service {
    use                     generic-service
    host_name               example_01
    service_description     Disk
    check_command           check_nrpe!check_disk
}

Processes

define service {
    use                     generic-service
    host_name               example_01
    service_description     Processes
    check_command           check_nrpe!check_procs
}

Uptime

define service {
    use                     generic-service
    host_name               example_01
    service_description     Uptime
    check_command           check_nrpe!check_uptime
}

Memory

define service {
    use                     generic-service
    host_name               example_01
    service_description     Memory
    check_command           check_nrpe!check_mem
}

uWSGI

If check_uwsgi is configured on the remote server:

define service {
    use                     generic-service
    host_name               example_01
    service_description     uWSGI
    check_command           check_nrpe!check_uwsgi
}

Step 5: Validate Nagios Configuration

Before restarting Nagios, validate the configuration:

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Make sure the output reports:

Total Errors:   0
Total Warnings: 0

Correct any configuration errors before restarting Nagios.

Step 6: Restart Nagios

Restart the Nagios service:

systemctl restart nagios

Check the service:

systemctl status nagios

The newly configured remote server should now appear in the Nagios monitoring interface.

Monitoring Flow

Remote Linux Server
        |
        | NRPE : 5666
        |
        v
Nagios Monitoring Server
        |
        v
Nagios Plugins
        |
        v
Monitoring Dashboard
        |
        v
Alerts / Notifications

Conclusion

Nagios with NRPE allows administrators to monitor important resources and services on remote Linux servers.

Once NRPE is configured, the Nagios server can monitor:

  • Server availability
  • CPU load
  • Disk usage
  • Memory
  • Processes
  • Uptime
  • SSH
  • Web services
  • Application services

Restricting NRPE access to the Nagios monitoring server and validating the configuration before restarting services are important steps for a secure and reliable monitoring setup.

FAQs

1. What is NRPE?

NRPE stands for Nagios Remote Plugin Executor. It allows Nagios to execute monitoring plugins on remote Linux servers.

2. Which port does NRPE use?

NRPE commonly uses TCP port:

5666

3. How can I test NRPE connectivity?

From the Nagios server:

/usr/local/nagios/libexec/check_nrpe -H <REMOTE_SERVER_IP>

Install & Configure Nagios Server — Read the article

Talk to Our Experts

Need help with server monitoring, Nagios, cloud, or DevOps? Our experts can help you build and manage reliable infrastructure.

Get in touch with us: Contact our team

admin

Our team has expertise across software and web development, WordPress, e-commerce, mobile applications, UI/UX, cloud and infrastructure, DevOps, CI/CD, API integration, security, testing, automation, and technical support. The team also works with AI-based software solutions, LLMs, AI workflows, AI agents, and intelligent application development to help businesses automate processes and build smarter digital solutions. We focus on developing, deploying, maintaining, and optimising secure, scalable, and reliable technology solutions while helping businesses adopt modern technologies and drive digital transformation.

Leave a Reply

Scroll to Top