How to install Nagios Core on Ubuntu 20.04

Share on Social Media

Learn how to install Nagios Core on Ubuntu 20.04 with this step-by-step guide. Ensure efficient network monitoring by setting up Nagios Core properly on your Ubuntu system. #centlinux #linux #nagios

What is Nagios Core?

Nagios Core, formerly known as Nagios, is a free and open-source computer-software application that monitors systems, networks and infrastructure.

This enterprise network monitoring software offers monitoring and alerting services for servers, switches, applications and services. It alerts users when things go wrong and alerts them a second time when the problem has been resolved.

Nagios was originally designed to run under Linux distros, but it also runs on other Unix variants. It is free software licensed under the terms of the GNU GPL v2 as published by the Free Software Foundation.

Nagios Alternatives: Network Monitoring Tools

There are several alternatives to Nagios Core for monitoring systems, networks, and applications. Some popular alternatives include:

  1. Zabbix: An open-source monitoring tool that offers extensive features for monitoring servers, networks, and applications with a robust web interface and flexible alerting.
  2. Prometheus: An open-source systems monitoring and alerting toolkit designed for reliability and scalability. It uses a powerful query language (PromQL) and integrates well with Grafana for visualization.
  3. Icinga: A fork of Nagios, Icinga provides advanced monitoring features, a modern web interface, and supports distributed monitoring.
  4. Sensu: A flexible, scalable, and open-source monitoring tool that focuses on monitoring dynamic cloud infrastructure and applications, with support for various data sources and handlers.
  5. Checkmk: A comprehensive IT monitoring solution that can monitor networks, servers, applications, and cloud environments, with a user-friendly interface and powerful automation capabilities.
  6. Datadog: A commercial monitoring and analytics platform for cloud-scale applications, offering features for infrastructure monitoring, application performance monitoring, and log management.
  7. New Relic: A cloud-based observability platform providing full-stack monitoring, application performance monitoring, and real-time analytics.
  8. SolarWinds: A suite of monitoring tools for various aspects of IT infrastructure, including network performance, server performance, and application monitoring.
  9. Opsview: A comprehensive monitoring platform that supports monitoring of physical, virtual, and cloud environments, with a focus on scalability and ease of use.
  10. PRTG Network Monitor: An all-in-one monitoring solution that provides detailed insights into network performance, servers, and applications with customizable dashboards and alerting.

Each of these tools has its own strengths and is suited to different use cases, so the best choice will depend on your specific monitoring needs and environment.

Recommended Online Training: Network Monitoring Using Nagios

1265172 359ashow?id=oLRJ54lcVEg&offerid=1074530.1265172&bids=1074530

Environment Specification

We are using a minimal Ubuntu 20.04 virtual machine with following specifications.

  • CPU – 3.4 Ghz (2 cores)
  • Memory – 2 GB
  • Storage – 40 GB
  • Operating System – Ubuntu Server 20.04 LTS
  • Hostname – nagios-01.centlinux.com
  • IP Address – 192.168.116.239 /24

Upgrade Ubuntu Software Packages

Connect with nagios-01.centlinux.com as a superuser by using a ssh client.

Execute apt command to update list of upgradeable software packages on your Ubuntu operating system.

$ sudo apt update
...
Fetched 4,186 kB in 42s (99.4 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
62 packages can be upgraded. Run 'apt list --upgradable' to see them.

You can now upgrade Ubuntu software packages by executing following apt command.

$ sudo apt -y upgrade
...
Found linux image: /boot/vmlinuz-5.4.0-66-generic
Found initrd image: /boot/initrd.img-5.4.0-66-generic
done
Processing triggers for initramfs-tools (0.136ubuntu6.4) ...
update-initramfs: Generating /boot/initrd.img-5.4.0-71-generic

Install Nagios Core on Ubuntu 20.04

Nagios Core is available in Ubuntu 20.04 LTS via the standard APT repositories. Although the available version is not the most recent, but it is the stable and supported version for your Linux distribution.

Therefore, you can easily install Nagios on Ubuntu by using apt command.

$ sudo apt install -y nagios4 nagios-plugins-contrib nagios-nrpe-plugin
...
Processing triggers for php7.4-cli (7.4.3-4ubuntu2.4) ...
Processing triggers for libapache2-mod-php7.4 (7.4.3-4ubuntu2.4) ...

During the installation of Nagios core, you may be asked to configure Postfix mail settings.

Nagios Core - Postfix Configuration
Nagios Core – Postfix Configuration

Select ‘No configuration’ option and click on ‘ok’ to complete setup.

Apache configuration file for Nagios uses following two apache modules. mod_authz_groupfile is used to allow or deny access to authenticated by group membership, and mod_authz_groupfile enables the MD5 digest authentication.

Therefore, you have to enable both of them by executing following command at Linux Bash prompt.

$ sudo a2enmod authz_groupfile auth_digest
[sudo] password for ahmer:
Considering dependency authz_core for authz_groupfile:
Module authz_core already enabled
Enabling module authz_groupfile.
Considering dependency authn_core for auth_digest:
Module authn_core already enabled
Enabling module auth_digest.
To activate the new configuration, you need to run:
  systemctl restart apache2

A default configuration file for Nagios Core is installed in Apache configuration directory. You can modify it according to your requirements.

Use nano text editor to edit Nagios configuration file.

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

Locate following lines in this file and comment them by inserting a hash (#) symbol at the start of line.

#Require ip ::1/128 fc00::/7 fe80::/10 10.0.0.0/8 127.0.0.0/8 169.254.0.0/16 172.16.0.0/12 192.168.0.0/16
#<Files "cmd.cgi">
#Require all    granted
#</Files>

Find and uncomment following line by removing the hash (#) symbol from start of line.

Require valid-user

To access Nagios web interface, you need a user credentials.

You can add a user in authentication file by using following command.

$ sudo htdigest -c /etc/nagios4/htdigest.users Nagios4 nagiosadmin
Adding password for nagiosadmin in realm Nagios4.
New password:
Re-type new password:

Restart Apache service to apply changes that you have made so far.

$ sudo systemctl restart apache2

Allow Apache service in Ubuntu ufw (Uncomplicated Firewall).

$ sudo ufw allow Apache
Rules updated
Rules updated (v6)

Accessing Nagios Core GUI

Open URL http://nagios-01.centlinux.com/nagios4/ in a web browser.

Nagios Login
Nagios Login

Login as nagiosadmin user.

Nagios Dashboard
Nagios Dashboard

After successful login, you have reached at the Nagios default dashboard.

Click on ‘Tactical Overview’ from the left side menu.

Nagios Core - Tactical Overview
Nagios Core – Tactical Overview

Click on ‘Services’ from the left side menu.

Nagios Core - Services
Nagios Core – Services

To learn more about the Nagios network monitoring software, we recommend that you should buy and read Nagios Core Administration Cookbook – Second Edition (PAID LINK) by Tom Ryder.

Final Thoughts

Final Thoughts

Setting up Nagios Core on Ubuntu 20.04 can greatly enhance your network monitoring capabilities, ensuring your systems run smoothly and efficiently. By following a structured installation process, you can leverage the powerful features of Nagios Core to keep your infrastructure in check and respond proactively to potential issues.

If you need professional assistance with installing Nagios Core on Ubuntu 20.04, or if you have any other network monitoring needs, I offer expert services to help you get up and running quickly. Visit my Fiverr gig to learn more about how I can assist you in optimizing your IT environment. Let’s ensure your network operates flawlessly with Nagios Core!

Leave a Comment