DebianLinuxTutorials

How To Install Nagios on Debian 10

Install Nagios on Debian 10

In this tutorial, we will show you how to install Nagios on your Debian 10. For those of you who didn’t know, Nagios will monitor servers, switches, applications, and services. It alerts the System Administrator when something went wrong and also alerts back when the issues have been rectified. Resources that can be monitored include CPU, memory, and disk space loads, log files, temperature, or hardware errors. Nagios also can monitor routers and other network devices.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the Nagios open source monitoring tool on a Debian 10 (Buster) server.

Prerequisites

  • A server running one of the following operating systems: Debian 10 (Buster).
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install Nagios on Debian 10 Buster

Step 1. Before we install any software, it’s important to make sure your system is up to date by running the following apt commands in the terminal:

apt update
apt upgrade

Step 2. Install the LAMP server.

A Debian 10 LAMP server is required. If you do not have LAMP installed, you can follow our guide here.

Step 3. Create users and groups.

This step ensures that “nagios” user and group are created. The www-data user is also added to the “nagios” group:

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

Step 4. Installing Nagios on Debian 10.

Go to the official website for downloading the latest version of Nagios Core, At the moment of writing this article it is version 4.4.6:

cd /tmp/ 
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.6.tar.gz 
tar -zxvf nagios-4.4.6.tar.gz 
cd /tmp/nagios-4.4.6/

After that, compile 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
sudo make install-webconf

Step 5. Configure Nagios.

Now we update the email address in the /usr/local/nagios/etc/objects/contacts.cfg file for nagiosadmin before you start the Nagios server:

sudo nano /usr/local/nagios/etc/objects/contacts.cfg
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@idroot.us        ; <<--- CHANGE THIS TO YOUR EMAIL ADDRESS

        }

Then, create a user nagiosadmin account for logging into the Nagios web interface:

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

Next, enable CGI:

sudo a2enmod cgi
sudo systemctl restart apache2

Step 6. Installing Nagios Plugins.

Now we download and install Nagios plugins for monitoring the services:

cd /tmp
wget http://www.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.2.3/

Then, compile and install the plugins:

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

Step 7. Verify and Start Nagios service.

Next, we have to make Nagios start at boot time, so first verify that the configuration file has no errors running the following command:

sudo systemctl start nagios
sudo systemctl enable nagios

Step 8. Configure the firewall for Nagios.

In case you have a firewall running, please allow the necessary ports:

sudo ufw allow 80
sudo ufw reload
sudo ufw enable

Step 9. Accessing Nagios Web Interface.

Nagios will be available on HTTP port 80 by default. Open your favorite browser and navigate to http://your-domain.com/nagios or http://server-ip-address/nagios and complete the required steps to finish the installation. When prompted for a username and password you will introduce the username “nagiosadmin” and the password that you entered in step 5.

Install Nagios on Debian 10

Congratulations! You have successfully installed Nagios. Thanks for using this tutorial for installing the Nagios monitoring tool in Debian 10 Buster systems. For additional help or useful information, we recommend you to check the official Nagios website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button