How to install Nagios agent on Ubuntu 18.04?

Windows Articles

Debian 10.6 available

Several volunteers have developed the free software distributed under the name of Debian. Debian does not sell its software directly, the developers...

How to check domain controller status in Windows Server 2019/2016.

Hello! The administration of Windows Server is very important. Indeed, the administrator manages many processes and roles that affect the optimal functioning...

How to install Vanilla Forum on Ubuntu 20.04?

Hello, folks. This post is about how to install Vanilla Forum on Ubuntu 20.04. Vanilla is an opensource discussion...

How to backup and restore Group Policy Objects in Windows Server 2016/2019.

Hi! Previously we have mentioned that Windows Server pursues a centralized administration of each role and service. In this way, a fluid...

How to use the ls command?

The ls commands list the content and optional information of the directories and files. When you execute the Ls command without options,...
angeloma
angeloma
Senior Writer and partner

We continue with some articles on Nagios. Well, once we have installed the server and the plugins come to another step. In this post, I’ll show you how to install Nagios agent on Ubuntu 18.04 / Linux Mint 19.

So, we have already talked a lot about Nagios and its potential. But for everything to be complete, we need to install the agent in a client operating system so that the server can monitor it.

So that’s what we’re going to do.

Install Nagios agent on Ubuntu 18.04

1.- Working on the client machine

The Nagios agent is NRPE (Nagios Remote Plugin Executor) which according to the Nagios wiki is the following

“it is a Nagios agent that allows remote system monitoring using scripts that are hosted on the remote systems.It allows for monitoring of resources such as disk usage, system load or the number of users currently logged in.”

The big advantage is that this agent is available in the official Ubuntu repositories and you don’t have to do much to install it.

So, open a terminal in the client operating system. Not on the server. And run the following:

:~$ sudo apt-get install nagios-nrpe-server nagios-plugins
1.- Install Nagios agent on Ubuntu 18.04 / Linux Mint 19
1.- Install Nagios agent on Ubuntu 18.04 / Linux Mint 19

When the installation is finished, a configuration file must be modified to tell the client where the Nagios server is.

:~$ sudo nano /etc/nagios/nrpe.cfg

In the allowed_hosts directive add the IP address of the computer where Nagios is installed. However, you can specify multiple IP addresses if there are multiple Nagios servers.

allowed_hosts=127.0.0.1, 192.168.250.32

In my case, this is the file.

2.- Configuring the plugin
2.- Configuring the plugin

Then save the changes and close the file.

For all these changes to take effect, the Nagios client service has to be restarted.

:~$ sudo systemctl restart nagios-nrpe-server

Finally, we check if the agent is working with the following command:

:~$ /usr/lib/nagios/plugins/check_load -w 15,10,5 -c 30,25,20

If you get a screen output like this:

OK - load average: 0.74, 0.62, 0.68|load1=0.740;15.000;30.000;0; load5=0.620;10.000;25.000;0; load15=0.680;5.000;20.000;0;

It means that everything is fine.

2.- Working on the server

It is now necessary to install NRPE on the server. This is so that you can establish communication with the client.

So, on the server open a terminal and run the following:

:~$ sudo apt install nagios-nrpe-plugin
3.- Installing the Nagios agent on the server
3.- Installing the Nagios agent on the server

Now that it is installed, some configuration files need to be modified. The first one is the Nagios configuration file where we have to enable the server folder.

:~$ sudo nano /usr/local/nagios/etc/nagios.cfg

You do it by decomposing the next line:

cfg_dir=/usr/local/nagios/etc/servers
4.- Configuring the Nagios agent on the server
4.- Configuring the Nagios agent on the server

Again, save the changes and close the file. Then create the folder in question.

:~$ sudo mkdir /usr/local/nagios/etc/servers

After that, another file has to be modified to add a command that the Nagios server has to run to communicate with the client.

:~$ sudo nano /usr/local/nagios/etc/objects/commands.cfg

At the end of the file, add the following:

define command {
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
5.- Adding a command to monitoring the client
5.- Adding a command to monitoring the client

Again, save the changes and close the file.

Now we have to create a new configuration file for the client that we are going to add.

:~$ sudo nano /usr/local/nagios/etc/servers/client.cfg

And add the following:

define host{
use linux-server
host_name laptop.osradar
alias Ubuntu 18
address 192.168.250.6
}

define service{
use generic-service
host_name laptop.osradar
service_description CPU Load
check_command check_nrpe!check_load
}

define service{
use generic-service
host_name laptop.osradar
service_description Total Processes
check_command check_nrpe!check_total_procs
}

define service{
use generic-service
host_name laptop.osradar
service_description Current Users
check_command check_nrpe!check_users
}

define service{
use generic-service
host_name laptop.osradar
service_description SSH Monitoring
check_command check_nrpe!check_ssh
}
define service{
use generic-service
host_name laptop.osradar
service_description FTP Monitoring
check_command check_nrpe!check_ftp
}

Nagios is very flexible because in this file you can add or remove the services you want.

Also, you have to modify some parameters like the hostname of the client machine and the IP address. This is enough.

6.- Creating a new file for the host
6.- Creating a new file for the host

Then, it is convenient to check if the configuration file has a syntax error. To do this, run the following command:

:~$ sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
7.- Cheecking the nagios configuration file
7.- Cheecking the nagios configuration file

Then test to see if the server can communicate with the client:

:~$ cd /usr/lib/nagios/plugins/
:~$ ./check_nrpe -H 192.168.250.6
8.- Checking the plugin
8.- Checking the plugin

Replace the IP address with the address of the computer that will be the client.

To avoid running problems with the plugin, copy it to the location where the rest of them are.

:~$ sudo cp check_nrpe /usr/local/nagios/libexec

And finally, restart the service.

:~$ sudo systemctl restart nagios

And that is it.

3.- Testing the Nagios client on Ubuntu 18.04

Now open your web browser and access Nagios. You will see the following:

9.- Nagios agent working
9.- Nagios agent working

And check the host information:

10.- Nagios server and agent working
10.- Nagios server and agent working

So everything’s fine.

Conclusion

To monitor with Nagios it is necessary to install the agent in each of the computers you want. In this post, you have learned how to install it in Ubuntu 18.04 / Linux Mint 19.3.

Please share this post and join our Telegram channel.

More articles

1 COMMENT

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest article

Debian 10.6 available

Several volunteers have developed the free software distributed under the name of Debian. Debian does not sell its software directly, the developers...

How to check domain controller status in Windows Server 2019/2016.

Hello! The administration of Windows Server is very important. Indeed, the administrator manages many processes and roles that affect the optimal functioning...

How to install Vanilla Forum on Ubuntu 20.04?

Hello, folks. This post is about how to install Vanilla Forum on Ubuntu 20.04. Vanilla is an opensource discussion...

How to backup and restore Group Policy Objects in Windows Server 2016/2019.

Hi! Previously we have mentioned that Windows Server pursues a centralized administration of each role and service. In this way, a fluid...

How to use the ls command?

The ls commands list the content and optional information of the directories and files. When you execute the Ls command without options,...
x