In this article, we will have explained the necessary steps to install and set up Nagios on Debian 10. Before continuing with this tutorial, make sure you are logged in as a user with sudo
privileges. All the commands in this tutorial should be run as a non-root user.
Nagios is an open-source tool that gives an enterprise-class central monitoring engine regarding IT monitoring, network monitoring, server in addition to applications monitoring. It also provides the web interface for viewing current position, historical logs, and basic reports.
Install Nagios on Debian 10
Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.
sudo apt update sudo apt upgrade sudo apt install build-essential unzip openssl libssl-dev apache2 php libapache2-mod-php php-gd libgd-dev
Step 2. Create User And Group for Nagios.
Now create a dedicated Nagios user and group:
sudo make install-groups-users sudo usermod -a -G nagios www-data
Step 3. Install Nagios on the Debian system.
Go to the official website for downloading the latest version of Nagios Core:
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/
Then, 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 4. Configure Nagios.
Now edit /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 }
Step 5. Configure Nagios Web Interface.
Now create a user nagiosadmin
account for logging into the Nagios web interface:
sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Restart Apache web service to make the new settings take effect:
sudo a2enmod cgi sudo systemctl restart apache2
Step 5. Install Nagios Plugins.
Download and install Nagios plugins using the following commands:
cd /tmp wget https://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz tar -zxvf /tmp/nagios-plugins-2.2.1.tar.gz cd /tmp/nagios-plugins-2.2.1/
Then, compile and install the plugins:
sudo ./configure --with-nagios-user=nagios --with-nagios-group=nagios sudo make sudo make install
Once done, start Nagios monitoring tool using the following command:
sudo systemctl start nagios sudo systemctl enable nagios sudo systemctl status nagios
Step 6. Configure Firewall.
In case you have a firewall running, please allow the necessary ports:
sudo ufw allow 80/tcp sudo ufw reload sudo ufw enable
Step 7. Access Nagios Web Interface.
Now access the Nagios web interface by going following URL in your web browser:
http://your-ip-address/nagios/
That’s all you need to do to install the Nagios on Debian 10 Buster. I hope you find this quick tip helpful. For further reading on Nagios monitoring tools, please refer to their official knowledge base. If you have questions or suggestions, feel free to leave a comment below.