Shashikant shah

Wednesday 29 August 2012

Monitoring Tool NAGIOS



                             NAGIOS Configuration


Firewall and SElinux is Disable

Server IP :- 192.168.0.10
Hostname :- shashi.example.com

Client IP :- 192.168.0.11
Hostname :- client.example.com

1.Package Requirement :-

# yum install httpd php
# yum install gcc glibc glibc-common
# yum install gd gd-devel

2.Create Nagios user and group :-

# useradd -m nagios
# passwd nagios
# usermod -G nagios  nagios
# groupadd nagcmd
# usermod -a -G nagcmd nagios
# usermod -a -G nagcmd apache

3.Download Some Package :-

# mkdir /opt/shashi/

# cd /opt/shashi

3.2.3.tar.gz

plugins-1.4.11.tar.gz

# tar xvf nagios-3.2.3.tar.gz

# cd nagios-3.2.3

# ./configure --with-command-group=nagcmd

# make all

# make install

# make install-init

# make install-config

# make install-commandmode

# make install-webconf

 4.vim /usr/local/nagios/etc/objects/contacts.cfg

35: change ---> email youadmin-mail-ID

6.Give the password web nagiosadmin user
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
New password :
Re-type new password :

Note:- If you want to change admin “nagiosadmin” name change all in “/usr/local/nagios/etc/cgi.cfg” file too.

7. Go to this Path :-

# cd /opt/shashi

# tar xvf nagios-plugin-1.4.11.tar.gz

# cd nagios-plugin-1.4.11

# ./configure - - with-nagios-user=nagios - - with-nagios-group=nagios

# make

# make install

# chkconfig - - add nagios

# chkconfig nagios on

# /etc/init.d/nagios start

# /etc/init.d/nagios restart

# chkconfig nagios on

# /etc/init.d/httpd restart

#chkconfig httpd on

# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg (check nagios)

Total warnings: 0
Total Errors: 0
Things look okay – No serious problems

8.Login to web interface :-


username :- nagiosadmin
passwd :- *******



9.Package Requirement :-

# yum install openssl-devel xinetd

# cd /opt/shashi

2.x/nrpe-2.13/nrpe-2.13.tar.gz/download

# tar xvf nrpe-2.13.tar.gz

# cd nrpe

# ./configure

General Options:

-------------------------

NRPE port:5666

NRPE user:nagios

NRPE group:nagios

Nagios user: nagios

Nagios group: nagios


# make all

# make install-plugin

# make install-daemon

# make install-daemon-config

# make install-xinetd


10.Enter the following entry :-

# vim /etc/xinetd.d/nrpe



only_from = 127.0.0.1 192.168.0.10 (nagios_ip_address
)

11.Now, add entry for nrpe daemon to /etc/services file :-

# vim /etc/services

nrpe 5666/tcp # NRPE

# service xinetd restart


# chkconfig xinetd on

12.Test NRPE Daemon Install :-

# netstat -at |grep nrpe
Output should be :

tcp 0 0 *:nrpe *.* LISTEN

13.Check NRPE Service :-

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

Output should be NRPE version:


NRPE v2.12



-: CLIENT SETUP :-

1.Package Requirement :-

# yum install openssl-devel xinetd

# yum install httpd php

# yum install gcc glibc glibc-common

# yum install gd gd-devel

2.Create Nagios user and group :-

# useradd -m nagios
# passwd nagios
# usermod -G nagios  nagios
# groupadd nagcmd
# usermod -a -G nagcmd nagios
# usermod -a -G nagcmd apache

3.Create a Directary shashi :-

# mkdir /opt/shashi

# cd /opt/shashi

# wget http://sourceforge.net/projects/nagios/files/nrpe-2.x/nrpe-2.13/nrpe-2.13.tar.gz/download


# tar -xvf nrpe-2.13.tar.gz
# cd nrpe

# ./configure

General Options:

-------------------------

NRPE port: 5666
NRPE user: nagios
NRPE group: nagios
Nagios user: nagios
Nagios group: nagios

# make all

# make install-plugin

# make install-daemon

# make install-daemon-config

# make install-xinetd

Enter the following entry in :-

# vim /etc/xinetd.d/nrpe


only_from = 127.0.0.1 <192.168.0.10>(nagios_ip_address)





4.Now, add entry for nrpe daemon to /etc/services file

# vim /etc/services

nrpe 5666/tcp # NRPE

# service xinetd start

# service xinetd restart


# chkconfig xinetd on

5.Test NRPE Daemon Install

# netstat -at |grep nrpe

Output should be:
tcp 0 0 *:nrpe *.* LISTEN

