How to Add Remote Linux to Nagios Server Using NRPE Plugin (2023)

In the first part of the Nagios series article, we’ve explained in detail how to install and configure the latest version of Nagios Core and Nagios Plugins in RHEL-based distributions such as CentOS Stream, Rocky Linux, AlmaLinux, and Fedora.

In this article, we will show you how to add a Remote Linux machine and its services to the Nagios Core Monitoring host using NRPE (Nagios Remote Plugin Executor) agent.

We hope you already have Nagios Core installed and running properly. If not, please use the following installation guide to install it on the system.

[ You might also like: How to Install Nagios Monitoring in RHEL, Rocky, and AlmaLinux ]

If you are planning to add a remote Windows host to the Nagios monitoring server, use the following guide:

[ You might also like: How to Add Windows Host to Nagios Monitoring Server ]

Once you’ve installed it, you can proceed further to install the NRPE agent on your Remote Linux host. Before heading further, let us give you a short description of NRPE.

Table of Contents

What is NRPE?

The NRPE (Nagios Remote Plugin Executor) plugin allows you to monitor any remote Linux/Unix services, network devices, or resources like CPU load, Swap, Memory usage, Online users, etc. on local/remote Linux machines.

After all, these local resources are not mostly exposed to external machines, an NRPE agent must be installed and configured on the remote machines.

(Video) Monitoring Remote Linux Server using Nagios | NRPE | Tech Arkit

Note: The NRPE addon requires that Nagios Plugins must be installed on the remote Linux machine. Without these, the NRPE daemon will not work and will not monitor anything.

Installation of NRPE Plugin in Nagios Server and Remote Linux Host

To use the NRPE, you will need to do some additional tasks on both the Nagios Monitoring Server and the Remote Linux Host that the NRPE is installed on. We will be covering both installation parts separately.

Installing Nagios Plugins and NRPE On Remote Linux Host

Please use the below instructions to install Nagios Plugins and NRPE daemon on the Remote Linux Host.

Step 1: Install Required Dependencies

We need to install required libraries like gcc, glibc, glibc-common, and GD and its development libraries using the yum package manager.

# yum install -y gcc glibc glibc-common gd gd-devel make net-snmp openssl-devel tar wget
Step 2: Create Nagios User

Create a new nagios user account and set a password.

# useradd nagios# passwd nagios
Step 3: Install the Nagios Plugins

Create a directory for nagios plugin installation and all its future downloads.

# mkdir /root/nagios# cd /root/nagios

Now download the latest Nagios Plugins package with the wget command.

# wget
Step 4: Extract Nagios Plugins

Run the following tar command to extract the source code tarball.

# tar -xvf nagios-plugins-2.3.3.tar.gz

After, extracting one new folder will appear in that directory.

# ls -ltotal 2724drwxr-xr-x. 15 root root 4096 Mar 11 2020 nagios-plugins-2.3.3-rw-r--r--. 1 root root 2782610 Mar 11 2020 nagios-plugins-2.3.3.tar.gz
Step 5: Compile and Install Nagios Plugins

Next, compile and install nagios plugins using the following commands

# cd nagios-plugins-2.3.3# ./configure # make# make install

Set the permissions on the plugin directory using the chown command.

# chown nagios.nagios /usr/local/nagios# chown -R nagios.nagios /usr/local/nagios/libexec
Step 6: Installing NRPE Plugin

To install the nrpe plugin, first, download the latest NRPE Plugin or use the following wget command.

(Video) Nagios Tutorial - Install NRPE and Add Linux Host to Monitoring | Tech Arkit

# cd /root/nagios# wget

Unpack the NRPE source code tarball.

# tar xzf nrpe-4.0.2.tar.gz# cd nrpe-4.0.2

Compile and install the NRPE addon.

# ./configure# make all

Note: If you get the following error while running the ‘make all‘ command:

