Nagios is a popular open-source system that provides network monitoring capabilities. It monitors different networking apps, their sources, and various Linux based devices. It monitors routers, servers, applications, services, and ensures that they are up and running. In case of any faults, Nagios sends notification alerts using various methods to prevent further damages. It can also deliver the results in visual representations format and reports.
Nagios works on server/agent architecture. Server hosting Nagios (core) uses plugins to interact with remote hosts and remote hosts have agent such as NRPE installed.
In this guide, we touch base on how you can install Nagios on Ubuntu 20.04.
Step 1: Update the system
As always recommended, ensure that all the package lists are updated as follows:
$ sudo apt update
Next, upgrade the system packages to their latest versions:
$ sudo apt upgrade
Step 2: Install prerequisite packages
After updating your system, proceed and install the following prerequisites packages that are required in the installation of Nagios Core.
$ sudo apt install wget unzip vim curl gcc openssl build-essential libgd-dev libssl-dev libapache2-mod-php php-gd php apache2
Step 3: Download Nagios Core on Ubuntu 20.04
Next, we are going to download Nagios core. Feel free to check the releases page for the latest version. As per the time of writing the guide, the latest version of Nagios is v4.4.6
To download and extract Nagios Core invoke the command:
$ export VER="4.4.6"
Next, use the curl command as follows.
$ curl -SL https://github.com/NagiosEnterprises/nagioscore/releases/download/nagios-$VER/nagios-$VER.tar.gz | tar -xzf -
This downloads a directory called
nagios-4.4.6 in your present working directory.
Step 4: Install Nagios on Ubuntu
We are going to install Ubuntu by compiling from source. So, first, navigate into the Nagios directory:
$ cd nagios-4.4.6
Next, run the configure script:
This will take a few seconds and be sure to get a sample output shown below towards the end.
To compile the main program alongside the CGIs, run the
make all command as follows.
$ sudo make all
Next, create the group users as follows.
$ sudo make install-groups-users
$ sudo usermod -a -G nagios www-data
Then, install Nagios Core 4.x on your Ubuntu 20.04 system
$ sudo make install
Towards the end, some additional instructions will be printed as shown above.
Therefore run the command below to install the init script in
$ sudo make install-init
Next, Install and configure permissions on the directory that contains the external command file.
$ sudo make install-commandmode
Then install sample config files in
$ sudo make install-config
At this point, enable the Apache module required for Nagios web interface
$ sudo make install-webconf
$ sudo a2enmod rewrite cgi
$ sudo systemctl restart apache2
Additionally, feel free to install the Nagios exfoliation theme as follows:
$ sudo make install-exfoliation
For the classic Nagios theme, run the following command.
$ sudo make install-classicui
Step 5: Create a Nagios login web user
You need to create a login user that you will use to log in to Nagios interface. We will create a user called nagiosadmin using the command:
$ sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
You will be required to provide a password for the user and confirm it.
The password is written to the
Step 6: Install Nagios Plugins
Nagios are used to extend the functionality of Nagios. You can get a glimpse of the latest plugins from GitHub.
To download the plugins, invoke the command:
$ VER="2.3.3" $ curl -SL https://github.com/nagios-plugins/nagios-plugins/releases/download/release-$VER/nagios-plugins-$VER.tar.gz | tar -xzf -
On your current working directory, you will have another directory - nagios-plugins-2.3.3
To install the plugins, navigate to the plugins source directory:
$ cd nagios-plugins-2.3.3
Then compile the Nagios plugins from source as follows:
$ ./configure --with-nagios-user=nagios --with-nagios-group=nagios $ sudo make install
Once the installation is complete verify that all the configurations are in order as shown.
$ sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Step 7: Start and enable Nagios daemon
With all the configurations set and ready, proceed and start the nagios service as follows:
To start the Nagios service run:
$ sudo systemctl enable --now nagios
Confirm that Nagios service is running.
$ sudo systemctl status nagios
The output confirms that Nagios is up and running.
Step 8: Access Nagios
And finally, we get to the last step where we shall access Nagios. To do so, simply open your web browser and head to the URL shown.
You will be required to authenticate in the pop-up prompt shown. Use the credentials you provided in Step 5 and click on the 'Sign In' button.
Once authenticated, you will be ushered to the dashboard shown below.
In this tutorial we learned how to install Nagios on Ubuntu 20.04 LTS. Thanks for reading and I hope you have enjoyed reading this Nagios tutorial.