Skip to content

Learning Nagios (Installation) – 1

October 19, 2011

So, below are the steps in brief that I used to install Nagios on our server:

Step 1:

Add ‘apache’ user and group to install apache tomcat:
useradd apache
groupadd apache

Then, add ‘nagios’ user and ‘nagcmd’ group to install nagios:
useradd -m nagios => Here, the “-m” option creates a home directory at /home/nagios
passwd nagios => set the password
groupadd nagcmd

Then, modify the group nagcmd for the users nagios and apache
usermod -a -G nagcmd nagios => Here, -a -G helps us assign a supplemental group nagcmd to the user nagios. The primary default group is still nagios
usermod -a -G nagcmd apache

Step 2:

Download the apache web server from here.

Install it following the instructions from here.

Step 3:

gunzip -d httpd-2_0_NN.tar.gz
tar xvf httpd-2_0_NN.tar
./configure
make
make install

vi /usr/local/apache2/conf/httpd.conf
Change the user to apache and group to apache
serveradmin – abhartiya@xxx.com
servername – <sip>:80

go to /usr/local/apache2/bin and then do ./apachectl start
go to http://<sip>/ and it should open

Note – you can set a runlevel on the httpd service so that it starts on booting up. Some kind of script will have to go in /etc/rc.d/init.d

Step 4:

After installing apache, we need to install nagios. For this, transfer both the nagios and the nagios plugins folder onto the box which you want to set up as the main server.
go to that folder /path/to-nagios/folder and run
./configure –with-command-group=nagcmd
make all
make install
make install-init
make install-config
make install-commandmode

change the email address of the admin at /usr/local/nagios/etc/objects/contacts.cfg to abhartiya@xxx.com

Step 5:

we need to make sure that the nagios ui is only accessed by the admin and its secure so for that, we need to vi /usr/local/apache2/conf/httpd.conf and add the below towards the end:

ScriptAlias /nagios/cgi-bin “/usr/local/nagios/sbin”
# SSLRequireSSL
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
# Order deny,allow
# Deny from all
# Allow from 127.0.0.1
AuthName “Nagios Access”
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user

Alias /nagios “/usr/local/nagios/share”
# SSLRequireSSL
Options All
AllowOverride None
Order allow,deny
Allow from all
# Order deny,allow
# Deny from all
# Allow from 127.0.0.1
AuthName “Nagios Access”
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
SetHandler application/x-httpd-php

Step 6:

Go to /usr/local/apache2/bin and type in the following:
./htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin => set the password here

Restart the apache server
/usr/local/apache2/bin/httpd -k restart

Step 7:

Now, we need to install the nagios plugins:
go to the folder where you put the nagios plugin folder and run ./configure –with-command-group=nagcmd
make all
make install
chkconfig –add nagios
chkconfig nagios on
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
service nagios start

Also set the following:
getenforce
setenforce 0

Step 8:

We also need to install PHP if its not already installed. Please follow the instructions here.

Advertisements

From → Monitoring

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: