Install and configure Nagios 4 on Ubuntu 20.04

The
You can download this article in PDF format to support us through the following link.

Download the guide in PDF format

turn off
The

The
The

Welcome to our guide to learn how to install and configure Nagios 4 on Ubuntu 20.04 (Focal Fossa). The version of Nagios that will be installed on Ubuntu 20.04 is Nagios Core. Nagios®Core ™ is an open source system and network monitoring application. Nagios will monitor the hosts and services you specify and alert you when the situation becomes worse or better.

Nagios will enable your organization to identify and resolve IT infrastructure issues before they affect critical business processes. This can be achieved through proactive IT infrastructure monitoring to ensure that systems, applications, services, and business processes are functioning properly. Whenever a fault is recorded, Nagios warns the technician of the problem.

Follow the steps in the following sections to run Nagios 4 monitoring server on Ubuntu 20.04 Linux computer.

Step 1: Update the system

Run the update command on the Ubuntu system to ensure that you are using the latest version.

sudo apt update && sudo apt upgrade

If it does not affect any services, it is recommended to restart.

sudo systemctl reboot

Step 2: Install required packages

Once the system is upgraded and restarted. You need to install the packages required to build Nagios Core on Ubuntu Linux.

sudo apt update
sudo apt install wget unzip vim curl openssl build-essential libgd-dev libssl-dev libapache2-mod-php php-gd php apache2

Step 3: Download Nagios Core on Ubuntu 20.04

an examination Publish page To get the latest Nagios.

export VER="4.4.6"
curl -SL https://github.com/NagiosEnterprises/nagioscore/releases/download/nagios-$VER/nagios-$VER.tar.gz | tar -xzf -

This command will download the Nagios core archive and unzip it into your current working directory.

Go to the created Nagios folder.

cd nagios-$VER

Step 4: Install Nagios Core 4.x on Ubuntu 20.04

After unzipping the archive, run the configure script:

 ./configure

Run the make command with the all option to compile the main program and CGI.

sudo make all

Create users and groups:

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

Install Nagios Core 4.x on Ubuntu 20.04:

sudo make install

Install the initialization script in / lib / systemd / system,

sudo make install-daemoninit

Install and configure permissions on the directory to save external command files:

sudo make install-commandmode

Install the sample configuration file in / usr / local / nagios / etc.

sudo make install-config

Install the Apache configuration file for the Nagios web interface:

sudo make install-webconf
sudo a2enmod rewrite cgi
sudo systemctl restart apache2

Install exfoliating theme for Nagios web interface.

sudo make install-exfoliation

If you want to use the classic Nagios theme, run:

sudo make install-classicui

Step 5: Create Nagios Web user

You must have a user to access the Nagios web console.

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

htpasswd has been used to generate a password and write it /usr/local/nagios/etc/htpasswd.users file.

Step 6: Install Nagios plugin on Ubuntu 20.04

Nagios plugin is used to extend Nagios monitoring function. Make sure they are installed. Check the latest version of Nagios plugin from it Github release page.

cd ~/
VER="2.3.3"
curl -SL https://github.com/nagios-plugins/nagios-plugins/releases/download/release-$VER/nagios-plugins-$VER.tar.gz | tar -xzf -

Go to the plugin source directory:

cd nagios-plugins-$VER

Compile and install the Nagios plugin by running the following command.

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

Step 7: Verify installation and start Nagios service

Confirm that your Nagios installation has been successfully completed on an Ubuntu 20.04 Linux computer.

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

If you successfully installed Nagios, you should get output similar to the following.

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

Start and enable the nagios service to start at startup.

sudo systemctl  enable --now nagios

Confirm that the nagios service is running.

$ systemctl status nagios
● nagios.service - Nagios Core 4.4.6
Loaded: loaded (/lib/systemd/system/nagios.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2020-05-17 16:45:23 UTC; 37s ago
Docs: https://www.nagios.org/documentation
Process: 35008 ExecStartPre=/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg (code=exited, status=0/SUCCESS)
Process: 35009 ExecStart=/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg (code=exited, status=0/SUCCESS)
Main PID: 35010 (nagios)
Tasks: 6 (limit: 2344)
Memory: 2.4M
CGroup: /system.slice/nagios.service
├─35010 /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
├─35011 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
├─35012 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
├─35013 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
├─35014 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
└─35030 /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
May 17 16:45:23 ubuntu20 nagios[35010]: qh: Socket '/usr/local/nagios/var/rw/nagios.qh' successfully initialized
May 17 16:45:23 ubuntu20 nagios[35010]: qh: core query handler registered
May 17 16:45:23 ubuntu20 nagios[35010]: qh: echo service query handler registered
May 17 16:45:23 ubuntu20 nagios[35010]: qh: help for the query handler registered
May 17 16:45:23 ubuntu20 nagios[35010]: wproc: Successfully registered manager as @wproc with query handler
May 17 16:45:23 ubuntu20 nagios[35010]: wproc: Registry request: name=Core Worker 35014;pid=35014
May 17 16:45:23 ubuntu20 nagios[35010]: wproc: Registry request: name=Core Worker 35013;pid=35013
May 17 16:45:23 ubuntu20 nagios[35010]: wproc: Registry request: name=Core Worker 35012;pid=35012
May 17 16:45:23 ubuntu20 nagios[35010]: wproc: Registry request: name=Core Worker 35011;pid=35011
May 17 16:45:24 ubuntu20 nagios[35010]: Successfully launched command file worker with pid 35030

Step 8: Access the Nagios Web dashboard

If you have a ufw firewall, please allow http and https ports for inbound communication.

for i in http https ssh; do sudo ufw allow $i; done

Now, use your browser to access the Nagios dashboard http:[IP/hostname]/ nagios /

Install and configure Nagios 4 on Ubuntu 20.04

Enter the credentials of the previously created user.

Install and configure Nagios 4 on Ubuntu 20.04

You should go to the Nagios Administration dashboard.

Install and configure Nagios 4 on Ubuntu 20.04

We hope this guide will help you install Nagios 4 on Ubuntu 20.04. The next article is to monitor your IT environment.

Through official Nagios 4 documentation About the configuration guide.

Similar guidelines:

Install Zabbix 5 on Ubuntu

Install LibreNMS on Ubuntu

Install Grafana on Ubuntu

Install Prometheus on Ubuntu

The
You can download this article in PDF format to support us through the following link.

Download the guide in PDF format

turn off
The

The
The

Sidebar