LowEndBox - Cheap VPS, Hosting and Dedicated Server Deals

How to Install Nagios on a Ubuntu 20.04 VPS

Tags: , , , , Date/Time: June 23, 2021 @ 12:00 am, by raindog308

This article was contributed by Dustin Cisneros at RackNerd, a web hosting and infrastructure as a service provider which was recently voted #1 by the LowEndTalk community! If you are looking for a Linux VPS, Ryzen VPS, Windows VPS, or shared and reseller hosting services, be sure to take a look at RackNerd’s latest special offers here.

Nagios is a well-known open-source software that is used for monitoring networks and systems. Nagios has the ability to monitor activities of a host and the associated services, and if something is out of order, Nagios can report it through multiple notification methods. In the text below, we will take a look at how Nagios is installed:

Installation guide

To begin the installation process, run the command listed below as a user with sudo privileges:

sudo apt update

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

This will result in the installation of multiple packages that include: Apache, Nagios plugin and nagios core. The configuration file of Apache that comes with Nagios is dependent upon mod_authz_groupfile and mod_auth_digest modules. It is noteworthy that prior enabling of these modules isn’t there by default.  mod_authz_groupfile module is involved in either allowing or denying access to the authenticated by group membership. After that, to enable the MD5 digest authentication the module mod_authz_groupfile is used.

 The following command must be run in order to enable the 2 modules above:

sudo a2enmod authz_groupfile auth_digest

The configuration set by default for Apache permits only localhost and private IPs to access Nagios. This article guides you to change the default configuration in such a way that allows only authenticated users to view issue commands and interface. The next step involves opening the configuration file via the text editor:

sudo nano /etc/apache2/conf-enabled/nagios4i.conf

Next step includes commenting the lines that begin with require ip, “<Files “cmd.cgi”>”, “” and Require all granted, followed by uncommenting of the line that contains Require valid-user within the following file:

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

Information regarding the configuration of multiple levels of access is additionally contained in the file above.

After the above steps use the command below for restarting Apache:

sudo systemctl restart apache2

Now in order to check the status of Nagios and Apache, the following command can be used:

sudo systemctl status apache2sudo systemctl status nagios4

This will confirm whether the two are working appropriately or not.

How to create a user account?

After installation, the inherent configuration of Nagios allows a user named “nagiosadmin” all the administrative authorities through which it is possible to log into nagios’ web interface, and the management of inventory can be done as well. The htdigest command below can be used for the setting up of the by default user discussed previously:

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

To allow the changes to completely occur, restart Apache.

sudo systemctl restart apache2

How to access Nagios web interface

Put in either the public IP address into your web browser as follows:

http(s)://your_VPS_ip_address/nagios

Then, put in the login information for the default nagiosadmin user and you will see the Nagios home page.

How to configure the firewall

UFW tool comes with Ubuntu that can be used for configuration of firewall. After the enabling of firewall, open the HTTPS and HTTP ports and insert the following command:

sudo ufw allow Apache

Do you use Nagios or do you prefer another monitoring software instead? Let us know your feedback/comments below!

No Comments

    Leave a Reply

    Some notes on commenting on LowEndBox:

    • Do not use LowEndBox for support issues. Go to your hosting provider and issue a ticket there. Coming here saying "my VPS is down, what do I do?!" will only have your comments removed.
    • Akismet is used for spam detection. Some comments may be held temporarily for manual approval.
    • Use <pre>...</pre> to quote the output from your terminal/console, or consider using a pastebin service.

    Your email address will not be published. Required fields are marked *