Sunday, December 29, 2024
Google search engine
HomeGuest BlogsInstall and Configure Nagios 4 on Ubuntu 22.04|20.04|18.04

Install and Configure Nagios 4 on Ubuntu 22.04|20.04|18.04

.tdi_3.td-a-rec{text-align:center}.tdi_3 .td-element-style{z-index:-1}.tdi_3.td-a-rec-img{text-align:left}.tdi_3.td-a-rec-img img{margin:0 auto 0 0}@media(max-width:767px){.tdi_3.td-a-rec-img{text-align:center}}

Welcome to our guide on how to install and configure Nagios 4 on Ubuntu 22.04|20.04|18.04. The edition of Nagios that will be installed on Ubuntu is Nagios Core. NagiosĀ® Coreā„¢ is an Open Source system and network monitoring application. Nagios watches hosts and services that you specify, alerting you when things go bad and when they get better.

Nagios will enable your organization to identify and resolve IT infrastructure problems before they affect critical business processes. This is achieved through a pro-active IT infrastructure monitoring to ensure systems, applications, services, and business processes are functioning properly. Whenever a failure is recorded, Nagios will alert the technical staff of the problem.

install nagios 4 ubuntu 02

Follow the steps in the next sections to have a running Nagios 4 monitoring server on Ubuntu 22.04|20.04|18.04 Linux machine.

.tdi_2.td-a-rec{text-align:center}.tdi_2 .td-element-style{z-index:-1}.tdi_2.td-a-rec-img{text-align:left}.tdi_2.td-a-rec-img img{margin:0 auto 0 0}@media(max-width:767px){.tdi_2.td-a-rec-img{text-align:center}}

Step 1: Update System

Run the update commands on your Ubuntu system to ensure youā€™re on the latest release.

sudo apt update && sudo apt upgrade -y

It is recommended to reboot if no service will be impacted.

[ -f /var/run/reboot-required ] && sudo reboot -f

Step 2: Install the required packages

Once the system is upgraded and rebooted. Youā€™ll 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

Check the releases page for latest Nagios available.

