How To Install Nagios on Debian 10 / Debian 9

Install Nagios on Debian 10
Install Nagios on Debian 10

Nagios is an open source monitoring tool for servers, network devices, and applications. It helps you to monitor the services, resources, and applications that run on Windows as well as on Linux. Nagios also can monitor routers and other network devices.

Nagios has an inbuilt web interface where we can access and monitor the whole infrastructure at a single location. You have to work on the file level (configuration file) as you can not customize or adjust the monitoring parameters over the web interface.

Services List

With the Nagios, you can monitor private services and attributes of Linux/UNIX servers, such as:


  • CPU load
  • Memory usage
  • Disk usage
  • Logged in users
  • Running processes
  • etc.

Private Services

  • HTTP
  • FTP
  • SSH
  • SMTP
  • etc

In this post, we will see how to install Nagios on Debian 10 / Debian 9 and how to monitor application services with Nagios plugins.


Install Nagios on Debian 10 / Debian 9


Before compiling Nagios from the source, you need to install dependent packages for the Nagios monitoring tool.

Update the repository cache index and install the dependencies for Nagios.

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

Create a user for allowing the external commands to be executed through the web interface.

user: nagios

group: nagcmd

Also, add nagios and apache user (www-data) to the part of the nagcmd group.

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

Visit the official website for downloading the latest version of Nagios Core.

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

Use the below steps to 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

Configure Nagios

The installer has now placed configuration files in the /usr/local/nagios/etc directory. You don’t need to modify Nagios configuration files for now to start the Nagios monitoring tool.

All you need is to update 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

Change to the email address of your choice to receive the notification.

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                           [email protected]      ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******

Configure Nagios Web Interface

Create a user nagiosadmin account for logging into the Nagios web interface. Remember the password you assign to user nagiosadmin – you’ll need it later.

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

To enable CGI, run:

sudo a2enmod cgi

Restart Apache web service to make the new settings take effect.

sudo systemctl restart apache2

Install Nagios Plugins

Now, it’s time to download and install Nagios plugins for monitoring the services.

cd /tmp
tar -zxvf /tmp/nagios-plugins-2.2.1.tar.gz
cd /tmp/nagios-plugins-2.2.1/

Compile and install the plugins.

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

Start Nagios Server

Verify the sample Nagios configuration files.

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


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
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 Nagios monitoring tool using the following command.

sudo systemctl start nagios

Enable Nagios to start automatically at the system startup.

sudo systemctl enable nagios

Check the status of Nagios service with the below command.

sudo systemctl status nagios
Nagios Service Status
Nagios Service Status


Configure the firewall so that the Nagios Web Interface can be accessible from external machines.


sudo firewall-cmd --permanent --add-port=80/tcp
sudo firewall-cmd --reload
sudo systemctl restart firewalld


sudo ufw allow 80/tcp
sudo ufw reload
sudo ufw enable

Access Nagios Web Interface

Now, go and access the Nagios web interface using the below URL.


The browser will prompt you to enter the username nagiosadmin and the password you specified earlier.

Login To Nagios
Login To Nagios

You will get the Nagios page.

Nagios Home Page
Nagios Home Page

Click the Hosts link in the left pane to see the hosts being monitored by Nagios.

Hosts List
Hosts List

Click the Services link in the left pane to see the services being monitored by Nagios.

Monitoring Services With Nagios
Monitoring Services With Nagios

By default, Nagios can monitor the only localhost, i.e., Nagios server. If you want to monitor remote machines, you need to install and configure the NRPE plugin.

READ: How To Monitor Linux Machines With Nagios Monitoring Using NRPE Plugin


That’s All. I hope this post helped you. Post your valuable comments below.

You might also like