MRKAVANA (mrkavana@gmail.com) - www.facebook.com/kavanathai
Showing posts with label nagios. Show all posts
Showing posts with label nagios. Show all posts

Jul 18, 2011

How to setup url or website monitoring in nagios server

First of all create a configuration directory for writing the rules. You can also create the rules in localhost.cfg but I recommend  to create a separate directory and create the files in it.

#mkdir /etc/nagios/monitor_websites
and cd to this directory

And create file host.cfg in this directory for setting the urls.
#vi host.cfg

Suppose I want to monitor three sites
www.abc.com, www.xyz.com, www.pqr.com

Configure host.cfg as below.
#vi host.cfg

define host{
host_name  abc.com
alias         abc
address    www.abc.com
use        generic-host
}

define host{
host_name  xyz.com
alias      xyz
address    www.xyz.com
use        generic-host
}

define host{
host_name  pqr.com
alias           pqr
address    www.pqr.com
use        generic-host
}

#Defining group of urls  - you should add this if you want to set up an HTTP check service.
define hostgroup {
hostgroup_name    monitor_websites
alias           monitor_urls
members         www.abc.com, www.xyz.com, www.pqr.com
}
:wq #save it

And now create the file services.cfg for setting the service ( http_check )

#vi services.cfg
## Hostgroups services ##
define service {
hostgroup_name                 monitor_websites
service_description             HTTP
check_command                 check_http
use                             generic-service
notification_interval           0
}

Now give the permissions for directory and configuration files.
#chown  -R nagios:nagios monitor_websites

List and check.
[root@mail nagios]#  ll monitor_websites
total 16
-rw-r--r-- 1 nagios nagios 669 Apr 25 23:13 host.cfg
-rw-r--r-- 1 nagios nagios 253 Apr 25 23:15 services.cfg
[root@mail nagios]#

Now give the configuration directory path in main nagios configuration file.
#vi /etc/nagios/nagios.cfg
cfg_dir=/etc/nagios/monitor_websites
:wq

Now restart the nagios service.
#service nagios restart

Thats it. Check the nagios site. You are done. You rocks.


How to install and configure Nagios Monitoring tool in redhat linux rhel5 or centos

This article will help you to install and configure Nagios monitoring tool in redhat linux or other redhat distributions like fedora, centos etc.

Nagios Installation :
Installing packages. Apache, PHP, GCC & GD 


Installing Apache web server: 
#yum -y install httpd*
set hostname in FQDN
#service httpd on


Installing PHP, GCC and GD:
#yum -y install php*
#yum -y install gcc*
#yum -y install gd*

Getting the package:
Get the latest packages from net. Mov it to some directory and untar them.

#wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.2.0.tar.gz
#mv nagios-3.2.0.tar.gz  /usr/local/src
#tar xvf nagios-3.2.0.tar.gz

#wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.14.tar.gz
#mv nagios-plugins-1.4.14.tar.gz/usr/local/src
#tar xvf nagios-plugins-1.4.14.tar.gz

Adding nagios user and setting password for that user: 
#useradd nagios
#passwd nagios
usermod -a -G nagios apache              //To permit the commands through web interface.

Configuration of Nagios:
cd /usr/local/src/nagios-3.2.0

./configure
make all
make install
make install-init
make install-config
make install-commandmode
make install-webconf

Admin account setting for nagios:
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin          /passwd  for web interface
give passwd
service httpd restart

Nagios Plugin installation:
install nagios - pluggin

cd /usr/local/src/nagios-plugins-1.4.14
./configure
make
make install

Creating entry in /etc/init.d/: 
chkconfig --add nagios
chkconfig nagios on

Checking the configuration:
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Nagios Alert Plugin - Mozilla Addon:
Name : Nagios Checker
[give name and url]

Configuring remotehost in nagios:
cp /usr/local/nagios/etc/objects/localhost.cfg  /usr/local/nagios/etc/objects/remotehost.cfg
[comment the hostgroup entries in order to prevent duplicate entries]
[change the localhost entries to the remote machine hostname and IP address.]