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. Since these public resources are not usually exposed to external machines, an agent like
NRPE must be installed on the remote Linux/Unix machines.

NRPE Installation
On the remote server, download the latest source tarball of the NRPE add-on (2.12 at time of writing):

mkdir -p /extra/src
cd /extra/src
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.12.tar.gz
tar zxvf nrpe-2.12.tar.gz
cd nrpe-2.12

NRPE will need a user to run as. In this example for Redhat, we'll add a "nagios" user that isn't allowed to actually log in.

useradd -s /bin/false nagios

In order to run NRPE under daemontools, we need to patch it to run in the foreground. The following patch is a modification of one posted on the nagios-devel mailing list, modified for the current version of NRPE:

wget http://productionmonkeys.net/sites/productionmonkeys.net/files/nrpe_foreground.patch
patch -p0 < nrpe_foreground.patch

Configure, compile, and install NRPE:

./configure
make all
make install

Adjust the permission on the Nagios directories:

chown nagios:nagios /usr/local/nagios
chown -R nagios:nagios /usr/local/nagios/libexec

Copy the sample config file:

mkdir /usr/local/nagios/etc
chown nagios:nagios /usr/local/nagios/etc
cp sample-config/nrpe.cfg /usr/local/nagios/etc/nrpe.cfg

Check Plugins
NRPE does not come with any check plugins - you'll need to install them with the same procedure as for a full Nagios server install.

Configuration
The configuration file, /usr/local/nagios/etc/nrpe.cfg will need to be modified in order to work.
FIrstly, the allowed_hosts must be modified to include the IP address of your Nagios server.

allowed_hosts=127.0.0.1,<nagios server ip address>

Then, you'll need to configure which checks you want to be made on the server. The sample config has checks for users, disk space, CPU load, etc. already enabled. You can modify those to suit your needs, or add your own plugins.

Automatic Startup
We're going to use daemontools. If you haven't already, install daemontools.

Create a directory for the NRPE service:

mkdir -m 1755 /var/service/nrpe
cd /var/service/nrpe

Create the run script and make it executable:

echo '#!/bin/sh' > run
echo 'exec 2>&1' >> run
echo 'exec /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d -f' >> run
chmod 755 run

Our log script comes from John Simpson's:

mkdir -m 755 log
cd log
wget http://qmail.jms1.net/scripts/service-any-log-run
mv service-any-log-run run
chmod 755 run

Finally, add the service to daemontools by creating the symbolic link in /service

ln -s /var/service/nrpe /service/nrpe

Confirm that the service is running:

svstat /service/nrpe /service/nrpe/log

Nagios Server Configuration
Your Nagios server needs the NRPE plug-in installed in order to query the remote server. Download the source tarball as per above, then:

./configure
make all
make install-plugin

The command definitions on your Nagios server needs to include NRPE.:

define command{
        command_name    check_nrpe
        command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
        }
AttachmentSize
File nrpe_foreground.patch1.31 KB

Recent Updates

  • 7 months 4 weeks ago
    1.27.2 update
  • 8 months 1 week ago
    Drupal 10/11 config
  • 8 months 1 week ago
  • PHP
    8 months 1 week ago
    PHP 8.3.11 and AlmaLinux
  • 8 months 1 week ago
    New version of Pound