Home » » Adding Host to Nagios for monitor

Adding Host to Nagios for monitor

Written By Giai phap ma nguon mo on Tuesday, July 19, 2011 | 11:28 PM

Adding Host to Nagios for monitor 
 
 
 
Today, we will see how to Add our first host to nagios for monitoring support
you want to monitor is it internet is working of not by ping www.google.com
for that Create new file as googel.cfg in /usr/local/nagios/etc/objects 
and type following parameter to use nagios to read. by using vi or nano editor.
 
to define host we need to specify host name of the computer or host you want to
monitor. valid ip address or DNS name of the given host. set alias for host and 
what template should be used. we should must also define atleast one service to 
check for the host. parameter for defining service also same but we have to 
specify how to check the service and what action nagios should take. for eg. send 
notification or not. if you want notification then you should enabled it. i have
set it disabled. 
 
we are checking is www.googl.com is up and http service is running or not. 
 
vi /usr/local/nagios/etc/objects/google.cfg
 
  
# Define a host for the local machine

define host{
        use                     linux-server    
                                    
                                    
        host_name               google.com
        alias                   google.com
        address                 www.google.com
        }

###############################################################################
###############################################################################
#
# SERVICE DEFINITIONS
#
###############################################################################
###############################################################################

# Define a service to "ping" the local machine

define service{
        use                             generic-service        
        host_name                       google.com
        service_description             PING
        check_command                   check_ping!100.0,20%!500.0,60%
        }

# Define a service to check HTTP


define service{
        use                             generic-service         
        host_name                       google.com
        service_description             HTTP
        check_command                   check_http
        notifications_enabled           0
        }
# End of File google.cfg
###############################################################################
 
Now define google.cfg file on nagios main configuration file.
sudo vi /usr/local/nagios/etc/nagios.cfg
and add the following line 
cfg_file=/usr/local/nagios/etc/objects/google.cfg 
 
Save the nagios.cfg and restart nagios using following command
 
sudo /etc/init.d/nagios restart 
 
wait for a mint. and then open you web browser and open url:-

http://localhost/nagios

OR

http://ipaddress/nagios

In Host you will now see google.com in host list for monitoring .
Share this article :

0 comments:

Post a Comment