How to install Nagios on Ubuntu 20.04?

Overview

Nagios is an open-source monitoring tool. It helps monitor all your network, servers, services, apps, and processes, which also keeps an inventory of your whole IT infrastructure. This tutorial demonstrates the installation of Nagios on Ubuntu server.

Prerequisites

There are certain prerequisites that need to be met before you begin.

  • A server running Ubuntu 20.04

  • Non-root sudo user privileges

Get Started

Step 1 - Setting up Nagios on Ubuntu 20.04

  • Execute the below commands as a user with sudo permissions to install Nagios:

sudo apt update
sudo apt install nagios4 nagios-plugins-contrib nagios-nrpe-plugin
  • The Apache configuration file requires the mod_auth_digest and mod_authz_groupfile modules which are used to grant or restrict access to users who have provided proof of group membership. So, to enable these modules, execute the below commands:

sudo a2enmod authz_groupfile auth_digest
  • Nagios can only be accessed by localhost and private IP addresses under the default configuration of Apache. We will now modify the configuration so that only the users who have been authenticated will be able to view the interface and run commands.

sudo nano /etc/apache2/conf-enabled/nagios4-cgi.conf
  • Locate the lines beginning with "Require ip" and "Require all granted" and comment them. Next, navigate to the line "Require valid-user" and uncomment it, as shown below:

  • Once you are done with the modifications, restart Apache:

sudo systemctl restart apache2
  • By examining their status, you can confirm that Nagios and Apache are both operating correctly:

sudo systemctl status apache2
sudo systemctl status nagios4

Press q or Ctrl+z to exit.

Step 2 - Setting Up a User Account

  • By default, Nagios is set up to give the user "nagiosadmin" administrative rights. You can access the Nagios web interface and control your inventory using this user. To create the user, enter the following htdigest command:

sudo htdigest -c /etc/nagios4/htdigest.users Nagios4 nagiosadmin
  • To make modifications effective, restart the Apache service:

sudo systemctl restart apache2

Step 3 - Setting Up the Firewall

  • UFW firewall setup software is included in Ubuntu. Ensure that the HTTP/HTTPS ports are open if your system has a firewall enabled:

sudo ufw allow Apache

Step 4 - Getting to the Nagios Web Interface

  • Open your preferred browser and enter your IP address, and then type /nagios (version number) to access the Nagios web interface:

http(s)://your_domain_or_ip_address/nagios4

Conclusion

We have successfully demonstrated how to set up Nagios on Ubuntu system.

Last updated