In file included from ../include/common.h:34, from ./nrpe.c:38:/usr/include/openssl/err.h:413:15: note: declared here 413 | unsigned long ERR_get_error_line_data(const char **file, int *line, | ^~~~~~~~~~~~~~~~~~~~~~~/usr/bin/ld: /tmp/ccWQBjHb.o: in function `init_ssl':/root/nagios/nrpe-4.0.2/src/./nrpe.c:474: undefined reference to `get_dh2048'collect2: error: ld returned 1 exit statusmake[1]: *** [Makefile:48: nrpe] Error 1

Then, you need to disable SSL for nrpe configuration with ./configure --disable-ssl flag as shown.

# ./configure --disable-ssl# make all

Next, install the NRPE plugin daemon, and sample config files.

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

Install the NRPE daemon under systemd as a service.

# make install-init
Step 7: Configuring NRPE Plugin

Now open /usr/local/nagios/etc/nrpe.cfg file and add the local hostand IP address of the Nagios Monitoring Server.


Next, enable and restart the nrpe service.

# systemctl enable nrpe# systemctl restart nrpe
Step 8: Open NRPE Port in Firewall

Make sure that the Firewall on the local machine will allow the NRPE daemon to be accessed from remote servers. To do this, run the following iptables command.

# firewall-cmd --zone=public --add-port=5666/tcp# firewall-cmd --zone=public --add-port=5666/tcp --permanent
Step 8: Verify NRPE Daemon Locally

Run the following netstat command to verify the NRPE daemon working correctly under systemd.

# netstat -at | grep nrpeOR# netstat -na | grep "5666"tcp 0 0* LISTEN tcp6 0 0 [::]:nrpe [::]:* LISTEN 

If you get output similar to the above, means it working correctly. If not, make sure to check the following things.

  • Make sure to check that the nrpe entry is correctly added in the/etc/services file.
  • The allowed_hosts contains an entry for “nagios_ip_address” in the /usr/local/nagios/etc/nrpe.cfg file.
  • Check for the errors in the system log files for about nrpe and fix those problems.

Next, verify the NRPE daemon is functioning properly by running the “check_nrpe” command that was installed earlier for testing purposes.

(Video) How to use NRPE Plugin in Nagios Monitoring Server

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

You will get the following string on the screen, it shows you what version of NRPE is installed:

NRPE v4.0.2
Step 9: Customize NRPE Commands

The default NRPE configuration file that got installed has several command definitions that will be used to monitor this machine. The sample configuration file is located at.

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

The following are the default command definitions that are located at the bottom of the configuration file. For the time being, we assume you are using these commands. You can check them by using the following commands.

# /usr/local/nagios/libexec/check_nrpe -H -c check_usersUSERS OK - 1 users currently logged in |users=1;5;10;0
# /usr/local/nagios/libexec/check_nrpe -H -c check_loadOK - load average: 3.90, 4.37, 3.94|load1=3.900;15.000;30.000;0; load5=4.370;10.000;25.000;0; load15=3.940;5.000;20.000;0;
# /usr/local/nagios/libexec/check_nrpe -H -c check_hda1DISK OK - free space: /boot 154 MB (84% inode=99%);| /boot=29MB;154;173;0;193
# /usr/local/nagios/libexec/check_nrpe -H -c check_total_procsPROCS CRITICAL: 297 processes
# /usr/local/nagios/libexec/check_nrpe -H -c check_zombie_procsPROCS OK: 0 processes with STATE = Z

You can edit and add new command definitions by editing the NRPE config file. Finally, you’ve successfully installed and configured NRPE agent on the Remote Linux Host.

Now it’s time to install an NRPE component and add some services to your Nagios Monitoring Server

Installing NRPE On Nagios Monitoring Server

Now login into your Nagios Monitoring Server. Here you will need to do the following things:

  • Install the check_nrpe plugin.
  • Create a Nagios command definition using the check_nrpe plugin.
  • Create a Nagios host and add service definitions for monitoring the remote Linux host.
Step 1: Install NRPE Plugin in Nagios

Go to the nagios download directory and download the latest NRPE Plugin or use the following wget command.

# cd /root/nagios# wget

Unpack the NRPE source code tarball.

# tar xzf nrpe-4.0.2.tar.gz# cd nrpe-4.0.2

Compile and install the NRPE addon.

# ./configure# make all# make install-plugin# make install-daemon# make install-init
Step 2: Verify NRPE Daemon Remotely

Make sure that the check_nrpe plugin can communicate with the NRPE daemon on the remote Linux host. Add the IP address in the command below with the IP address of your Remote Linux host.

# /usr/local/nagios/libexec/check_nrpe -H <remote_linux_ip_address>

You will get a string back that shows you what version of NRPE is installed on the remote host, like this:

NRPE v4.0.2

If your receive a plugin time-out error, then check the following things.

(Video) How to Add Linux Host to Nagios Monitoring using NRPE plugin | Adding Centos 7 to Nagios Monitoring

  • Make sure your firewall isn’t blocking the communication between the remote host and the monitoring host.
  • Make sure that the NRPE daemon is installed correctly under systemd.
  • Make sure that the remote Linux host firewall rules block the monitoring server from communicating with the NRPE daemon.

Adding Remote Linux Host to Nagios Monitoring Server

To add a remote host you need to create two new files “hosts.cfg” and “services.cfg” under the “/usr/local/nagios/etc/” location.

Step 1: Creating Nagios Host and Services File
# cd /usr/local/nagios/etc/# touch hosts.cfg# touch services.cfg

Now add these two files to the main Nagios configuration file. Open the nagios.cfg file with any editor.

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

Now add the two newly created files as shown below.

# You can specify individual object config files as shown below:cfg_file=/usr/local/nagios/etc/hosts.cfgcfg_file=/usr/local/nagios/etc/services.cfg
Step 2: Configuring Nagios Host and Services File

Now open hosts.cfg file and add the default host template name and define remote hosts as shown below. Make sure to replace host_name, alias, and address with your remote host server details.

# vi /usr/local/nagios/etc/hosts.cfg
## Default Linux Host Template ##define host{name linux-box ; Name of this templateuse generic-host ; Inherit default valuescheck_period 24x7 check_interval 5 retry_interval 1 max_check_attempts 10 check_command check-host-alivenotification_period 24x7 notification_interval 30 notification_options d,r contact_groups admins register 0 ; DONT REGISTER THIS - ITS A TEMPLATE}## Defaultdefine host{use linux-box ; Inherit default values from a templatehost_name tecmint ; The name we're giving to this serveralias CentOS 6 ; A longer name for the serveraddress ; IP address of Remote Linux host}

Next open services.cfg file and add the following services to be monitored.

# vi /usr/local/nagios/etc/services.cfg
define service{ use generic-service host_name tecmint service_description CPU Load check_command check_nrpe!check_load }define service{ use generic-service host_name tecmint service_description Total Processes check_command check_nrpe!check_total_procs }define service{ use generic-service host_name tecmint service_description Current Users check_command check_nrpe!check_users }define service{ use generic-service host_name tecmint service_description SSH Monitoring check_command check_nrpe!check_ssh }define service{ use generic-service host_name tecmint service_description FTP Monitoring check_command check_nrpe!check_ftp }
Step 3: Configuring NRPE Command Definition

Now NRPE command definition needs to be created in commands.cfg file.

# vi /usr/local/nagios/etc/objects/commands.cfg

Add the following NRPE command definition at the bottom of the file.

################################################################################ NRPE CHECK COMMAND## Command to use NRPE to check remote host systems###############################################################################define command{ command_name check_nrpe command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ }

Finally, verify Nagios Configuration files for any errors.

# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfgTotal Warnings: 0Total Errors: 0

Finally, restart Nagios to apply recent configuration changes:

# systemctl restart nagios
Step 4: Monitoring Remote Linux in Nagios

Now go to the Nagios Monitoring Web interface at “http://Your-server-IP-address/nagios” or “http://FQDN/nagios” and Provide the username “nagiosadmin” and password. Check that the Remote Linux Host was added and is being monitored.


That’s it! for now, in my upcoming article, I will show you how to add a Windows host to Nagios monitoring Server. If you’re facing any difficulties while adding the remote host to Nagios.

Please do comment on your queries or problem via the comment section, till then stay tuned to for more such valuable articles.

(Video) Nagios-Agent using NRPE plugin with the Monitor Server side (Full configuration)


How to add Linux host to Nagios monitoring server using SNMP? ›

  1. STEP 01: Add Command Definitions. ...
  4. STEP 04: Add Host Definition File Path Into Nagios Main Configuration File. ...
  6. STEP 06: Restart Nagios Service.
Oct 25, 2019

What is Nagios plugins Nrpe? ›

The NRPE addon is designed to allow you to execute Nagios plugins on remote Linux/Unix machines. The main reason for doing this is to allow Nagios to monitor "local" resources (like CPU load, memory usage, etc.) on remote machines.

What is Nrpe Nagios Remote Plugin Executor in Nagios? ›

The Nagios daemon which run checks on remote machines in NRPE (Nagios Remote Plugin Executor). It allows you to run Nagios plugins on other machines remotely. You can monitor remote machine metrics such as disk usage, CPU load etc. It can also check metrics of remote windows machines through some windows agent addons.

How to add Linux host to Nagios Ubuntu server? ›

How to Add Ubuntu Host to Nagios?
  1. Step 1: Install NRPE on Ubuntu. Nagios only discovers and monitors the server on which it is installed by default ( localhost ). ...
  2. Step 2: Configure the NRPE agent. ...
  3. Step 3: Add host to Nagios server. ...
  4. Step 4: Configure the UFW firewall.
Aug 26, 2022

How to add Hosts to Nagios? ›

To manually add a new host, select the Hosts link located under Monitoring on the left menu of CCM. This will bring up the Host Management page, which displays a list of the current hosts being monitored by Nagios XI.

How to monitor Linux server with SNMP? ›

Monitor Linux Servers Using SNMP
  1. Install an SNMPd Agent on Ubuntu Server 17.
  2. SNMPd Configuration.
  3. Access Control.
  4. System Information.
  5. Install and Configure SNMP on CentOS.
  6. Test the SNMP Configuration.
  7. Linux SNMP OIDs for CPU, Memory, and Disk Statistics.
Jan 24, 2023

How do I enable SNMP on Linux? ›

Red Hat Enterprise Linux (RHEL)
  1. Installation. yum install net-snmp.
  2. Configuration. Edit the file: /etc/snmp/snmpd.conf. Add the following lines: rocommunity public. agentAddress udp:161,udp6:[::1]:161. Start the snmpd service: systemctl enable snmpd && systemctl start snmpd.
  3. Allow SNMP ports in Firewall.
Mar 17, 2021

Can Linux be monitored by Nagios? ›

Nagios provides complete monitoring of Linux operating systems and distributions – including operating system metrics, service state, process state, file system usage, and more. When you use Nagios to monitor your Linux environment, you're using one of the most powerful Linux monitoring tools on the planet.

How to install a plugin in Nagios? ›

Installing a new plugin in Nagios XI is very simple. Navigate to Admin > System Extensions > Manage Plugins. Click the Browse button to select the new plugin you want to install. Select the plugin file countdown_to_date.

How does Nrpe work? ›

NRPE allows you to remotely execute Nagios plugins on other Linux/Unix machines. This allows you to monitor remote machine metrics (disk usage, CPU load, etc.). NRPE can also communicate with some of the Windows agent addons, so you can execute scripts and check metrics on remote Windows machines as well.

How do Nagios plugins work? ›

Plugins are standalone extensions to Nagios Core that make it possible to monitor anything and everything with Core. Plugins process command-line arguments, perform a specific check, and then return the results to Nagios Core.

Where are the Check_nrpe plugin and NRPE daemon located? ›

We can install bunch of Nagios plugins including check_nrpe plugin using the following command. These plugins will be installed to /usr/lib/nagios/plugins. If you see NRPE version as the command output, that means you have successfully configured NREP daemon on the remote host.

How do I enable Nrpe? ›

  1. Add nrpe port to /etc/services – Add NRPE service to /etc/services and make sure port 5666 (default) is open on Firewall: # echo "nrpe 5666/tcp # NRPE" >> /etc/services.
  2. Make necessary changes to nrpe. conf – Edit nrpe. ...
  3. Start xinetd/nrpe and enable them at system boot:

What port does NRPE use? ›

By default, Nagios Remote Plugin Executor aka NRPE uses port 5666 for its checks.

What is NRPE and why is it used? ›

NRPE. Nagios Remote Plugin Executor (NRPE) is a Nagios agent that allows remote system monitoring using scripts that are hosted on the remote systems. It allows for monitoring of resources such as disk usage, system load or the number of users currently logged in.

How do I connect to Nagios? ›

The complete process to install Nagios can be summarized in four steps:
  1. Install Required Packages In The Monitoring Server.
  2. Install Nagios Core, Nagios Plugins And NRPE (Nagios Remote Plugin Executor)
  3. Set Nagios Password To Access The Web Interface.
  4. Install NRPE In Client.
Dec 15, 2021

How to configure Nagios in Linux? ›

2.1. Installing and configuring the Nagios Core server from source
  1. Install the prerequisites: ...
  2. Open port 80 for httpd : ...
  3. Create a user and group for Nagios Core: ...
  4. Run ./configure : ...
  5. Compile the Nagios Core source code: ...
  6. Install Nagios source code: ...
  7. Copy the event handlers and change their ownership: ...
  8. Run the pre-flight check:

How do I add a remote host? ›

  1. Create a remote server configuration.
  2. Specify the name, type, and visibility of a server configuration.
  3. Specify user credentials defined during registration on the host.
  4. Enable connection to the server and specify the server configuration root.
  5. Map local folders to folders on the server and the URL addresses to access them.
Dec 12, 2022

How do I add entries to my host? ›

How to add a static entry in the hosts file?
  1. Open your text editor in Administrator mode.
  2. In the text editor, open C:\Windows\System32\drivers\etc\hosts.
  3. Add the IP Address and hostname. Example:
  4. Save the changes.

How do I add Hosts to allow? ›

To allow client access, add the client host name or IP address in /etc/hosts. allow. To deny client access, add its name or IP address in /etc/hosts.

How do I add a host in Checkmk? ›

So let's switch back to the browser and add it to Checkmk. To add the host to the monitoring system, once again click on setup and then go to "Hosts", and then "Add host", you can either click the small button or the big blue button here.

How do I add a host to cockpit? ›

How to add a server to Cockpit
  1. Accessing the host add feature in Cockpit that's running on AlmaLinux.
  2. Configuring the necessary information for the new host to be added.
  3. Accepting the key for the remote server.
  4. You must type the user password to continue.
  5. Creating an SSH key for automatic Cockpit login.
Dec 15, 2021

How configure Nagios on Linux? ›

2.1. Installing and configuring the Nagios Core server from source
  1. Install the prerequisites: ...
  2. Open port 80 for httpd : ...
  3. Create a user and group for Nagios Core: ...
  4. Run ./configure : ...
  5. Compile the Nagios Core source code: ...
  6. Install Nagios source code: ...
  7. Copy the event handlers and change their ownership: ...
  8. Run the pre-flight check:

How can I tell if Nagios is running on Linux? ›

As opposed to just checking that a web server is running on the classroom PCs, you could also check that t he nagios3 service is available, by requesting the /nagios3/ path. This means passing extra options to the check_http plugin.

Which method would you prefer while monitoring a Linux machine in Nagios? ›

The NRPE addon is designed to allow you to execute Nagios plugins on remote Linux/Unix machines. The main reason for doing this is to allow Nagios to monitor “local” resources (like CPU load, memory usage, etc.) on remote machines.

What are Nagios commands? ›

Nagios - Commands

Commands include service checks, service notifications, service event handlers, host checks, host notifications, and host event handlers. Command definitions for Nagios are defined in commands. cfg file. Command name − This directive is used to identify the command.

How add to hosts file Linux? ›

Edit the Hosts File in Linux

Open the Terminal by pressing Ctrl+Alt+T. Add the targeted IP address followed by a space, then the domain name at the bottom of the hosts file, just like on the Windows 10 tutorial. Save your changes.

What port does Checkmk use? ›

Checkmk agents are available for a wide variety of operating systems — from the commonplace such as Windows and Linux to exotics such as OpenVMS. The agents are passive and listen on TCP port 6556.

How do I add a hostname? ›

Adding the IP-to-hostname mapping in /etc/hosts
  1. Open the /etc/hosts file. vi /etc/hosts.
  2. Add a line of text in the format ip-address localhost localhost. localdomain. As shown in Figure 1, enter 192.168. 1.158 imctest imctest. IMC to map 192.168. 1.158 to the host name imctest in the IMC domain. ...
  3. Save and close the file.

What is Cockpit for Linux? ›

Cockpit is a web-based graphical interface for servers, intended for everyone, especially those who are: new to Linux (including Windows admins) familiar with Linux and want an easy, graphical way to administer servers. expert admins who mainly use other tools but want an overview on individual systems.

How do I access my Cockpit remotely? ›

Once installed, open your web browser and navigate to https://localhost:9090 (or) https://IP-address:9090. You will be pleased with Cockpit's login screen. Use any one of your system user's credentials to login.

How do I connect to a host in terminal? ›

Open the terminal on the server machine. You can either search for “terminal” or press CTRL + ALT + T on your keyboard. Type in ssh localhost and hit enter.

What is the configuration file for Nagios? ›

The main configuration file is usually named nagios. cfg and located in the /usr/local/nagios/etc/ directory.

How to add services to Nagios server? ›

To manually add a new service, select the Services link located under Monitoring on the left menu of CCM. This will bring up the service Management page, which displays a list of the current services being monitored by Nagios XI. Click the Add New button to manually add a new service.


1. How to Add Linux Host into Nagios Server Monitoring | Tech Arkit
(Tech Arkit)
2. Nagios+NRPE : Monitor Linux Host With Nagios Using NRPE
(Digital Avenue)
3. Nagios-Agent configuration using NRPE plugin - Step two
(Cyber - Tech - Tips)
4. Nagios Remote Plugin Executor, NRPE, Deployment with Plugins
(Matha Goram)
5. How to connect NRPE Client to Nagios Master
(Easy DevOps)
6. Add Linux Host into Nagios Server Monitoring | NRPE Client Configuration
(IT Learning Center)
Top Articles
Latest Posts
Article information

Author: Manual Maggio

Last Updated: 03/31/2023

Views: 6564

Rating: 4.9 / 5 (49 voted)

Reviews: 80% of readers found this page helpful

Author information

Name: Manual Maggio

Birthday: 1998-01-20

Address: 359 Kelvin Stream, Lake Eldonview, MT 33517-1242

Phone: +577037762465

Job: Product Hospitality Supervisor

Hobby: Gardening, Web surfing, Video gaming, Amateur radio, Flag Football, Reading, Table tennis

Introduction: My name is Manual Maggio, I am a thankful, tender, adventurous, delightful, fantastic, proud, graceful person who loves writing and wants to share my knowledge and understanding with you.