NAGIOS_VER=$(curl -s https://api.github.com/repos/NagiosEnterprises/nagioscore/releases/latest|grep tag_name|cut -d '"' -f 4)
curl -SL https://github.com/NagiosEnterprises/nagioscore/releases/download/$NAGIOS_VER/$NAGIOS_VER.tar.gz | tar -xzf -

The command will download and extract the Nagios core archive to your current working directory.

Change to created Nagios folder.

cd $NAGIOS_VER

Step 4: Install Nagios Core on Ubuntu

After extracting the archive, run the configure script:

 ./configure

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

make all

Create User And Group:

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

Install Nagios Core 4.x on Ubuntu:

sudo make install

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

sudo make install-daemoninit

Install and configures permissions on the directory for holding the external command file:

sudo make install-commandmode

Install sample config files in /usr/local/nagios/etc.

sudo make install-config

Install the Apache config file for the Nagios web interface:

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

Install the Exfoliation theme for the Nagios web interface.

sudo make install-exfoliation

If you want to use classic Nagios theme, run:

<make install-classicui>

Step 5: Create Nagios Web user

A user is required for the access to Nagios web console.

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

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

Step 6: Install Nagios Plugins

Nagios plugins are used to extend Nagios monitoring features. Letā€™s ensure they are installed. Check for the latest release of Nagios plugins from Github releases page.

cd ~/
VER=$( curl -s https://api.github.com/repos/nagios-plugins/nagios-plugins/releases/latest|grep tag_name|cut -d '"' -f 4|sed 's/release-//')
curl -SL https://github.com/nagios-plugins/nagios-plugins/releases/download/release-$VER/nagios-plugins-$VER.tar.gz | tar -xzf -

Change to the plugins source directory:

cd nagios-plugins-$VER

Compile and install Nagios plugins by running commands below.

./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 was successful on Ubuntu Linux machine.

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

You should get an output similar to below if installation of Nagios was successful.

Nagios Core 4.4.14
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 2023-08-01
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 nagios service to start at boot.

sudo systemctl  enable --now nagios

Confirm that nagios service is running.

$ systemctl status nagios
ā— nagios.service - Nagios Core 4.4.14
     Loaded: loaded (/lib/systemd/system/nagios.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2023-08-16 13:05:13 EAT; 3s ago
       Docs: https://www.nagios.org/documentation
    Process: 33611 ExecStartPre=/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg (code=exited, status=0/SUCCESS)
    Process: 33612 ExecStart=/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg (code=exited, status=0/SUCCESS)
   Main PID: 33613 (nagios)
      Tasks: 8 (limit: 4523)
     Memory: 6.1M
        CPU: 171ms
     CGroup: /system.slice/nagios.service
             ā”œā”€33613 /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
             ā”œā”€33614 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
             ā”œā”€33615 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
             ā”œā”€33616 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
             ā”œā”€33617 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
             ā”œā”€33619 /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
             ā”œā”€33620 /usr/local/nagios/libexec/check_ping -H 127.0.0.1 -w 3000.0,80% -c 5000.0,100% -p 5
             ā””ā”€33621 /usr/bin/ping -n -U -w 30 -c 5 127.0.0.1

Aug 16 13:05:13 jammy nagios[33613]: qh: Socket '/usr/local/nagios/var/rw/nagios.qh' successfully initialized
Aug 16 13:05:13 jammy nagios[33613]: qh: core query handler registered
Aug 16 13:05:13 jammy nagios[33613]: qh: echo service query handler registered
Aug 16 13:05:13 jammy nagios[33613]: qh: help for the query handler registered
Aug 16 13:05:13 jammy nagios[33613]: wproc: Successfully registered manager as @wproc with query handler
Aug 16 13:05:13 jammy nagios[33613]: wproc: Registry request: name=Core Worker 33614;pid=33614
Aug 16 13:05:13 jammy nagios[33613]: wproc: Registry request: name=Core Worker 33615;pid=33615
Aug 16 13:05:13 jammy nagios[33613]: wproc: Registry request: name=Core Worker 33617;pid=33617
Aug 16 13:05:13 jammy nagios[33613]: wproc: Registry request: name=Core Worker 33616;pid=33616
Aug 16 13:05:13 jammy nagios[33613]: Successfully launched command file worker with pid 33619

Step 8: Access Nagios Web Dashboard

if you have ufw firewall, allow http and https ports for inbound traffic.

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

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

nagios login

Input the credentials for the user created earlier.

install nagios 4 ubuntu 01

You should get to Nagios Administration dashboard.

install nagios 4 ubuntu 02

We hope this guide helped you to install Nagios 4 on Ubuntu 22.04|20.04|18.04. The next reading is monitoring for your IT environment.

Go through official Nagios 4 documentation for configuration guides.

Similar guides:

Install LibreNMS on Ubuntu

Install Grafana on Debian

Install Prometheus on Ubuntu

.tdi_4.td-a-rec{text-align:center}.tdi_4 .td-element-style{z-index:-1}.tdi_4.td-a-rec-img{text-align:left}.tdi_4.td-a-rec-img img{margin:0 auto 0 0}@media(max-width:767px){.tdi_4.td-a-rec-img{text-align:center}}

RELATED ARTICLES

Most Popular

Recent Comments

ź°•ģ„œźµ¬ģ¶œģž„ė§ˆģ‚¬ģ§€ on How to store XML data into a MySQL database using Python?
źøˆģ²œźµ¬ģ¶œģž„ė§ˆģ‚¬ģ§€ on How to store XML data into a MySQL database using Python?
ź“‘ėŖ…ģ¶œģž„ģ•ˆė§ˆ on How to store XML data into a MySQL database using Python?
ź“‘ėŖ…ģ¶œģž„ģ•ˆė§ˆ on How to store XML data into a MySQL database using Python?
ė¶€ģ²œģ¶œģž„ģ•ˆė§ˆ on How to store XML data into a MySQL database using Python?
źµ¬ģ›”ė™ģ¶œģž„ģ•ˆė§ˆ on How to store XML data into a MySQL database using Python?
ź°•ģ„œźµ¬ģ¶œģž„ģ•ˆė§ˆ on How to store XML data into a MySQL database using Python?
ģ˜¤ģ‚°ģ¶œģž„ģ•ˆė§ˆ on How to store XML data into a MySQL database using Python?
ź“‘ėŖ…ģ¶œģž„ė§ˆģ‚¬ģ§€ on How to store XML data into a MySQL database using Python?
ģ•ˆģ–‘ģ¶œģž„ė§ˆģ‚¬ģ§€ on How to store XML data into a MySQL database using Python?
ė¶€ģ²œģ¶œģž„ģ•ˆė§ˆ on How to store XML data into a MySQL database using Python?
ė™ķƒ„ģ¶œģž„ģ•ˆė§ˆ on How to store XML data into a MySQL database using Python?
ģ„œģšøģ¶œģž„ģ•ˆė§ˆ on How to store XML data into a MySQL database using Python?
ė¶„ė‹¹ģ¶œģž„ģ•ˆė§ˆ on How to store XML data into a MySQL database using Python?
ė¶€ģ²œģ¶œģž„ģ•ˆė§ˆ on How to store XML data into a MySQL database using Python?
ķ™”ź³”ė™ģ¶œģž„ė§ˆģ‚¬ģ§€ on How to store XML data into a MySQL database using Python?
ź°•ģ„œźµ¬ģ¶œģž„ė§ˆģ‚¬ģ§€ on How to store XML data into a MySQL database using Python?
ź³ ģ–‘ģ¶œģž„ģ•ˆė§ˆ on How to store XML data into a MySQL database using Python?
ķ™”ģ„±ģ¶œģž„ė§ˆģ‚¬ģ§€ on How to store XML data into a MySQL database using Python?
ģ²œķ˜øė™ģ¶œģž„ė§ˆģ‚¬ģ§€ on How to store XML data into a MySQL database using Python?