Skip to main content

Linux NRPE3

IMPORTANT: This monitoring connector is deprecated. For a more standard deployment, monitor your Linux servers using Linux NRPE4.

Overview​

NRPE (Nagios Remote Plugin Executor) is a protocol that was designed to remotely run monitoring commands.

This Monitoring Connector relies on 3 components that are listed below:

ComponentTypeLocationRole
centreon_nrpe3_pluginBinary executablePollerSends a command name and arguments associated to it
centreon_linux_local.plPerl ScriptMonitored hostIs run locally and returns a status, an output message and metrics
centreon-nrpe3Service/daemonMonitored hostListens on port 5666 and runs the configured commands on demand

Monitoring Connector assets​

Monitored objects​

  • CentOS 7 / RHEL7 Linux servers (to which this procedure applies)
  • Other GNU/Linux distributions, provided that the plugin and the daemon are installed and configured manually)

Collected metrics​

Only standard metrics are described in this section. Be aware that a lot of other checks and metrics are available from the centreon_linux_local.pl Plugin. Here is a non-exhaustive list:

Service AliasService TemplateService Description
Check-PluginOS-Linux-Check-Plugin-NRPE3-customSSH execution commands in a remote host
Cmd-GenericOS-Linux-Cmd-Generic-NRPE3-customCheck command returns
Connections-GenericOS-Linux-Connections-Generic-NRPE3-customCheck tcp/udp connections
Cpu-DetailedOS-Linux-Cpu-Detailed-NRPE3-customCheck average usage for each CPUs
DiskOS-Linux-Disks-NRPE3-customCheck storage usage
Disk-IOOS-Linux-Disk-IO-NRPE3-customCheck some disk io counters
File-Date-GenericOS-Linux-File-Date-Generic-NRPE3-customCheck time of files/directories
File-Size-GenericOS-Linux-File-Size-Generic-NRPE3-customCheck size of files/directories
InodesOS-Linux-Inodes-NRPE3-customCheck Inodes space usage
Is-File-GenericOS-Linux-Is-File-Generic-NRPE3-customCheck the presence of a file
Is-Not-File-GenericOS-Linux-Is-Not-File-Generic-NRPE3-customCheck the absence of a file
LoadOS-Linux-Load-NRPE3-customCheck system load-average
NtpOS-Linux-Ntp-NRPE3-customCheck ntp daemons
OpenFileOS-Linux-OpenFile-NRPE3-customCheck open files
Packet-ErrorsOS-Linux-Packet-Errors-NRPE3-customCheck packet errors and discards on interfaces
Pending-UpdatesOS-Linux-Pending-Updates-NRPE3-customCheck pending updates
Process-GenericOS-Linux-Process-Generic-NRPE3-customCheck linux processes
Systemd-JournalOS-Linux-Systemd-Journal-NRPE3-customCount journal entries
Systemd-Sc-StatusOS-Linux-Systemd-Sc-Status-NRPE3-customCheck services managed by systemd
TrafficOS-Linux-Traffic-NRPE3-customCheck Traffic

The services listed above are created automatically when the OS-Linux-NRPE3-custom host template is used.

Here are the metrics that are collected by default:

MetricDescriptionUOM
0#core.cpu.utilization.percentageAverage core 0 CPU usage%
1#core.cpu.utilization.percentageAverage core 1 CPU usage%
......%
cpu.utilization.percentageAverage overall CPU usage%

Prerequisites​

This chapter describes the installation prerequisites required by the plugin to run.

Network flows​

The default TCP port for NRPE is 5666.

SourceDestinationProtocolPort
PollerMonitored hostTCP5666

Installation of Centreon-packaged NRPE3 daemon and Linux local plugin​

The monitored hosts will need two components to be monitored:

  • the centreon_linux_local.pl plugin
  • the NRPE3 daemon

To install them, run the commands below:

dnf install -y dnf-plugins-core
dnf config-manager --add-repo https://packages.centreon.com/rpm-standard/22.10/el8/centreon-22.10.repo
dnf install centreon-nrpe3-daemon.x86_64 centreon-plugin-Operatingsystems-Linux-Local.noarch

NB: To avoid installing the Centreon Yum repo on all your monitored Linux servers, both https://yum.centreon.com/standard/22.10/el8/stable/noarch/RPMS/centreon-plugin-Operatingsystems-Linux-Local-20230117-074217.el8.noarch.rpm and https://yum.centreon.com/standard/22.10/el8/stable/x86_64/RPMS/centreon-nrpe3-plugin-4.0.3-0.el8.x86_64.rpm (current version at the time this document is written) can be installed directly but this installation mode won't allow the packages to be updated with yum update command, so it is not recommended.

