Installing Nagio NRPE on Ubuntu 18.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
tar zxf 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:

cd /opt
curl -L -O
tar zxf 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:


Finally, start nrpe and make sure everything started correctly:

systemctl start nrpe.service // or service nrpe start
tail -f /var/log/syslog
Mar 12 10:26:57 collada nrpe[23263]: Starting up daemon
Mar 12 10:26:57 collada nrpe[23263]: Server listening on port 5666.
Mar 12 10:26:57 collada nrpe[23263]: Server listening on :: port 5666.
Mar 12 10:26:57 collada nrpe[23263]: Warning: Daemon is configured to accept command arguments from clients!
Mar 12 10:26:57 collada nrpe[23263]: Listening for connections on port 5666
Mar 12 10:26:57 collada nrpe[23263]: Allowing connections from:,::1,<nagios_server_private_ip>

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

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