How to Install Nagios on Ubuntu 20.04 LTS

In this article we are going to cover How to Install Nagios on Ubuntu 20.04 LTS

Nagios Core Features:

  • Nagios core is used for continuous monitoring of servers, network, applications, business processes and infrastructure.
  • Nagios core detects network errors, server crashes and automatically sends the alerts.
  • In Nagios issues occurred can also be fixed automatically.
  • Nagios core is scalable, manageable and secure server monitoring tool.

Prerequisites

  • Ubuntu Server with 20.04 LTS
  • Preinstalled Apache2
  • 1 CPU and 2 GB RAM
  • Firewall Ports 5666,80,443

Before installing Nagios, Install the below per-requisite packages .

sudo apt-get update
sudo apt-get install -y autoconf gcc libc6 make wget unzip apache2 php libapache2-mod-php7.4 libgd-dev

Step #1: Create Nagios User and Group

Enter below command to create Nagios user and group and add www-data user to nagios group.

sudo useradd nagios
sudo groupadd nagios
sudo make install-groups-users
sudo usermod -a -G nagios www-data

Step #2: Download Latest Nagios Core Setup on Ubuntu 20.04 LTS

Here We are downloading Nagios Core 4.4.6 setup, To download latest version visit Officical Nagios Site

Navigate to /tmp directory

cd /tmp

Download and Extract the Nagios Core Setup

wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.5.tar.gz

tar -zxvf nagios-4.4.5.tar.gz

cd /tmp/nagioscore-nagios-4.4.6/

Step #3: Install Nagios on Ubuntu 20.04 LTS

Compile the Nagios Core and Install Nagios on Ubuntu 20.04 LTS

sudo ./configure --with-nagios-group=nagios --with-command-group=nagcmd --with-httpd_conf=/etc/apache2/sites-enabled/

sudo make all

sudo make install

sudo make install-init

sudo make install-config

sudo make install-commandmode

Step #4: Install and Configure Apache Files

Install and configure apache files using below commands,

sudo make install-webconf
sudo a2enmod rewrite
sudo a2enmod cgi

Restart an Apache to take effect

sudo systemctl restart apache2

Step #5: Create User Account to Access Nagios Web Interface

We have to create user in apache and set password. Enter below command for same.

sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

Output:

sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
New password:
Re-type new password:
Adding password for user nagiosadmin

Step #6: Download and Install Nagios Plugins

Navigate to /tmp directory, Download the nagios core plugin and extract it as shown below

cd /tmp
wget https://nagios-plugins.org/download/nagios-plugins-2.3.3.tar.gz
tar -zxvf nagios-plugins-2.3.3.tar.gz

Compile and install nagios core plugins,

cd nagios-plugins-2.3.3/
sudo ./configure --with-nagios-user=nagios --with-nagios-group=nagios
sudo make
sudo make install

Step #7: Verify Nagios Configuration, Start Nagios and Enable

Verify the Nagios core configuration using below command,

sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Output:

Nagios Core 4.4.6
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 2020-04-28
License: GPL

Website: https://www.nagios.org
Reading configuration data...
   Read main config file okay...
   Read object config files okay...

Running pre-flight check on configuration data...

Checking objects...
        Checked 8 services.
        Checked 1 hosts.
        Checked 1 host groups.
        Checked 0 service groups.
        Checked 1 contacts.
        Checked 1 contact groups.
        Checked 24 commands.
        Checked 5 time periods.
        Checked 0 host escalations.
        Checked 0 service escalations.
Checking for circular paths...
        Checked 1 hosts
        Checked 0 service dependencies
        Checked 0 host dependencies
        Checked 5 timeperiods
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...

Total Warnings: 0
Total Errors:   0

Things look okay - No serious problems were detected during the pre-flight check

To start Nagios Service

sudo systemctl start nagios

To enable nagios service at system startup

sudo systemctl enable nagios

Step #8: Accessing Nagios Web Interface

To access nagios web interface, Open your favorite browser and type your server name or IP followed by nagios/

http://Server_IP/nagios

OR

http://Domain_Name/nagios

Once you hit above URL, Enter the credentials of “nagiosadmin” user and password you set above , you will be redirected to nagios default page.

How to Install Nagios on Ubuntu 20.04 LTS 1

To Monitor the services. go to Current status -> Services at left pane as shown below.

Conclusion:

In this article, we have performed Creating nagios user and group, downloading Nagios Core, compiling and installing nagios, Installing apache configuration files, Downloading and installing Nagios core plugins, verify,start and enable Nagios service, Accessing nagios web interface.

Related Articles:

How to Install Nagios Core on CentOS 7

Akash Padwal

I am Akash Padwal working as a DevOps Engineer Intern in Product Company. Likes to explore new DevOps tools and share knowledge.

1 thought on “How to Install Nagios on Ubuntu 20.04 LTS”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Share via
Copy link
Powered by Social Snap