NRPE daemon configuration​

The value of the allowed_hosts parameter in /etc/nrpe/centreon-nrpe3.cfg must be changed to include the pollers IP addresses:

[...]
# ALLOWED HOST ADDRESSES
# This is an optional comma-delimited list of IP address or hostnames
# that are allowed to talk to the NRPE daemon. Network addresses with a bit mask
# (i.e. 192.168.1.0/24) are also supported. Hostname wildcards are not currently
# supported.
allowed_hosts=127.0.0.1,::1
[...]

And the service must be restarted:

systemctl restart centreon-nrpe3.service

Installation​

Monitoring Connector​

The Monitoring Connector installation concerns only the central server and the procedure depends on the type of license.

Install the "Linux NRPE3" Monitoring Connector from Configuration > Monitoring Connector Managerin the WUI.

Centreon NRPE3 Plugin​

Install this plugin on each poller:

yum install centreon-nrpe3-plugin

Prerequisites and installation validation​

If everything is fine, this command:

/usr/lib64/nagios/plugins/check_centreon_nrpe3 -H monitored_host_ip -p 5666

should produce this output:

NRPE v4.0.3

Otherwise please refer to the troubleshooting section.

Centreon Configuration​

Create a host using the appropriate template​

Go to Configuration > Hosts and click Add. Then, fill the form as shown by the following table:

Once the template has been applied, the following macros can be customized:

MandatoryNameDescription
XNRPECLIENTName of the plugin to use to dialog with the NRPE3 daemon (default: check_centreon_nrpe3)
XNRPEPORTTCP port the NRPE3 daemon is listening to (default: 5666)
XNRPETIMEOUTCommand timeout (default: 5s)
NRPEEXTRAOPTIONSAny extra option (default: -u to return an UNKNOWN state in case of a connection issue)

FAQ​

How does it work?​

Here is a command monitors the Cpu usage of the Linux Server having the IP address x.x.x.x:

/usr/lib64/nagios/plugins/check_centreon_nrpe3 \
-H x.x.x.x \
-p 5666 -t 5 -u \
-c check_centreon_plugins \
-a 'os::linux::local::plugin' 'cpu' ' --statefile-dir=/var/log/nrpe/centplugins'

It should return this:

OK: CPU(s) average usage is: 1.16% | 'cpu0'=1.64%;;;0;100 'cpu1'=0.98%;;;0;100 'cpu2'=1.09%;;;0;100 'cpu3'=0.94%;;;0;100 'total_cpu_avg'=1.16%;;;0;100

What happened:

  • The check_centreon_nrpe3 executable asked the daemon to run the "check_centreon_plugins" command with "os::linux::local::plugin" "cpu" and " --statefile-dir=/var/log/nrpe/centplugins" as arguments
  • The NRPE daemon puts together the command (that is defined in the NRPE configuration file) with its arguments, forming this local command line:
/usr/lib/centreon/plugins/centreon_linux_local.pl --plugin=os::linux::local::plugin --mode=cpu --statefile-dir=/var/log/nrpe/centplugins
  • The NRPE daemon runs this command and sends its results (return code and standard output) back to the check_centreon_nrpe3 executable, that was waiting for the answer.

Troubleshooting​

Let's detail the most common errors.

connect to address x.x.x.x port 5666: Connection refused​

If the output of the command is:

connect to address x.x.x.x port 5666: Connection refused

It probably means that the IP address from which the request was sent is not allowed to dialog with the NRPE daemon.

The allowed_hosts parameter, in the /etc/nrpe/centreon-nrpe3.cfg configuration file (see above).

Then restart the service.

systemctl restart centreon-nrpe3.service

CHECK_NRPE STATE CRITICAL: Socket timeout after 10 seconds​

If the output of the command is:

CHECK_NRPE STATE CRITICAL: Socket timeout after 10 seconds.

Then the following points must be checked:

  • the centreon-nrpe3 is effectively started
systemctl status centreon-nrpe3.service
  • the TCP port that is used by the plugin (-p 5666 for example) is the same as the one configured for the daemon
  • there is no local firewall blocking the NRPE port (iptables -L)
  • there is no firewall device filtering this port on the network

NRPE: Command 'my_command' not defined​

If the output of the command is:

NRPE: Command 'my_command' not defined

This means that the daemon is asked to run a command it doesn't know about.

For a command to be recognized, it has to be defined using the right syntax:

[my_command]=/full/path/to/command --argument --other-argument

And restart the daemon:

systemctl restart centreon-nrpe3.service