How to build network monitoring and problem-solving tools.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
One of the greatest open-source monitoring tools is Nagios, which keeps an eye on services and programs running on Linux and Windows operating systems.
Nagios can keep an eye on system metrics including CPU load, memory consumption, disk utilization, logged-in users, active processes, and services like HTTP, FTP, SSH, and SMTP.
We’ll look at how to set up Nagios on Ubuntu 22.04 in this article.
We shall compile Nagios from source even though there is a package for it in the Ubuntu repository. Therefore, install the packages listed below to compile Nagios.
For Nagios, create a user and group. Then, to enable external commands to be executed via the Nagios web interface, add the nagios and apache user (www-data) to the section of the nagcmd group.
You can find Nagios’s configuration files under the /usr/local/nagios/etc directory, and the default configuration should work fine.
Next, install the Nagios web interface with the below command.
#sudo make install-webconf
You must establish a user account (nagiosadmin) in order to access the Nagios web interface, which is password secured by default. So, to establish a user account for the Nagios online interface, execute the command below.
#sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Enable the CGI module using the following command.
#tar -zxvf nagios-plugins-2.3.3.tar.gz
Then, compile and install the Nagios plugins.
Then, start and enable the Nagios service with the below command
Now navigate to the following URL in your web browser to view the Nagios web interface.
Enter the login (nagiosadmin) and password for the Nagios account you previously created at
You will see Nagios’ main page after successfully logging in.
To view the services that Nagios is watching, click Services in the left pane.
Now use the following command to install NRPE Add-on and Nagios plugins for adding Host.
#sudo apt update
#sudo apt install -y nagios-nrpe-server nagios-pluginss.
Set up NRPE Add-on
To accept the connection from the Nagios server, modify the NRPE configuration file, Change the file /etc/nagios/nrpe.cfg.
#sudo nano /etc/nagios/nrpe.cfg
Add the Nagios servers IP address, separated by comma like below.
#sudo nano /etc/nagios/nrpe.cfg
Set up the firewall so that the NRPE server operating on a distant Linux computer may be contacted by the Nagios server. Use a remote Linux computer to execute these instructions.
#firewall-cmd –permanent –add-port=5666/tcp
#iptables -I INPUT -p tcp –dport 5666 -m conntrack –ctstate NEW,ESTABLISHED -j ACCEPT
#iptables -I OUTPUT -p tcp –sport 5666 -m conntrack –ctstate ESTABLISHED -j ACCEPT
Install the NRPE plugin on the Nagios server.
To verify the services or resources, this NRPE plugin offers the check nrpe plugin, which makes communication with the NRPE server on distant computers.
Use the following command to install the NRPE plugin on your machine.
To add all.cfg files located in the /usr/local/nagios/etc/servers directory, edit the Nagios configuration file.
#sudo nano /usr/local/nagios/etc/nagios.cfg
Add or uncomment the following line.
Create a configuration directory.
Add the following text to the file mentioned above.
The template below can also be used, and it can be customized to meet your needs. For monitoring logged-in users, system load, disk utilization (/ – partition), swap, and overall process, use the template below.