I-install Apache, PHP and some needed Libraries
First we will install Apache, PHP and needed librairies
- Install some necessary compilers using the command:
sudo apt-get install build-essential
- Install GD libraries using the command:
sudo apt-get install libgd2-xpm-dev
sudo apt-get install apache2
- Install PHP for Apache 2:
sudo apt-get install php5-common php5 libapache2-mod-php5
Now configure Apache to use PHP:
Open apache2.conf File
sudo vi /etc/apache2/apache2.conf
And add this line
DirectoryIndex index.html index.php index.cgi
Now restart your Apache
sudo /etc/init.d/apache2 restart
II-install and configure Nagios:
Now lets install and configure Nagios
First download the latest Core Nagios from Nagios website and before installing create a user to run the service and a group to run external commands:
* sudo useradd -m nagios * sudo passwd nagios * sudo groupadd nagcmd * sudo usermod -a -G nagcmd nagios * sudo usermod -a -G nagcmd www-data
Now install the Nagios tarbils that were downloaded previusly:
tar -zxvf nagios-3.2.1.tar.gz
Then CD the extracted folder and install
cd nagios-3.2.1sudo ./configure --with-command-group=nagcmdsudo make allsudo make installsudo make install-initsudo make install-configsudo make install-commandmodesudo make install-webconf
Add a user for the Nagios interface:
sudo mkdir /usr/local/nagios/etc
Create a new password
sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Output
New password:
Re-type new password:
Pirat9 @ pirat9-desktop :~ /Downloads/nagios-3.2.1 $
Now add Nagios directory to Apache, first open Apache. conf:
sudo vi /etc/apache2/apache.conf
And add these lines:
ScriptAlias/Nagios/cgi-bin/usr/local/Nagios/sbin
<Directory "/usr/local/Nagios/sbin">
Options execcgi
AllowOverride none
Order allow, deny
Allow from all
Authtype basic
Authuserfile/usr/local/Nagios/etc/htpasswd. Users
Require valid-user
</Directory>
Alias/Nagios/usr/local/Nagios/share
<Directory "/usr/local/Nagios/share">
Options none
AllowOverride none
Order allow, deny
Allow from all
Authtype basic
Authuserfile/usr/local/Nagios/etc/htpasswd. Users
Require valid-user
</Directory>
Save and exit then restart apache2
sudo /etc/init.d/apache2 restart
Install Nagios plugins:
- Now we have to install Nagios plugins, first download the file from Nagios website, then extract it using the command:
tar -zxvf nagios-plugins-1.4.14.tar.gz
- CD the extracted folder and install the plugins
cd nagios-plugins-1.4.14 sudo ./configure --with-nagios-user=nagios --with-nagios-group=nagiossudo make sudo make install
- Create a link to start the service:
sudo ln -s /etc/init.d/nagios /etc/rcS.d/S99nagiosls -altr
Output
Total 20
-RW-r-1 Root 447 readme
Lrwxrwxrwx 1 Root 20 2010-04-04 S70x11-common-> ../init. d/x11-common
Lrwxrwxrwx 1 Root 24 2010-04-04 S70screen-cleanup-> ../init. d/screen-cleanup
Lrwxrwxrwx 1 Root 17 2010-04-04 s55urandom-> ../init. d/urandom
Lrwxrwxrwx 1 Root 23 2010-04-04 S49console-setup->.../init. d/console-Setup
Lrwxrwxrwx 1 Root 18 2010-04-04 s37apparmor->.../init. d/apparmor
Lrwxrwxrwx 1 Root 16 2010-04-04 s25brltty->.../init. d/brltty
Lrwxrwxrwx 1 Root 21 2010-04-04 s13pcmciautils->.../init. d/pcmciautils
Lrwxrwxrwx 1 Root 24 2010-04-04 S06keyboard-setup-> ../init. d/keyboard-Setup
Drwxr-XR-x 132 Root 12288 2010-04-15 ..
Lrwxrwxrwx 1 Root 18 2010-04-15 s99nagios->/etc/init. d/Nagios
Drwxr-XR-x 2 root Root 4096 2010-04-15.
Please before running the configuration check and copy all config files from your Nagios directory to/usr/local/Nagios/etc/objects/and/usr/local/Nagios/etc/
Like
Config File '/usr/local/Nagios/etc/objects/commands. cfg '...
Object Config File '/usr/local/Nagios/etc/objects/contacts. cfg '...
Object Config File '/usr/local/Nagios/etc/objects/timeperiods. cfg '...
Object Config File '/usr/local/Nagios/etc/objects/templates. cfg '...
Object Config File '/usr/local/Nagios/etc/objects/localhost. cfg '...
sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Output:
Nagios core 3.2.1
Copyright (c) 2009-2010 Nagios core development team and community contributors
Copyright (c) 1999-2009 Ethan galstad
Last modified: 03-09-2010
License: GPL
Web: http://www.nagios.org
Reading configuration data...
Read main config file okay...
Processing object Config File '/usr/local/Nagios/etc/objects/commands. cfg '...
Processing object Config File '/usr/local/Nagios/etc/objects/contacts. cfg '...
Processing object Config File '/usr/local/Nagios/etc/objects/timeperiods. cfg '...
Processing object Config File '/usr/local/Nagios/etc/objects/templates. cfg '...
Processing object Config File '/usr/local/Nagios/etc/objects/localhost. cfg '...
Read object config files okay...
Running pre-flight check on configuration data...
Checking services...
Checked 8 services.
Checking hosts...
Checked 1 hosts.
Checking host groups...
Checked 1 host groups.
Checking Service groups...
Checked 0 service groups.
Checking contacts...
Checked 1 contacts.
Checking contact groups...
Checked 1 contact groups.
Checking Service escalations...
Checked 0 service escalations.
Checking Service dependencies...
Checked 0 service dependencies.
Checking host escalations...
Checked 0 host escalations.
Checking host dependencies...
Checked 0 host dependencies.
Checking commands...
Checked 24 commands.
Checking time periods...
Checked 5 time periods.
Checking for circular paths between hosts...
Checking for circular host and service dependencies...
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
Pirat9 @ pirat9-desktop :~ /Downloads/nagios-3.2.1 $
sudo /etc/init.d/nagios start
- Now you are ready to use Nagios, open your browser and type:
http://hostname/nagios or http://ip/nagios