This command run by SERVER SIDE :-

# /usr/local/nagios/libexec/check_nrpe -H 192.168.0.11 (client IP)

NRPE v2.12

# cd /opt/shashi


# tar xvf nagios-plugins-1.4.11.tar.gz

# cd nagios-plugins-1.4.11

# ./configure --with-nagios-user=nagios --with-nagios-group=nagios

# make

# make install

# chkconfig --add nagios

# chkconfig nagios on

# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Total Warnings: 0

Total Errors: 0
Things look okay - No serious problems were detected during the pre-flight check

6.All Plugin :-

# cd /usr/local/nagios/libexec

# cp check_http check_tomcat
# cp check_http check_jboss

GO TO SERVER SIDE :-

# vim /usr/local/nagios/etc/nagios.cfg

>Definitions for monitoring the local (Linux) host

cfg_file=/usr/local/nagios/etc/objects/localhost.cfg (add line)

cfg_file=/usr/local/nagios/etc/objects/client.cfg (add line)

# vim /usr/local/nagios/etc/objects/client.cfg


define host {

name client ; Name of this template

use generic-host ; Inherit default values

check_period 24x7

check_interval 5

retry_interval 1

max_check_attempts 10

check_command check-host-alive

notification_period 24x7

notification_interval 30

notification_options d,r

contact_groups admins
register 0 ; DONT REGISTER THIS - ITS A TEMPLATE

}

define host {

use client ; Inherit default values from a template

host_name client ; The name we're giving to this server

alias client ; A longer name for the server

address 192.168.0.11 ; IP address of the server
}
define service {

use local-service

host_name client

service_description PING

check_command check_ping!100.0,20%!500.0,60%
}


define service {

use local-service ; Name of service template to use

host_name client

service_description Disk Space

check_command check_disk!20%!10%!/
}


define service {

use local-service ; Name of service template to use

host_name client

service_description Total Processes

check_command check_local_procs!150!300!RSZDT

}

define service {

use local-service ; Name of service template to use

host_name client

service_description HTTP

check_command check_http

notification_interval 0 ; set > 0 if you want to be renotified

}



define service {

use local-service

host_name client

service_description MySQL connection-time

check_command check_mysql_health!root!XXXX!connection-time

notifications_enabled 1
}


#define service {

use local-service

host_name client

service_description Tomcat

check_command check_tomcat
}

define service {

use local-service

host_name client

service_description Jboss

check_command check_jboss
}


define service {

use local-service

host_name client

service_description SSH

check_command check_ssh
}


define service {
use local-service ; Name of service template to use

host_name client

service_description Current Users

check_command check_local_users!20!50
}



# vim /usr/local/nagios/etc/objects/command.cfg


################################################################################

# NOTE: The following 'check_...' commands are used to monitor services on

# both local and remote hosts.

################################################################################



# 'check_load' command definition

define command {

command_name check_procs

command_line $USER1$/check_procs -w $ARG1$ -c $ARG2$ -s $ARG3$
}


# 'check_ftp' command definition

define command {

command_name check_ftp

command_line $USER1$/check_ftp -H $HOSTADDRESS$ $ARG1$
}

# 'check_http' command definition

define command {

command_name check_http

command_line $USER1$/check_http -H $HOSTADDRESS$ -w 10 -c 20
}
# 'check_ssh' command definition

define command {

command_name check_ssh

command_line $USER1$/check_ssh $ARG1$ $HOSTADDRESS$
}


# 'check_ping' command definition

define command {

command_name check_ping

command_line $USER1$/check_ping -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ -p 5
}


# 'check_remote_users' command definition

define command {

command_name check_remote_users

command_line $USER1$/check_users -w $ARG1$ -c $ARG2$
}

# 'check_disk' command defintion

define command {

command_name check_disk

command_line $USER1$/check_disk -w 20% -c 10% -p /dev/sda1
}

# 'check_mysql'comman definition

define command {

command_name check_mysql_health

command_line $USER1$/check_mysql_health -H $HOSTADDRESS$ --user $ARG1$
--password $ARG2$ --mode $ARG3$
}

# 'check_tomcat'comman definition

define command {

command_name check_tomcat

command_line $USER1$/check_tomcat -H $HOSTADDRESS$ -p 8080 -w 4 -c 5
}

#'check_jboss'command definition

define command{

command_name check_jboss

command_line $USER1$/check_jboss -H $HOSTADDRESS$ -p 4444 -w 4 -c 5
}



Check Configuration :-

# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg



# /etc/init.d/nagios restart

######################### Now Enjoy Working with Nagios ###########################

No comments:

Post a Comment