Beruflich Dokumente
Kultur Dokumente
EFFECTIVE DATE:11/07/2011
PREPARED BY : Karthikeyan.B
APPROVED BY:
Introduction:
Nagios is a opensource monitoring application used for monitoring systems,servers,routers
and switches in our network.It watches hosts and services, alerting users when thing go wrong and
again when they get better.
Hardware Requirements:
We can install nagios in a normal desktop.Nagios doesn't require higher end
configurations.
Software Requirements:
1) Redhat Linux el5
2) Apache-2.2.19
3) Php-5.3.6
4)gcc, glibc, glibc-common, gd, gd-devel
Dependencies Installation:
Step1:
gcc, glibc, glibc-common, gd, gd-devel is installed default during os installation.If it is
not installed download the rpm and install it using rpm -ivh command.
Step2:(Apache)
cd /usr/local/
Download the apache-2.2.19 source
tar -xvzf apache-2.2.19.tar.gz
cd apache-2.2.19
./configure –prefix=/usr/local/apache2
make
make install
/usr/local/apache2/bin/apachectl start -> starting the service
Step:3(Php)
cd /usr/local
Download the php-5.3.6 source
tar -xvzf php-5.3.6.tar.gz
cd php-5.3.6
./configure –prefix=/usr/local/php –with-apxs2=/usr/local/apache2/bin/apxs --with-gd-
dir=/usr/local/src/gd-2.0.35 --enable-track-vars --with-ttf --enable-gd-imgstrttf --with-png-dir=/usr/li
--with-freetype-dir=/usr/lib --with-fontconfig-dir=/usr/local/src/fontconfig-2.7.3 --with-jpeg-
dir=/usr/lib --with-xpm-dir=/usr/local/src/xpm-3.4k/lib/ --with-zlib-dir=/usr/local/lib/ --enable-ldap
--enable-ssl
make
make install
cp php.ini-production /usr/local/lib/php.ini
change the following lines in /usr/local/lib/php.ini
register_globals=On
short_open_tag=On
display_error=Off
Add the following lines in /usr/local/apache2/conf/httpd.conf
LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
DocumentRoot "/home/httpd"
save and quit the file.
/usr/local/apache2/bin/apachectl restart
To chk running status – Netstat –pan | grep 80
In URL: http://ip/ (should open up Apache home page)
Create user httpd in linux
useradd httpd
cd /home
chown -R httpd:httpd httpd
chmod 777 httpd
Nagios Installation:
Step:1
First we have to create nagios user and group.
useradd nagios
passwd nagios
groupadd nagcmd
usermod -a -G nagcmd nagios -> adding nagios user to nagcmd group
usermod -a -G nagcmd httpd -> adding httpd user to nagcmd group
Step:2
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.2.3.tar.gz
wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-
1.4.11.tar.gz
Step:3
vim /home/httpd/nagios/etc/objects/contacts.cfg
in this file change the email address to your own email address.From this we can recieve alerts
through email.
/usr/local/apache2/bin/htpasswd -c /home/httpd/nagios/etc/htpasswd.users nagiosadmin
We have to restart the apache
/usr/loca/apache2/bin/apachectl restart
Step:4
tar -xvzf nagios-plugins-1.4.11.tar.gz
cd nagios-plugins-1.4.11
./configure -–prefix=/home/httpd/nagios --with-nagios-user=nagios --with-nagios-group=nagios
make
make install
Step:5
vim /usr/local/apache2/conf/httpd.conf
add the following lines
ScriptAlias /nagios/cgi-bin "/home/httpd/nagios/sbin"
<Directory "/home/httpd/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 /home/httpd/nagios/etc/htpasswd.users
Require valid-user
</Directory>
Nrpe:
Nrpe is a plugin it is used to monitor remote linux host and the various services running on the
remotehost.
Note:
In Redhat Linux ./configure command was hanging with “Checking for Redhat Spopen
Problem” so use --enable-redhat-pthread-workaround
Step:2
tar -xvzf nrpe-2.12.tar.gz
cd nrpe-2.12
./configure
make all
make install-plugin
make install-daemon
make install-daemon-config
make install-xinetd
Step3:
vim /etc/xinetd.d/nrpe
only from 127.0.0.1 124.7.58.36 -> is a nagios server
save & auit the fle
Add the follwing in /etc/services
/etc/services
nrpe 5666/tcp #nrpe
service xinetd restart
netstat -at | grep nrpe
tcp 0 *:nrpe *:* LISTEN
/usr/local/nagios/etc/libexec/check_nrpe -H <serverip>
NRPE v2.12
Step:4
Installing Nrpe on Nagios server
tar -xvzf nrpe-2.12.tar.gz
cd nrpe-2.12
./configure –prefix=/home/httpd/nagios
make all
make install-plugin
/home/httpd/nagios/libexec/check_nrpe -H 124.7.226.173
checks remote host connection
; This host definition will inherit all variables that are defined
host_name 124.7.58.41
alias 124.7.58.41
address 124.7.58.41
define command{
command_name check_http
service_description HTTP
check_command check_http!124.7.58.41
notifications_enabled 0
/home/httpd/nagios/bin/nagios -v /home/httpd/nagios/etc/nagios.cfg
service nagios restart
Note:
The above command is used to test the nagios configuration,If there is any error in our
configuration it will displays the error.After adding each service we can check our configuration by
providing this command.
Url Monitoring:
Download the website monitoring scripts from http://exchange.nagios.org/directory/Plugins/
copy the script to /home/httpd/nagios/libexec
chown nagios.nagios /home/httpd/nagios/libexec/check_website_response.sh
Edit the file /home/httpd//nagios/etc/objets/commands.cfg
The following lines should look like this
# 'check_website' command definition
define command{
command_name check_website
host_name 124.7.58.41
service_description check_website
check_command check_website!1500!2000!alphacms.sify.com
Nagios Server:
vim /home/httpd/nagios/etc/objects/commands.cfg
the following lines should look like this:
# 'check_nrpe' command definition
define command{
command_name check_nrpe
host_name 124.7.58.41
check_command check_nrpe!check_disk!25%!20%!/
define service{
check_command check_nrpe!check_boot!30%!25%!/boot
define service{
host_name 124.7.58.41
service_description Cms Partition
check_command check_nrpe!check_cms!20%!15%!/cmsdata
In Nagios Server:
vim /home/httpd/nagios/etc/servers/alphacms.cfg
The following lines should look like this:
define service{
host_name 124.7.58.41
check_command check_nrpe!check_swap!20!10
In Nagios Server:
vim /home/httpd/nagios/etc/servers/alphacms.cfg
The following lines should look like this:
define service{
use generic-service ; Name of service template to use
host_name 124.7.58.41
check_command check_nrpe!check_load!15,10,5!30,25,20
In Nagios Server:
vim /home/httpd/nagios/etc/servers/alphacms.cfg
The following lines should look like this:
define service{
host_name 124.7.58.41
service_description check_mem
check_command check_nrpe!check_mem!75!80
notifications_enabled 0
STATUS="Apache Count-MAX_THRESHOLD"
TV=300
VAL=1
else
fi
In Remote Host:
vim /usr/local/nagios/etc/nrpe.cfg
The Following lines should look like this:
command[check_apache]=/usr/local/nagios/libexec/alert.sh
host_name 124.7.58.41
service_description check_apache
check_command check_nrpe!check_apache!10
notifications_enabled 0
Monitoring Ethernet:
copy the script errorcheck.sh from any one of our server.
Copy it in to the remote host 124.7.58.41:/usr/local/nagios/libexec
chmod nagios.nagios errorcheck.sh
In Remote Host:
vim /usr/local/nagios/etc/nrpe.cfg
The Following lines should look like this:
command[check_ethernet]=/usr/local/nagios/libexec/errorcheck.sh
In Nagios Server:
vim /home/httpd/nagios/etc/servers/alphacms.cfg
The following lines should look like this:
define service{
host_name 124.7.58.41
service_description check_ethernet
check_command check_nrpe!check_ethernet!30
notifications_enabled 0