Linux

How to Install Nagios on Ubuntu 20.04

0
How to Install Nagios on Ubuntu 20.04

Nagios is a popular open source monitoring system.

Nagios stores an inventory of your entire IT infrastructure and ensures your network, servers, applications, services and processes are up and running. In the event of failure or suboptimal performance, Nagios will send notification notifications through various methods.

This article explains how to install Nagios on Ubuntu 20.04.

Install Nagios on Ubuntu 20.04

Nagios 4 is available in the Ubuntu software repository. Installation is quite easy, just run the following command as a user with sudo privileges:

sudo apt update
sudo apt install nagios4 nagios-plugins-contrib nagios-nrpe-plugin

The above command will install many packages, including Nagios Core, Nagios Plugins, and Apache.

The Apache configuration file that ships with Nagios depends on the mod_authz_groupfile and mod_auth_digest modules, which are not activated by default. the mod_authz_groupfile module is used to allow or deny access to be authenticated by group membership, and mod_authz_groupfile allows MD5 digest authentication.

Run the command below to activate both modules:

sudo a2enmod authz_groupfile auth_digest

The default Apache configuration allows access to Nagios only from localhost and private IP. We will change the configuration so that only authenticated users can see the interface and issue orders.

Open the configuration file with your text editor:

sudo nano /etc/apache2/conf-enabled/nagios4-cgi.conf

Comment on the lines that begin with Require ip, “<Files” cmd.cgi “>”, “” and Require everything given and delete comments on lines that contain valid user requirements, as shown below:

/etc/apache2/conf-enabled/nagios4-cgi.conf

This file also includes instructions for configuring different access levels.

After restarting Apache:

sudo systemctl restart apache2

You can verify that Apache and Nagios are functioning properly by checking their status:

sudo systemctl status apache2
sudo systemctl status nagios4

Create a User Account

By default, Nagios is configured to give administrative rights to users named “Nagiosadmin”. With this user, you can enter the Nagios web interface and manage your inventory. Use the following htdigest command to create a user:

sudo htdigest -c /etc/nagios4/htdigest.users Nagios4 nagiosadmin

You will be prompted to enter and confirm the user’s password.

Output :

New password: 
Re-type new password: 
Adding password for user nagiosadmin

Restart the Apache service for the changes to take effect:

sudo systemctl restart apache2

Configure the Firewall

Ubuntu is shipped with a firewall configuration tool called UFW. If a firewall is enabled on your system, be sure to open HTTP and HTTPS ports:

sudo ufw allow Apache

Access the Nagios Web Interface

To access the Nagios web interface, open your favorite browser and type your server domain name or public IP address followed by / Nagios:

http(s)://your_domain_or_ip_address/nagios

Enter your Nagiosadmin user login credentials, and you will be directed to the Nagios main page.

Conclusion

We have shown you how to install Nagios on an Ubuntu server.

For more information on how to configure and use Nagios, check their documentation.

If you experience problems or get feedback, leave a comment below.

How to Create and Manage Digital Family Documents

Previous article

How to fix Motion Blur on a PC Game

Next article

You may also like

More in Linux