How to install Nagios on Ubuntu 20.04

Nagios is an open-source monitoring tool that was designed to serve the purpose of monitoring the different networking apps, their sources, and various Linux based devices. With Nagios, we can be vigilant of any critical activities and events of software malfunctions by sending automated alerts to the admins and prevent further damages.

Nagios also keep tabs on networking details(using TCP port, SMTP, POP3, HTTP, NNTP, PING, etc.)

The way it works can be described in the following manner: Nagios sets up security protocols on the different nodes in a network to detect any suspicious activity and notifies the users via an automatic SMS. These problematic activities include HTTP, SSH, FTP fails, other malfunction and critical errors, etc. And displays the web output using current statuses notifications and problem history log file etc. Let’s see how we are going to install Nagios on Ubuntu 20.04 LTS machine.

Some pre-requisites

We’re assuming that you’re at least familiar with the fundamentals of Linux OS, and have a basic know-how of its interactive shell works. Other than that, you should have pre-installed ubuntu 20.04 on your virtual machine or server before proceeding with the installation.

Also, we’re downloading and installing the Nagios package from the official depositories here.

We’ll be using the sudo access mode during the installation. If you’re using your root account, you should exclude ‘sudo’ before each of the commands we’ve used below.

Here’s how to go about installing Nagios on your Virtual machine or server.

Step 1: Check for the updates

First off, we’ll check the web for the latest packages available, download and install them. Use the command below to check for updates.

$ sudo apt update && upgrade

$ sudo apt install -y build-essential apache2 php openssl perl make
php-gd libgd-dev libapache2-mod-php libperl-dev libssl-dev daemon
wget apache2-utils unzip

Step 2: Create a user account

Before we install Nagios, we must create a user account parallel to that of the apache user. Type in the following commands to add a user:

$ sudo useradd nagios
$ sudo groupadd nagcmd
$ sudo usermod -a -G nagcmd nagios
$ sudo usermod -a -G nagcmd www-data

Step 3: Download Nagios from the official website

With the updates and user account took care of, we can download Nagios by visiting the official website.

Alternatively, you can use the following commands to download directly from the web:

$ cd /tmp

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

Then extract the files with the help of tar command, and move it to the location of your choice

$ tar -zxvf /tmp/nagios-4.4.5.tar.gz

$ cd /tmp/nagios-4.4.5/

Step 4: Compile Nagios with Ubuntu 20.04

Type in the following commands:

$ 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 5: Update your email address

Type in the following command:

$ sudo gedit /usr/local/nagios/etc/objects/contacts.cfg

What this command does is that it edits the file (contacts.cfg) located in the directory usr/local/nagios/etc/objects, to include the email address where we want to receive notifications.

Step 6: Fire up the web interface installer

With all of the above input into their places, we can finally move on to the installation of Nagios web interface. Use the following codes, to begin with, the installation.

$ sudo make install-webconf

You’ll need a user account to start using the Nagios web interface, so naturally, you must create a user account first.

Type the following in the interactive shell to create a user account.

$ cd /tmp/nagios-4.4.5$ sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users

$ sudo a2enmod cgi

Finally, you can restart the Apache Servers.

$ sudo systemctl restart apache2

Step 7: Install Nagios Plugins

If it is not already on /tmp, you can switch directories using:

$ cd /tmp

And then use the following command to start the download.

$ wget https://nagios-plugins.org/download/nagios-plugins-2.3.3.tar.gz

Next, you must extract the file and place it in the resultant directory:

$ tar -zxvf /tmp/nagios-plugins-2.3.3.tar.gz

$ cd /tmp/nagios-plugins-2.3.3/

Once you’ve switched the directories, compile the plugins using the following command:

$ sudo ./configure --with-nagios-user=nagios --with-nagios-group=nagios

$ sudo make

$ sudo make install

Step 8: Using Nagios on Ubuntu

To make sure the configuration was properly seen through, use the following command:

$ sudo /usr/local/nagios/bin/nagios -v

$ cd /usr/local/nagios/etc/nagios.cfg

Turn on the Nagios service to automatically start it every time you boot your VM by using:

$ sudo systemctl enable nagios

Start the services.

$ sudo systemctl start Nagios

Step 9: Get to know the web interface

Go to http://ip-add/nagios/ and have a crack at the web interface. You’ll be asked the user credentials before you log in.

Upon logging in, you should be seeing the member dashboard:

Notice the variety of options on the far left of the interface. Hover over them to find out more.

Wrapping things up

In this tutorial, we’ve seen how to install Nagios on Ubuntu 20.04. We went through and detailed all the steps that need be followed and explained what function each step serves overall. It is much easier to install Nagios from their official repositories than to install it from its source code. But sometimes, it so happens that the repositories fail to deliver the latest versions of Nagios. This, of course, is never the case when you use source code to install Nagios.



from Linux Hint https://ift.tt/3isbclX

Post a Comment

0 Comments