Install and configure Nagios on Debian 10 (Buster)

Foreword

Nagios is a powerful monitoring system that allows organizations to identify and resolve IT infrastructure issues before they impact critical business processes. It monitors the entire IT infrastructure to ensure that systems, applications, services, and business processes function properly. In the event of a failure, Nagios can alert technicians to the problem so they can begin the remediation process before the failure affects business processes, end users or customers.

Nagios®Core ™ is an open source system and network monitoring application. It monitors the hosts and services you specify and alerts you when things get worse or better.

If you want to install Nagios Core on Debian 10, the following steps will help you upgrade it in minutes.

Step 1: Update the system

Run the following command to update your server so we start with the latest software installed

sudo apt update

If it’s a brand new server, follow this guide to update your apt source file (/etc/apt/sources.list)

Step 2: Install required packages

The next step is to install the prerequisite packages that Nagios Core needs to run. Please proceed to install them.

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

Step 3: Extract and extract Nagios 4.4.5 files

We must go now Nagios download Page for the latest version.

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

Extract the compressed package

tar xvzf nagios-4.4.5.tar.gz

Step 4: Compile the extracted files

After successfully extracting the Nagios core files, navigate to the new directory containing the files and begin the compilation process.

cd nagios-4.4.5/
./configure --with-httpd-conf=/etc/apache2/sites-enabled

When the above command ends, you should see the following.

*** Configuration summary for nagios 4.4.5 2019-08-20 ***:
 General Options:
 
     Nagios executable:  nagios     Nagios user/group:  nagios,nagios    Command user/group:  nagios,nagios          Event Broker:  yes     Install ${prefix}:  /usr/local/nagios Install ${includedir}:  /usr/local/nagios/include/nagios             Lock file:  /run/nagios.lock
 Check result directory:  /usr/local/nagios/var/spool/checkresults
            Init directory:  /lib/systemd/system
   Apache conf.d directory:  /etc/apache2/sites-enabled
              Mail program:  /bin/mail
                   Host OS:  linux-gnu
           IOBroker Method:  epoll
 Web Interface Options:
 
              HTML URL:  http://localhost/nagios/               CGI URL:  http://localhost/nagios/cgi-bin/
 Traceroute (used by WAP):  /usr/bin/traceroute

Step 5: Create users and groups

This step ensures that “nagios” users and groups are created. www data users have also been added to the “nagios” group.

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

Now let’s compile the main Nagios programs and related packages

sudo make all

Install the main program, CGI and HTML files

sudo make install

Step 6: Install the daemon

This will install the Nagios daemon files and configure them to start when the system boots.

sudo make install-daemoninit

Step 7: Add command mode

This will install and configure the external command file.

sudo make install-commandmode

Step 8: Install the configuration file

In this step, we will install the required SAMPLE configuration file because Nagios needs some configuration files to launch it.

sudo make install-config

Step 9: Apache web server configuration

We must configure Apache to serve Nagios web pages. Nagios developers make setting up Apache easier. You just need to run a command to set up a configuration file and then enable a specific apache module. Proceed as follows.

This will install the configuration file

sudo make install-webconf

This will enable Apache rewrite and CGI modules

sudo a2enmod rewrite cgi

Step 10: Configure Nagios Apache authentication

In order to create Nagios web authentication, you need to create a web user for authentication. The “htpasswd” command performs this task. Please note that Nagios uses the “nagiosadmin” user by default. Run the following command and enter the password you want.

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

After that, give appropriate permissions to the (/usr/local/nagios/etc/htpasswd.users) file.

sudo chown www-data:www-data /usr/local/nagios/etc/htpasswd.users
sudo chmod 640 /usr/local/nagios/etc/htpasswd.users

Step 11: Install the basic Nagios plugin

Before we finish setting up Nagios core monitoring, we need Nagios plugins, which will help us with a lot of work, including monitoring localhost. Therefore, we will get the latest stable version of the plugin, extract it and install it into our system. You can find plugins at Nagios plugin. Followed

Extract and extract plugins

Navigate to your home directory
cd ~
wget https://nagios-plugins.org/download/nagios-plugins-2.3.2.tar.gz

tar xvzf nagios-plugins-2.3.2.tar.gz

Navigate to the new plugins folder, then compile and install.

cd nagios-plugins-2.3.2/
./configure --with-nagios-user=nagios --with-nagios-group=nagios

sudo make
sudo make install

Step 12: Allow ports on the firewall and start Nagios

If you are running a firewall, allow the necessary ports.

sudo ufw allow 80
sudo ufw reload

Start Nagios and Apache services

sudo systemctl restart apache2
sudo systemctl start nagios.service

Step 13: Log in to the Nagios web interface

After everything is working without any errors, let’s open the browser and see if we can access the Nagios web interface. Open a browser and enter the IP or domain name of the server (if one is configured) and the root directory of Nagios.

http:///nagios

You will be prompted for a username and password. The username you may remember is the username we set up in step 10, which is “nagiosadmin

Install and configure Nagios on Debian 10 (Buster)

If you click on the “Hosts” link, you should see that the local host is up and therefore monitored because of the plugin we installed earlier.

Install and configure Nagios on Debian 10 (Buster)

in conclusion

We hope this conference can bring you more information and help, and we thank you for coming. You make it all worthwhile. If you are interested in other monitoring tools, the guide below will also be perfect for you.

How to install Sensu Monitoring Tool on Ubuntu 18.04 LTS

Install LibreNMS monitoring tool on CentOS using Letsencrypt and Nginx

How to install Icinga2 monitoring tool on Ubuntu 18.04 LTS

Install Cacti Monitoring Server on Debian 10 (Buster) using Nginx

Install and configure Zabbix Server 4.4 on Debian 10 (Buster)

How to install Zabbix Agent on Debian 10 (Buster)

How to install Zabbix server on CentOS 8 / RHEL 8

How to install Icinga2 monitoring tool on Ubuntu 18.04 LTS

Sidebar