Nagios is one of the most popular Open Source application being used for the purpose of IT Infrastructure and Network Monitoring. Basically, this tool is available in two editions, namely, Nagios Core edition which is Open Source and absolutely free to download and Nagios XI edition that has to be purchased by the user. Of course, Nagios XI will have additional features as compared to Nagios Core, but when configured with additional open source plugins and softwares, Nagios Core can provide you with similar or exact results as those in Nagios XI. But, using open source tools is always preferred by most of the users.
So, this article we guide you to install Nagios Core 4 on your Ubuntu System. The upcoming commands are tested on Ubuntu 13.04 and you will see the screenshots of the same.
He we begin!
1. Install the Necessary Packages
First of all, login as the Superuser, update the packages and then install the dependencies required by Nagios.
2. Create a User and a Group
sudo su - apt-get update apt-get install wget build-essential apache2 php5 openssl perl make php5-gd wget libgd2-xpm libgd2-xpm-dev libapache2-mod-php5 libperl-dev libssl-dev daemon
We are going to create a user 'nagios' using
useraddcommand and a group 'naggrp' using
groupaddcommand, then add the user 'nagios' to the group 'naggrp'.
3. Download the Nagios Core 4 Package
sudo useradd nagios sudo groupadd naggrp sudo usermod -a -G naggrp nagios
4. Unarchive the Tarball
sudo wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.0.2.tar.gz
5. Compile the Source Code
sudo tar -xvzf nagios-4.0.2.tar.gz
cd nagios-4.0.2/ ./configure --with-command-group=naggrp
6. Install the Programs
7. Copy the 'eventhandlers' directory
8. Create a User 'nagiosadmin'
cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/ chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers
htpasswd -cm /usr/local/nagios/etc/htpasswd.users nagiosadmin
9. Restart the Apache2 Service
10. Start the Nagios Service
service apache2 restart OR /etc/init.d/apache2 restart
If you try starting the nagios service at this stage, you will be faced with an error as follows:
sudo /etc/init.d/nagios start /etc/init.d/nagios: 20: .: Can't open /etc/rc.d/init.d/functions
The reason behind this is the init script. As a remedy, we create a file 'nagios.conf' in the
/etc/init/directory and edit it as follows:
Now, start the nagios service and it should work smoothly.
description "nagios 4.x core" start on filesystems stop on runlevel  respawn setuid nagios setgid naggrp console log script exec /usr/local/nagios/bin/nagios /usr/local/nagios/etc/nagios.cfg end script
sudo /etc/init.d/nagios start
11. Nagios Apache Configuration
12. Check the Nagios Configuration
cp /etc/apache2/conf.d/nagios.conf /etc/apache2/sites-available/nagios ln -s /etc/apache2/sites-available/nagios /etc/apache2/sites-enabled/nagios
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
13. The Last Touch
sudo /etc/init.d/nagios start
If you click 'Services' on the left side, at this point of time, you will meet following situation, indicating that you will have to install Nagios Plugins in order to proceed. How to do that? We will see in the upcoming tutorial.
That's all for now !