How to install NRPE in CentOS 7

Share on Social Media

Learn how to install NRPE in CentOS 7 with this comprehensive step-by-step guide. Ensure smooth monitoring of your network services and hosts. #centlinux #linux #nagios

Problem Definition

We have already configured our Nagios Monitoring Server in our previous post Install & Configure Nagios Core 4.4 on CentOS 7. Now, its time to add some hosts to our Nagios Monitoring Server. For this purpose, we need to install a Monitoring Agent software on our Host. There are so many Monitoring Agents are available, that works well with not only Nagios, but other forks of Nagios (such as Icinga). But after having some research we have selected NRPE (Nagios Remote Process Executor) for the purpose.

what is NRPE?

NRPE (Nagios Remote Plugin Executor) is a Nagios plugin that allows you to execute plugins on remote hosts. It enables you to monitor local resources (like disk usage, CPU load, memory usage, etc.) on remote machines. The NRPE addon consists of two pieces:

  1. NRPE Daemon: Runs on the remote hosts and listens for requests.
  2. NRPE Plugin: Runs on the Nagios server and is used to execute commands on the remote hosts.

By using NRPE, you can monitor the performance and health of remote systems, ensuring that they meet the desired operational standards. This setup is particularly useful for managing and monitoring multiple servers in a network from a central Nagios server.

Before moving forward, it is required to have basic concepts of Nagios Core 4. Therefore, it is highly recommended that you should have Learning Nagios – Third Edition (PAID LINK). It will be really helpful for you during your Nagios journey.

Environment Specification

In this post, we will install NRPE Nagios Core Agent on CentOS 7 host to add it to Nagios Monitoring Server. Here, we use following two Linux servers for this installation guide.

1) Nagios Monitoring Server – A working Nagios Core Server.

  • Hostname – nagios01.example.com
  • IP Address – 192.168.229.129/24

2) Linux Host – A CentOS 7 machine, in which we are going to install NRPE.

  • Hostname – dbserver01.example.com
  • IP Address – 192.168.229.133/24

Read Also: How to install NSClient on Windows

Install NRPE in CentOS 7

Connect to the Linux host using ssh and install prerequisite packages.

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

Create user that own Nagios plugins and NRPE files & processes.

# useradd nagios
# passwd nagios

Create directories to download Nagios plugins & NRPE.

# mkdir -p /soft/nagios

Download Nagios Plugins 2.1.2 from https://www.nagios.org/downloads/nagios-plugins/

# cd /soft/nagios
# wget https://nagios-plugins.org/download/nagios-plugins-2.1.2.tar.gz

Extract and install Nagios plugins.

# tar -xvf nagios-plugins-2.1.2.tar.gz
# cd nagios-plugins-2.1.2
# ./configure
# make
# make install

Download NRPE Agent from Nagios Exchange.

# cd /soft/nagios
# wget https://github.com/NagiosEnterprises/nrpe/archive/3.0.1.tar.gz

Extract and install NRPE.

# tar -xvzf 3.0.1.tar.gz
# cd nrpe-3.0.1/
# ./configure
# make all
# make install-daemon

Open the server port, used by NRPE Daemon.

# firewall-cmd –-permanent –-add-port=5666/tcp
success
# firewall-cmd –reload
success

Configure NRPE.

# mkdir /usr/local/nagios/etc/
# cp sample-config/nrpe.cfg /usr/local/nagios/etc/nrpe.cfg
# vi /usr/local/nagios/etc/nrpe.cfg

Add the localhost (IPv4 & IPv6 both) & Nagios Monitoring Server IP addresses separated by Comma ‘,’.

allowed_hosts=127.0.0.1,::1,192.168.229.129

Start the NRPE Daemon.

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

At Nagios Monitoring Server add this Linux host and define some services.

# vi /usr/local/nagios/etc/objects/linux.cfg
## Default Linux Host Template ##
define host{
name                            linux-box               ; Name of this template
use                             generic-host            ; Inherit default values
check_period                    24x7        
check_interval                  5       
retry_interval                  1       
max_check_attempts              10      
check_command                   check-host-alive
notification_period             24x7    
notification_interval           30      
notification_options            d,r     
contact_groups                  admins  
register                        0                       ; DONT REGISTER THIS - ITS A TEMPLATE
}
## Default
define host{
use                             linux-box               ; Inherit default values from a template
host_name                       dbserver01  ; The name we're giving to this server
alias                           dbserver01              ; A longer name for the server
address                         192.168.229.133         ; IP address of Remote Linux host
}

define service{
use                     generic-service
host_name               dbserver01
service_description     CPU Load
check_command           check_nrpe!check_load
}
define service{
use                     generic-service
host_name               dbserver01
service_description     Total Processes
check_command           check_nrpe!check_total_procs
}
define service{
use                     generic-service
host_name               dbserver01
service_description     Current Users
check_command           check_nrpe!check_users
}
define service{
use                     generic-service
host_name               dbserver01
service_description     SSH Monitoring
check_command           check_nrpe!check_ssh
}
define service{
use                     generic-service
host_name               dbserver01
service_description     FTP Monitoring
check_command           check_nrpe!check_ftp
}

Now, add this config file to nagios.cfg.

# vi /usr/local/nagios/etc/nagios.cfg
cfg_file=/usr/local/nagios/etc/objects/linux.cfg

Define the check_nrpe command.

# vi /usr/local/nagios/etc/objects/commands.cfg
define command{
 command_name check_nrpe
 command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}

Restart Nagios service to reload changes

# systemctl restart nagios.service

Browse the Nagios Web UI, and check the services of dbserver01.

Nagios Server - Current Network Status
Nagios Server – Current Network Status

NRPE Nagios Core Agent has been successfully installed on our CentOS 7 host.

Recommended Online Training: Learn Bash Shell in Linux for Beginners

745772 0021

Final Thoughts

Installing NRPE on CentOS 7 can greatly enhance your ability to monitor network services and hosts efficiently. By following the steps outlined in this guide, you should be able to set up NRPE with ease and ensure your systems are running smoothly.

If you need further assistance or prefer to have a professional handle the installation, I’m here to help! Check out my Fiverr service: Linux Server Administrator for expert support in setting up NRPE and other server-related tasks.

6 thoughts on “How to install NRPE in CentOS 7”

Leave a Comment