Essential networking devices, network services, and applications need constant monitoring to lessen the troubleshooting complexities that many server administrators have to endure or overcome.
One reputable tool for managing such networking footprints is Nagios. Its active monitoring functionality can detect network devices, services, and application faults on a server it is tasked to monitor. Once such faults are detected, the administrative user is notified of the underlying suspicious activity on the network.
The machine that hosts Nagios should embrace a Server/Agent architecture for it to comfortably communicate with remote hosts that need constant monitoring.
This Nagios network monitoring tool makes use of agents like Nagios Remote Plugin Executor for swift communication with remote hosts. Moreover, Nagios generates final reports from visually represented user interface logs.
Before this article walks us through the installation and configuration of Nagios on Ubuntu 22.04 and Ubuntu 20.04, we must obey the following prerequisites:
- You are under an Ubuntu 22.04/20.04 server environment that is fully up-to-date.
- You have Sudoer user privileges on the Ubuntu server environment.
Installing Nagios Core in Ubuntu Server
First, update your Ubuntu system and then retrieve several packages that are valid Nagios dependencies.
$ sudo apt update $ sudo apt install wget unzip curl openssl build-essential libgd-dev libssl-dev libapache2-mod-php php-gd php apache2 -y
Since we have also installed the Apache web server as one of the needed dependencies, make sure it is running.
$ sudo systemctl status apache2
To install the latest Nagios Core release, first, download the Nagios Core release or use the following download command.
$ wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.6.tar.gz
We now need to extract the Nagios Core compressed file.
$ sudo tar -zxvf nagios-4.4.6.tar.gz
We can now navigate to the main Nagios directory and configure the script associated with Nagios Core.
$ cd nagios-4.4.6 $ sudo ./configure
As suggested on the above screen capture, we will proceed and compile the main program.
$ sudo make all
Configure Nagios group and user and link Nagios group with the www-data directory.
$ sudo make install-groups-users $ sudo usermod -a -G nagios www-data
Now proceed to install Nagios.
$ sudo make install
The installation configuration scripts need initialization, execute the following command:
$ sudo make install-init
The configs directory needs certain permissions installed and configured.
$ sudo make install-commandmode
We will need Nagios sample config files for reference.
$ sudo make install-config
Install Apache (webserver) files and enable rewrite and CGI modules.
$ sudo make install-webconf $ sudo a2enmod rewrite $ sudo a2enmod cgi
Finally, restart the Apache webserver.
$ sudo systemctl restart apache2
Next, create a Nagios admin user with your preferred password.
$ sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users admin
Installing Nagios Plugins in Ubuntu
To install the latest Nagios Plugins release, first, download the Nagios Plugins release or use the following download command.
$ wget https://nagios-plugins.org/download/nagios-plugins-2.3.3.tar.gz
Extract the downloaded Nagios Plugins files and configure them:
$ sudo tar -zxvf nagios-plugins-2.3.3.tar.gz $ cd nagios-plugins-2.3.3/ $ sudo ./configure --with-nagios-user=nagios --with-nagios-group=nagios
Compile the Nagios plugins:
$ sudo make
Install the Nagios plugins:
$ sudo make install
Verifying Nagios Configuration in Ubuntu
Nagios Core configuration can be verified with the following command:
$ sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
To start the Nagios service, run the command:
$ sudo systemctl start nagios
You might also need to enable Nagios for it to keep on running even after a system reboot.
$ sudo systemctl enable nagios
Finally, access Nagios from your web server at the following URL.
I will use the admin user I created with its associated password to gain entry to Nagios’ dashboard.
In the next article piece, we will handle how to add remote Linux hosts to the Nagios server so that you can view/monitor their devices, applications, and services performances.