For those of you who didn’t know, Nagios is an open source software that can be used for network and infrastructure monitoring. Nagios will monitor servers, switches, applications and services. It alerts the System Administrator when something went wrong and also alerts back when the issues has been rectified. Resources that can be monitored include CPU, memory and disk space loads, log files, temperature or hardware errors. It can monitor various parameters and problems for services like HTTP, SMTP, DNS, and with the help of plugins it can be highly extended. Nagios Core was originally designed to run under Linux, although it should work under most other unices as well.
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. I will show you through the step by step installation Nagios in ubuntu 14.04 server.
Install Nagios on Ubuntu 14.04
Step 1. Install the dependencies for Nagios.
apt-get install build-essential apache2 php5 openssl perl make php5-gd libgd2-xpm-dev libapache2-mod-php5 libperl-dev libssl-dev daemon wget apache2-utils
Step 2. Create users and groups for Nagios.
usermod -a -G nagcmd nagios
usermod -a -G nagcmd www-data
Step 3. Install Nagios service and Nagios plugins.
Download latest Nagios source code from official site:
tar xzf nagios-4.0.10.tar.gz
Download latest nagios-plugins source and install using following commands:
tar xzf nagios-plugins-2.0.3.tar.gz
./configure --with-nagios-user=nagios --with-nagios-group=nagios
Step 4. Configure Nagios.
Edit the /usr/local/nagios/etc/objects/contacts.cfg config file with your favorite editor and change the email address associated with the nagiosadmin contact definition to the address you’d like to use for receiving alerts.
Change the email address field to receive the notification:
contact_name nagiosadmin ; Short name of userus
generic-contact ; Inherit default values from generic-contact template (defined above)
alias Nagios Admin ; Full name of useremail
email@example.com ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
Step 5. Configure Apache authentication.
We need to setup the password for the user nagiosadmin. This username will be used to access the web interface so it is important to remember the password that you will input here. Set the password running the following command and enter the password twice:
# sudo htpasswd -s -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Re-type new password:
Adding password for user nagiosadmin
Enable Apache’s rewrite and cgi modules:
sudo a2enmod rewrite
sudo a2enmod cgi
Step 6. 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 /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
And you should get the output:
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
Step 7. Start the apache and nagios service.
Step 8. Access Nagios from web browser.
Nagios creates its own apache configuration file /etc/httpd/conf.d/nagios.conf. There are no need to make any changes to it. Simply open url in browser http://nagios-server-ip/nagios.
When prompted for username and password you will introduce the username “nagiosadmin” and the password that you entered in step 5. In case you forget this password you can modify it by rerunning the htpasswd command in step 5.
Congratulation’s! You have successfully installed nagios. Thanks for using this tutorial for installting nagios on ubuntu 14.04 systems.