Monday, December 29, 2008

INSTALLATION AND CONFIGURATION OF NAGIOS

INSTALLATION AND CONFIGURATION OF NAGIOS
---------------------------------------------


1)tar xfvz nagios-1.0b5.tar.gz

2)cd nagios-1.0b5

3)mkdir /usr/local/nagios

4)chown nagios.nagios /usr/local/nagios

5)grep "^User" etc/httpd/conf/httpd.conf

6)/usr/sbin/groupadd nagcmd

7)/usr/sbin/usermod -G nagcmd apache
/usr/sbin/usermod -G nagcmd nagios

8)./configure --prefix=/usr/local/nagios
--with-cgiurl=/nagios/cgi-bin --with-htmurl=/nagios/ --with-nagios-user=nagios
--with-nagios-grp=nagios

9)make all

10)make install

11)make install-init (It creates the daemon script in rc.d)

12)make install-config (Creates the etc directory)

INSTALLATION OF PLUGGINS
-------------------------

1)tar xfvz nagios-pluggins-1.0b5.tar.gz

2)cd nagios-pluggins-1.0b5.tar.gz

3)./configure
--prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios

4)make all

5)make install

6)cd /usr/local/nagios/libexec/

There will be some files in this directory.

7)./check_ssh -h (To check ssh pluggin)

8)cd /usr/local/nagios/etc (All sample files are there remove the sample extension.)Make the necessary changes in the configuration files.

9)Now create the following cfg files

hosts.cfg
----------


# Host Definition

define host{
# Name of host template to use
use generic-host

host_name test-server1
alias subho
address 172.16.0.210
check_command check-host-alive
max_check_attempts 10
contact_groups nagios
notification_interval 120
notification_period 24x7
notification_options d,u,r
}

define host{
# Name of host template to use
use generic-host

host_name localhost.localdomain
alias sss
address 172.16.0.211
check_command check-host-alive
max_check_attempts 10
contact_groups nagios
notification_interval 120
notification_period 24x7
notification_options d,u,r



hostgroups.cfg(This file should not have the contact_groups directive)
----------------

define hostgroup{
hostgroup_name flcd-servers
alias The Free Linux CD Project Servers
members test-server1

contacts.cfg
---------------

define contact{
contact_name nagios
alias Oktay Altunergil
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,u,r
service_notification_commands notify-by-email
host_notification_commands host-notify-by-email
email oktay@localhost.localdomain


contactgroups.cfg
---------------------

define contactgroup{
contactgroup_name nagios
alias FreeLinuxCD.org Admins
members nagios

services.cfg
-------------------

# Service definition
define service{
# Name of service template to use
use generic-service

host_name test-server1
service_description HTTP
is_volatile 0
check_period 24x7
max_check_attempts 3
normal_check_interval 5
retry_check_interval 1
contact_groups nagios
notification_interval 120
notification_period 24x7
notification_options w,u,c,r
check_command check_http
}


# Service definition
define service{
# Name of service template to use
use generic-service

host_name test-server1
service_description PING
is_volatile 0
check_period 24x7
max_check_attempts 3
normal_check_interval 5
retry_check_interval 1
contact_groups nagios
notification_interval 120
notification_period 24x7
notification_options c,r
check_command check_ping!100.0,20%!500.0,60%



Added only two service for monitoring we can add many more.


10)../bin/nagios -v nagios.cfg (For checking the configuration)

11)Running Nagios Manually as a Daemon
/usr/local/nagios/bin/nagios -d
Note that you must specify the path/filename of the main configuration file (i.e.
/usr/local/nagios/etc/nagios.cfg) on the command line.

12)/etc/rc.d/init.d/nagios restart

13)chkconfig nagios on


To start the web interface
-------------------------------
1)Add the following lines in httpd.conf file

ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin/"

Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user


Alias /nagios "/usr/local/nagios/share/"

Options None
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user



2)Issue the following commands

htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

To add more than one user

htpasswd /usr/local/nagios/etc/htpasswd.users


3)# service httpd restart

4)check from the browser

http://172.16.0.211/nagios/index.html

For the REMOTE HOSTS (tO BE INSTALLED ON THE REMOTE HOSTS)
-----------------------------------------------------------

1)Download the NRPE tar ball and unpack it

#tar xzf nrpe-2.8.tar.gz

#cd nrpe-2.8

2)Compile the NRPE addon.

#./configure
# make all

3)Install the NRPE plugin (for testing), daemon, and sample daemon config file.

#make install-plugin
#make install-daemon
#make install-daemon-config

4)Install the NRPE daemon as a service under xinetd.

#make install-xinetd

5)Edit the /etc/xinetd.d/nrpe file and add the IP address of the monitoring server to the only_from directive.

only_from = 127.0.0.1

6)Add the following entry for the NRPE daemon to the /etc/services file.

nrpe 5666/tcp # NRPE

7)Restart the xinetd service.

#service xinetd restart

8)Test the NRPE daemon locally

#netstat -at | grep nrpe

The output out this command should show something like this:

tcp 0 0 *:nrpe *:* LISTEN

9)/usr/local/nagios/libexec/check_nrpe -H localhost

You should get a string back that tells you what version of NRPE is installed, like this:

NRPE v2.8


NRPE PLUGGIN IN THE NAGIOS SERVER
--------------------------------------

1)Extract the NRPE source code tarball.

# tar xzf nrpe-2.8.tar.gz
# cd nrpe-2.8

2)Compile the NRPE addon.

#./configure
# make all

3)Install the NRPE plugin.

# make install-plugin

4) Test communication with the NRPE daemon


Make sure the check_nrpe plugin can talk to the NRPE daemon on the remote host.

#/usr/local/nagios/libexec/check_nrpe -H

You should get a string back that tells you what version of NRPE is installed on the remote host, like this:

NRPE v2.8

No comments:

Post a Comment