Nagios is an open source powerful tool to monitor your hosts and services. It easy very easy to configure and use. You can also set email notifications, and SMS notifications and if you can run a little bit Python scripts you can also set WhatsApp notifications. However, WhatsApp notifications are not officially by Nagios but Python script is available for that.
Step 1: You need to install pre-requirement packages first.
# apt install apache2 libapache2-mod-php php
# apt install wget unzip zip autoconf apache2-utils libgd-dev libc6 make gcc
Step 2: Create nagios user and assign the user group to www-data
# useradd nagios
# usermod -a -G nagios www-data
Step 3: Download the latest nagios from the official website.
for example I am using this version.
# wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.6.tar.gz
Step 4: Now extract the downloaded file into your specific folder. You can extract anywhere like /tmp or /opt or /usr/local/src. That’s up to you.
# tar xzf nagios-4.4.6.tar.gz
# cd nagios-4.4.6/
Now, You can see required configuration files in the above folder.
Step 5: Let’s compile the nagios setup
# ./configure --with-httpd-conf=/etc/apache2/sites-enabled
# make all
# make install
# make install-init
# make install-commandmode
# make install-config
# make install-webconfig
Step 6: Now enable and restart the nagios server.
# systemctl start nagios
# systemctl enable nagios
Step 7: Setup password ‘nagiosadmin’ user by using below command.
# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Step 8: Enable cgi modules to access http server to execute nagios cgi scripts.
# a2enmod cgi
# systemctl restart apache2
Step 9: Thats it. Now just start and enable nagios service and you are good to go.
# systemctl start nagios
# systemctl enable nagios
Now you can able to login your nagios server from web browser via this adress http://ipaddress/nagios or http://FQDN/nagios. Login prompt will appear, you need to login with the user ‘nagiosadmin’ and password you setup in earlier steps.
You also need to install Nagios Plugins to proper monitoring. How to install Nagios Plugins.