How To Install Nagios On Ubuntu 20.04 | Holhol24

7

Nagios is one of the most widely used open-source
monitoring tools for monitoring the services and applications that run on Windows and Linux operating systems.

With the help of
Nagios, you can monitor basic services such as HTTP, FTP, SSH, SMTP, etc., and attributes such as CPU load, memory, disk usage, logged in users, running processes, etc.

Nagios can also monitor routers and other network devices.

Here, we will see how to install
Nagios on
Ubuntu 20.04.

Prerequisites

Nagios doesn’t come in .deb package format. So, we need to compile it from the source. Install the below packages for compiling Nagios.

sudo apt update

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

Create a user and group for Nagios. Then add the nagios and apache user (www-data) to the part of the nagcmd group that allows the external commands to be executed through the Nagios web interface.

sudo useradd nagios

sudo groupadd nagcmd

sudo usermod -a -G nagcmd nagios

sudo usermod -a -G nagcmd www-data

Install Nagios Core

Download Nagios

Download the Nagios core (v4.4.5) tarball using the terminal with wget command. Else, you can visit the
official website to download the latest version of Nagios core.

cd /tmp

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

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

cd /tmp/nagios-4.4.5/

Compile Nagios

Execute below commands to compile the Nagios from the source code.

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

Configure Nagios

Nagios places configuration files in the /usr/local/nagios/etc directory. These default configuration files should work fine.

Edit the /usr/local/nagios/etc/objects/contacts.cfg file and change the email address associated with the nagiosadmin contact definition to the email address you would like to use for receiving alert notification.

sudo nano /usr/local/nagios/etc/objects/contacts.cfg

Change the email address field to receive the alerts.

define contact{
        contact_name                    nagiosadmin             ; Short name of user
        use                             generic-contact         ; Inherit default values from generic-contact template (defined above)
        alias                           Nagios Admin            ; Full name of user

        email                           nagios@holhol24.com      ; 


Install Nagios Web Interface

Install the Nagios web interface with the below command

sudo make install-webconf

Create a user account (nagiosadmin) to access the Nagios web interface. Remember the password you assign to this account – you will need it later.

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

Run the following command.

sudo a2enmod cgi

Restart Apache webserver.

sudo systemctl restart apache2

Install Nagios Plugins

Download the Nagios plugins for monitoring the system services. Place it into /tmp directory.

cd /tmp

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

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

cd /tmp/nagios-plugins-2.3.3/

Compile and install the plugins.

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

sudo make

sudo make install

Start Nagios

Verify the sample Nagios configuration files before starting it.

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

Nagios Core 4.4.5
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 2019-08-20
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

Enable Nagios service to start automatically at system startup.

sudo systemctl enable nagios

Now, start the Nagios service.

sudo systemctl start nagios

Access Nagios Web Interface

Now access the Nagios web interface by going following URL in your
web browser.

http://ip-add-re-ss/nagios/

Enter the username (nagiosadmin) and password you specified earlier.

Nagios Login

Upon successful login, you would get the Nagios’s home page.

Nagios Tool Home Page How To Install Nagios On Ubuntu 20.04 | Holhol24 How To Install Nagios On Ubuntu 20.04 | Holhol24 1605833823 321 How To Install Nagios On Ubuntu 2004 Holhol24
Nagios Tool Home Page

Click on Hosts to see the servers that are being monitored.

By default, Nagios can monitor only the localhost, i.e., Nagios server. So, if you want to monitor remote machines, then you need to use the NRPE plugin on the remote hosts.

READ:
How To Monitot Remote Linux Host With Nagios

Hosts Monitored By Nagios How To Install Nagios On Ubuntu 20.04 | Holhol24 How To Install Nagios On Ubuntu 20.04 | Holhol24 1605833823 482 How To Install Nagios On Ubuntu 2004 Holhol24
Hosts Monitored By Nagios

Clicking on Services in the left pane to services being monitored by Nagios.

Services Monitored By Nagios How To Install Nagios On Ubuntu 20.04 | Holhol24 How To Install Nagios On Ubuntu 20.04 | Holhol24 1605833823 413 How To Install Nagios On Ubuntu 2004 Holhol24
Services Monitored By Nagios

Conclusion

That’s All. I hope, by now, you have
Nagios up and running on your
Ubuntu 20.04. You might want to read
how to monitor remote Linux machines with the NRPE plugin. Please share your feedback in the comments section.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More