Monday, April 25, 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,,

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

define host{
alias         abc
use        generic-host

define host{
alias      xyz
use        generic-host

define host{
alias           pqr
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
: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

Now restart the nagios service.
#service nagios restart

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

1 comment:

  1. i searched it for a long time on internet now i stopped here. very simple code to set up Website Monitoring in nagiosserver.Thank you for post.


Be nice. That's all.