This guide describes how to easily install Nagios NRPE agents on Debian 11/Debian 10. If you want to monitor your Debian hosts using Nagios server, then you need to have the NRPE agents installed on these hosts. Nagios Remote Plugin Executor (NRPE) allows you to remotely execute Nagios plugins on other Linux/Unix machines to query machine metrics such as disk usage, CPU load, etc.
Add Hosts to Nagios Server for Monitoring
Before you can now start to monitor hosts using Nagios server, you need to add them hosts to Nagios Server.
Follow the guide below to add hosts to Nagios server for monitoring.
Add Hosts to Nagios Server For Monitoring
Installing Nagios NRPE Agents on Debian
Nagios NRPE agents:
- can be installed from the default repos directly using the package manager
- can be build from the source
Install Nagios NRPE Agent From Default Debian Repos
NRPE agents are available on the default Debian repositories.
On Debian 11;
apt-cache policy nagios-nrpe-server
nagios-nrpe-server:
Installed: (none)
Candidate: 4.0.3-1
Version table:
4.0.3-1 500
500 http://deb.debian.org/debian bullseye/main amd64 Packages
NRPE 4.0.3, which is the current stable latest release as of this writing is available for installation.
apt install nagios-nrpe-serverOn Debian 10
On Debian 10, the default repos do not have the latest version of NRPE.
apt-cache policy nagios-nrpe-server
nagios-nrpe-server:
Installed: (none)
Candidate: 3.2.1-2
Version table:
3.2.1-2 500
500 http://deb.debian.org/debian buster/main amd64 Packages
To ensure you install the latest version of Debian 10, you can install Backport repos;
echo 'deb http://deb.debian.org/debian buster-backports main' > /etc/apt/sources.list.d/backports.listThen run command below installs NRPE agent on Debian 10.
apt updateNote that Backports repos are disabled by default and hence, you need to explicitly specify that you want to install from Backports.
apt install -t buster-backports nagios-nrpe-serverConfirm installed version once the installation completes.
nrpe -VNRPE - Nagios Remote Plugin Executor
Version: 4.0.3Running NRPE on Debian 11/Debian 10
Run the commands below to start and enable nrpe to run on system boot.
systemctl enable --now nagios-nrpe-serverTo check the status of NRPE agent;
systemctl status nagios-nrpe-server● nagios-nrpe-server.service - Nagios Remote Plugin Executor
Loaded: loaded (/lib/systemd/system/nagios-nrpe-server.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2021-11-18 13:48:57 EAT; 9min ago
Docs: http://www.nagios.org/documentation
Main PID: 775 (nrpe)
Tasks: 1 (limit: 4678)
Memory: 1012.0K
CPU: 7ms
CGroup: /system.slice/nagios-nrpe-server.service
└─775 /usr/sbin/nrpe -c /etc/nagios/nrpe.cfg -f
Nov 18 13:48:57 debian11 systemd[1]: Started Nagios Remote Plugin Executor.
Nov 18 13:48:57 debian11 nrpe[775]: Starting up daemon
Nov 18 13:48:57 debian11 nrpe[775]: Server listening on 0.0.0.0 port 5666.
Nov 18 13:48:57 debian11 nrpe[775]: Server listening on :: port 5666.
Nov 18 13:48:57 debian11 nrpe[775]: Listening for connections on port 5666
Nov 18 13:48:57 debian11 nrpe[775]: Allowing connections from: 127.0.0.1,::1
Open NRPE Port on Firewall
NRPE uses port TCP 5666 by default. If firewall is running, open this port to allow external checks from Nagios Monitoring server.
ufw allow from <NAGIOS_IP> to any port 5666 proto tcp comment "Allow Connection from Nagios Server for Metrics check"If you are using your IP tables;
apt install iptables-persistent -y
iptables -I INPUT -p tcp -s <NAGIOS_IP> --dport 5666 -j ACCEPT
iptables-save > /etc/iptables/rules.v4Install Nagios NRPE Agent from Source Code
You can as well build Nagios NRPE agent from the source code.
To install Nagios NRPE from source code:
Install Required Build Packages
apt updateapt install -y autoconf automake gcc libc6 libmcrypt-dev make libssl-dev wgetDownload NRPE Source Archive
Next, download the current release version of NRPE source code from the releases page.
wget https://github.com/NagiosEnterprises/nrpe/releases/download/nrpe-4.0.3/nrpe-4.0.3.tar.gzInstall Nagios NRPE Agent from Source Code
Extract the source archive
tar xzf nrpe-4.0.3.tar.gzCompile the agent;
cd nrpe-4.0.3/./configure --enable-command-argsSample summary;
...
*** Configuration summary for nrpe 4.0.3 2020-04-28 ***:
General Options:
-------------------------
NRPE port: 5666
NRPE user: nagios
NRPE group: nagios
Nagios user: nagios
Nagios group: nagios
Review the options above for accuracy. If they look okay,
type 'make all' to compile the NRPE daemon and client
or type 'make' to get a list of make options.
make allCreate NRPE nagios user and group;
make install-groups-usersInstall NRPE binary files;
make installInstall NRPE configuration files;
make install-configThe configs are placed under /usr/local/nagios/etc directory as nrpe.cfg.
Update services file to define NRPE service and respective port on which it listens on;
echo "nrpe 5666/tcp # Nagios NRPE" >> /etc/servicesInstall NRPE service;
make install-initThis creates a systemd unit file, /lib/systemd/system/nrpe.service.
Hence you can start and enable NRPE to run on boot;
systemctl enable --now nrpeYou can then enable the service to be accessible on firewall as shown above.
Install Nagios Plugins From Source
Download plugins from downloads page.
wget https://nagios-plugins.org/download/nagios-plugins-2.3.3.tar.gztar xzf nagios-plugins-2.3.3.tar.gzcd nagios-plugins-2.3.3
./configure
make
make installThe plugins are installed under /usr/local/nagios/libexec/ directory.
How to Configure NRPE Agent
When installed from the APT repos, the default Nagios NRPE configuration is /etc/nagios/nrpe.cfg.
When installed from the source, the default configuration file is /usr/local/nagios/etc/nrpe.cfg.
The configuration files are well commented. This is how the config looks like with no comments;
grep -vE "^.*#|^$" /usr/local/nagios/etc/nrpe.cfglog_facility=daemon
debug=0
pid_file=/usr/local/nagios/var/nrpe.pid
server_port=5666
nrpe_user=nagios
nrpe_group=nagios
allowed_hosts=127.0.0.1,::1
dont_blame_nrpe=0
allow_bash_command_substitution=0
command_timeout=60
connection_timeout=300
disable_syslog=0
command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10
command[check_load]=/usr/local/nagios/libexec/check_load -r -w .15,.10,.05 -c .30,.25,.20
command[check_hda1]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/hda1
command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 150 -c 200
In most cases, the configs above would suffice to monitor the host agent metrics.
However, there are a few parameters that you might want to update:
allowed_hosts=127.0.0.1,::1Update this parameter to include the IP address of the monitoring server. For example, in my setup, the IP address of the Nagios server is 192.168.58.22. Hence, this parameter is updated such that it looks like;
allowed_hosts=127.0.0.1,192.168.58.22The others include the commands to check various metrics. Below are my updated commands based on host agent.
command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10
command[check_load]=/usr/local/nagios/libexec/check_load -r -w 15,10,5 -c 30,25,20
command[check_disk]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/sda1
command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 150 -c 200
The NRPE installed from the APT, the plugins path is set to /usr/lib/nagios/plugins/. The commands above would look like;
command[check_users]=/usr/lib/nagios/plugins/check_users -w 5 -c 10
command[check_load]=/usr/lib/nagios/plugins/check_load -r -w 15,10,5 -c 30,25,20
command[check_disk]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /dev/sda1
command[check_zombie_procs]=/usr/lib/nagios/plugins/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/lib/nagios/plugins/check_procs -w 150 -c 200
In general, this is how my configuration is like;
log_facility=daemon
debug=0
pid_file=/run/nagios/nrpe.pid
server_port=5666
nrpe_user=nagios
nrpe_group=nagios
allowed_hosts=127.0.0.1,::1
dont_blame_nrpe=0
allow_bash_command_substitution=0
command_timeout=60
connection_timeout=300
disable_syslog=0
command[check_users]=/usr/lib/nagios/plugins/check_users -w 5 -c 10
command[check_load]=/usr/lib/nagios/plugins/check_load -r -w 15,10,5 -c 30,25,20
command[check_disk]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /dev/sda1
command[check_zombie_procs]=/usr/lib/nagios/plugins/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/lib/nagios/plugins/check_procs -w 150 -c 200
include=/etc/nagios/nrpe_local.cfg
include_dir=/etc/nagios/nrpe.d/
Restart NRPE when done configuring it;
systemctl restart nagios-nrpe-server.serviceIf installed from the source, then use nrpe.service.
systemctl restart nrpe.serviceCheck to see if port 5666/tcp is listening;
ss -altnp | grep 5666LISTEN 0 5 0.0.0.0:5666 0.0.0.0:* users:(("nrpe",pid=10345,fd=4))
LISTEN 0 5 [::]:5666 [::]:* users:(("nrpe",pid=10345,fd=5))If you already added hosts to Nagios and defined the services, then such is the example of how they should look on Nagios dashboard.
Hosts;

Services;

Further Reading
Other Tutorials
Install Nagios NRPE Agent on Rocky Linux 8
How to Install Nagios Plugins and NRPE agents on CentOS 7/RHEL 7/Fedora 29

