Nagios is a powerful monitoring system that enables organizations to identify and resolve IT infrastructure problems before they affect critical business processes. It monitors your entire IT infrastructure to ensure systems, applications, services, and business processes are functioning properly. In the event of a failure, Nagios can alert the technical staff of the problem, allowing them to begin remediation processes before outages affect business processes, end-users, or customers.
Nagios® Core™ is an Open Source system and network monitoring application. It watches hosts and services that you specify, alerting you when things go bad and when they get better.
If you would wish to install Nagios Core on Debian 10, the following steps will help you rev it up in a few minutes.
Step 1: Update your System
Run the command below to update your server so that we begin from latest software installed
sudo apt update
If it is a totally new server, follow this guide to update your apt sources file (/etc/apt/sources.list)
Step 2: Install the required packages
The following step will install the pre-requisite 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: Fetch and extract Nagios 4.4.5 Files
We now have to go to the Nagios downloads page to grab the latest release.
cd ~
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.5.tar.gz
Extract the tarball
tar xvzf nagios-4.4.5.tar.gz
Step 4: Compile the extracted files
After Nagios core files have been successfully extracted, navigate into the new directory holding the files and begin the compilation process.
cd nagios-4.4.5/
./configure --with-httpd-conf=/etc/apache2/sites-enabled
You should see the following when the above command ends.
*** 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 User And Group
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
Now let us compile the main Nagios program and associated packages
sudo make all
Install the main program, CGIs, and HTML files
sudo make install
Step 6: Install Daemon
This installs Nagios daemon files and also configures them to start when the system boots.
sudo make install-daemoninit
Step 7: Add Command Mode
This installs and configures the external command file.
sudo make install-commandmode
Step 8: Install Configuration Files
In this step, we install SAMPLE configuration files required as Nagios needs some configuration files to allow it to start.
sudo make install-config
Step 9: Apache Webserver Configuration
We have to configure our Apache to serve Nagios web pages. Nagios developers made it easier to set up Apache. You simply run one command to set up configuration files and then enable specific apache modules. Proceed as below.
This will install config files
sudo make install-webconf
This enables 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 rises to the occasion for this task. Please note that Nagios uses “nagiosadmin” user by default. Run the command below and input your favorable password.
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 essential Nagios Plugins
Before we finish up setting up our Nagios core monitoring, we need Nagios Plugins that will help us accomplish a lot of stuff including monitoring the localhost. We will thus fetch the latest stable release of plugins, extract and install it in our system. You can find the plugins at Nagios Plugins. Follow along
Fetch and extract the 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 into 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
In case you have a firewall running, please 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 into Nagios Web Interface
After everything has been done well without any errors, let us open up our browser and get to see if the Nagios web interface is accessible. Open your browser and key in the IP of your server or its domain name if you had configured one and the root directory of Nagios.
http:///nagios
You will be prompted for a username and password. The username as you may remember is the one we set in Step 10, that is “nagiosadmin“
If you click on the “Hosts” link, you should see that the localhost is up and hence being monitored thanks to the plugins we installed earlier.
We hope this session was as informative and helpful as possible and we thank you for visiting. You make it all worthwhile. In case you are interested in other monitoring tools, the guides below will be great for you as well.
How to Install Sensu Monitoring Tool on Ubuntu 18.04 LTS
Install LibreNMS Monitoring Tool on CentOS with Letsencrypt and Nginx
How To Install Icinga2 Monitoring Tool on Ubuntu 18.04 LTS
Install Cacti Monitoring Server on Debian 10 (Buster) with Nginx
Install and Configure Zabbix Server 4.4 on Debian 10 (Buster)
How To Install Zabbix Agent on Debian 10 (Buster)