Would you like to learn how to do a Nagios NRPE agent installation on Ubuntu Linux? In this tutorial, we are going to show you how to install and configure a Nagios server to monitor a Linux computer using the NRPE agent.

Hardware List:

The following section presents the list of equipment used to create this Zabbix tutorial.

Every piece of hardware listed above can be found at Amazon website.

Nagios Playlist:

On this page, we offer quick access to a list of videos related to Nagios.

Don't forget to subscribe to our youtube channel named FKIT.

Nagios Related Tutorial:

On this page, we offer quick access to a list of tutorials related to Nagios installation.

Tutorial - NTP on Ubuntu Linux

All the steps in this section should be executed on the Linux Client computer.

First, we are going to configure the system to use the correct date and time using NTP.

On the Linux console, use the following commands to set the correct timezone.

# dpkg-reconfigure tzdata

Install the Ntpdate package and set the correct date and time immediately.

# apt-get update
# apt-get install ntpdate
# ntpdate pool.ntp.br

The Ntpdate command was used to set the correct date and time using the server: pool.ntp.br

Let's install the NTP service.

# apt-get install ntp

NTP is the service that will keep our server updated.

Use the command date to check the date and time configured on your Ubuntu Linux.

# date

If the system shown the correct date and time, this means that you followed all the steps correctly.

Tutorial - Installing NRPE on Linux

All these steps in this section should be executed on the Linux Client computer.

Next, we need to install NRPE agent on the computer that will be monitored.

On the Linux console, use the following commands to install the required packages.

# apt-get update
# apt-get install autoconf build-essential libc6 libmcrypt-dev make libssl-dev wget

Use the following commands to download the Nagios NRPE packages.

# mkdir /downloads
# cd /downloads
# wget https://github.com/NagiosEnterprises/nrpe/releases/download/nrpe-3.2.1/nrpe-3.2.1.tar.gz

Extract, compile and install the Nagios NRPE package.

# tar -zxvf nrpe-3.2.1.tar.gz
# cd nrpe-3.2.1/
# ./configure --enable-command-args --with-ssl-lib=/usr/lib/x86_64-linux-gnu/
# make all
# make install-groups-users
# make install
# make install-config
# make install-init

Now, you should find the location of the nrpe.cfg file on your system.

You need to edit the nrpe.cfg file.

# updatedb
# locate nrpe.cfg
# vi /usr/local/nagios/etc/nrpe.cfg

Here is the original file, before our configuration.

log_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
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

Here is the new file with our configuration.

Add the IP address of the Nagios server to the allowed_hosts line.

log_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,200.200.200.200
dont_blame_nrpe=0
allow_bash_command_substitution=0
command_timeout=60
connection_timeout=300
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 our example, the NRPE agent is configured to allow the connection of the Nagios server 200.200.200.200.

The server with the IP address 200.200.200.200 is allowed to request and receive information from the agent.

The Localhost, 127.0.0.1, is allowed to request and receive information from the agent.

After finishing the configuration, use the following command to start the NRPE agent:

# service nrpe start

Use the following command to test your Nagios NRPE agent installation.

The NRPE agent should answer this request and display the NRPE version installed on the local computer.

# /usr/local/nagios/libexec/check_nrpe -H 127.0.0.1

NRPE v3.2.1

Use the following command to enable the NRPE service to start automatically at boot time.

# systemctl enable nrpe.service

Congratulations! You have installed the Nagios NRPE agent on Ubuntu Linux.

Tutorial - NRPE Plugin Installation on Nagios Server

Now, we need to install the Nagios NRPE plugin the Nagios Server.

All the steps in this section should be executed on the Nagios server computer.

Use the following commands to download the Nagios NRPE packages.

# mkdir /downloads
# cd /downloads
# wget https://github.com/NagiosEnterprises/nrpe/releases/download/nrpe-3.2.1/nrpe-3.2.1.tar.gz

Extract, compile and install the Nagios NRPE plugin.

# tar -zxvf nrpe-3.2.1.tar.gz
# cd nrpe-3.2.1/
# ./configure
# make all
# make make install-daemon

# make check_nrpe
# make install-plugin

Use the following command to test the communication between the Nagios server and the Nagios Client.

The NRPE agent should answer this request and display the NRPE version installed on the remote computer.

# /usr/local/nagios/libexec/check_nrpe -H 220.220.220.220 -c check_users

NRPE v3.2.1