Installing Nagio NRPE on Ubuntu 18.04 through 22.04

A short tutorial on moving from Nagios NRPE using apt-get to source installation. We want to first remove all Nagios parts that were installed via apt:

sudo apt-get update
apt list --installed | grep nagios
nagios-nrpe-server/trusty,now 2.15-0ubuntu1 amd64 [installed]
nagios-plugins/trusty,now 1.5-3ubuntu1 all [installed]
nagios-plugins-basic/trusty,now 1.5-3ubuntu1 amd64 [installed,automatic]
nagios-plugins-common/trusty,now 1.5-3ubuntu1 amd64 [installed,automatic]
nagios-plugins-standard/trusty,now 1.5-3ubuntu1 amd64 [installed,automatic]
apt-get remove nagios-nrpe-server nagios-plugins nagios-plugins-basic nagios-plugins-common nagios-plugins-standard

Ensure we still have the nagios user:

sudo useradd nagios

Next, install the basics which will let us build NRPE:

sudo apt-get install build-essential openssl libssl-dev unzip make

Now we can download and install Nagios plugins:

cd /opt
curl -L -O http://nagios-plugins.org/download/nagios-plugins-2.3.3.tar.gz
tar zxf nagios-plugins-*.tar.gz
rm -f nagios-plugins-*.tar.gz 
cd nagios-plugins-*
./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-openssl
sudo make
sudo make install

Next install NRPE on 18.04 and 20.04:

cd /opt
curl -L -O https://github.com/NagiosEnterprises/nrpe/releases/download/nrpe-3.2.1/nrpe-3.2.1.tar.gz

... or install NRPE on 22.04:

cd /opt
https://github.com/NagiosEnterprises/nrpe/releases/download/nrpe-4.1.0/nrpe-4.1.0.tar.gz
tar zxf nrpe-*.tar.gz
rm -f nrpe-*.tar.gz
cd nrpe-*
./configure --enable-command-args --with-nagios-user=nagios --with-nagios-group=nagios --with-ssl=/usr/bin/openssl --with-ssl-lib=/usr/lib/x86_64-linux-gnu
make all
sudo make install
sudo make install-config
sudo make install-init

Next, we need  to update the config file to suite your needs:

vim /usr/local/nagios/etc/nrpe.cfg

Most important is this setting:

allowed_hosts=127.0.0.1,::1,<nagios_server_private_ip>

Finally, start nrpe and make sure everything started correctly:

systemctl start nrpe.service
systemctl status nrpe.service
…
● nrpe.service - Nagios Remote Plugin Executor
      Loaded: loaded (/lib/systemd/system/nrpe.service; disabled; vendor preset: enabled)
      Active: active (running) since Mon 2021-01-25 16:08:52 UTC; 8s ago

Now from the Nagios server, ensure you can see NRPE:

/usr/local/nagios/libexec/check_nrpe -H remote_host_ip
NRPE v3.2.1

Read more…

Comments