How to add check_http as a service in Nagios Monitoring using NRPE

Before we add the check_http service to check status of HTTP Server on a remote server , it is assumed that we already have a running Nagios Server . If this is not done yet , please configure a Nagios Server by following the steps from the link below.      

http://zaman4linux.blogspot.in/2012/04/configuring-nagios-to-monitor-services.html


                                            REMOTE SERVER  


1. On the Remote host which  we want to monitor for HTTP service , execute  the following steps.

$ /usr/local/nagios/libexec/check_http  -I 
HTTP OK: HTTP/1.1 200 OK - 40321 bytes in 0.090 second response time |time=0.090395s;;;0.000000 size=40321B;;;0


If the above command works fine for you , update nrpe.cfg with the check_http plugin

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

command[check_http]=/usr/local/nagios/libexec/check_http -I 192.168.2.142

                                 
                                     MONITORING SERVER

1. Execute the following command and look for a response from the remote server.

# /usr/local/nagios/libexec/check_nrpe -H 192.168.2.142 -c check_http
HTTP OK: HTTP/1.1 200 OK - 40321 bytes in 0.105 second response time |time=0.104595s;;;0.000000 size=40321B;;;0


2.  Open the server config file defined in Nagios and add the following entry. For us the server config file is  /usr/local/nagios/etc/objects/linuxservers.cfg

grep /usr/local/nagios/etc/objects/linuxservers.cfg /usr/local/nagios/etc/nagios.cfg
cfg_file=/usr/local/nagios/etc/objects/linuxservers.cfg


  define service{
                         use                            generic-service
                         host_name                www
                         service_description  HTTP STATUS
                         contact_groups         ssdgadmins
                         check_command        check_nrpe!check_http
                        }


3. Check the syntax of Nagios Config file and if all looks OK , restart nagios service.

#  /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
   .............
   .............
  Checking for circular paths between hosts...
  Checking for circular host and service dependencies...
  Checking global event handlers...
  Checking obsessive compulsive processor commands...
  Checking misc settings...

  Total Warnings: 0
  Total Errors:   0


 # service nagios restart
    Running configuration check...done.
    Stopping nagios: done.
    Starting nagios: done.

 








Comments

Unknown said…
Very useful and informative article on Nagios, Thanks for writing.

Best Regards,
CourseIng - DevOps Training in Hyderabad

Popular Posts