Operations 6 min read

How to Add Remote Servers to Nagios: Step‑by‑Step Installation & Configuration

This guide explains the remote monitoring principle of Nagios using NRPE, then walks through installing Nagios‑plugins and NRPE on both the monitored host and the Nagios server, configuring host and service definitions, and verifying communication through the web interface.

Java High-Performance Architecture
Java High-Performance Architecture
Java High-Performance Architecture
How to Add Remote Servers to Nagios: Step‑by‑Step Installation & Configuration

Remote Monitoring Principle

Nagios can communicate with remote hosts via several methods such as SNMP, NRPE, or SSH; this article uses NRPE. NRPE consists of two parts: the check_nrpe plugin on the Nagios server and the NRPE daemon running on the remote host as an agent.

The monitoring flow is:

1) Nagios runs the check_nrpe plugin to request specific information. 2) check_nrpe connects to the remote NRPE daemon. 3) The daemon executes the requested plugin and returns the result. 4) Nagios processes the returned data.

Installation and Configuration Process

1) Install Nagios‑plugins and NRPE on the monitored host

Add a dedicated user: useradd -s /sbin/nologin nagios Install required packages and download Nagios‑plugins:

yum -y install gcc gcc-c++ make openssl openssl-devel
wget http://www.nagios-plugins.org/download/nagios-plugins-2.1.1.tar.gz
tar zxf nagios-plugins-2.1.1.tar.gz
cd nagios-plugins-2.1.1
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make && make install

Download and extract NRPE:

tar xf nrpe-3.0.1.tar.gz
cd nrpe-3.0.1
./configure --with-nrpe-user=nagios \
--with-nrpe-group=nagios \
--with-nagios-user=nagios \
--with-nagios-group=nagios \
--enable-command-args \
--enable-ssl
make all
make install-plugin
make install-daemon
cp sample-config/nrpe.cfg /usr/local/nagios/etc

Edit /usr/local/nagios/etc/nrpe.cfg to add the Nagios server IP to allowed_hosts, then start NRPE:

/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d

Verify the daemon is listening on port 5666, e.g., with netstat -tnlp.

2) Install and configure NRPE on the Nagios server

Repeat the same download and build steps for NRPE on the server. After installation, the check_nrpe plugin appears in /usr/local/nagios/libexec/. Test communication: ./check_nrpe -H <monitored_host_ip> If successful, the plugin returns the remote NRPE version.

Configure Nagios commands by editing commands.cfg and adding:

define command{
    command_name    check_nrpe
    command_line    $USER1$/check_nrpe -H "$HOSTADDRESS$" -c "$ARG1$"
}

Create a host configuration file myserver1.cfg with definitions for the host, hostgroup, and a service (e.g., load monitoring):

define host{
    use         linux-server
    host_name   MyServer1
    alias       MyServer1
    address     192.168.31.188
}

define hostgroup{
    hostgroup_name  linux-servers2
    alias           linux Servers
    members         MyServer1
}

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

Update nagios.cfg to include the new file: cfg_file=/usr/local/nagios/etc/objects/myserver1.cfg Check the configuration syntax and restart Nagios:

service nagios configtest
service nagios restart

After restarting, log into the Nagios web interface to see the newly added host and its services.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

LinuxInstallationNagiosNRPERemote Monitoring
Java High-Performance Architecture
Written by

Java High-Performance Architecture

Sharing Java development articles and resources, including SSM architecture and the Spring ecosystem (Spring Boot, Spring Cloud, MyBatis, Dubbo, Docker), Zookeeper, Redis, architecture design, microservices, message queues, Git, etc.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.