[Nagiosplug-help] Help with Event handler again!!

Soeun Vanny vanny at artemis-it.com
Mon Jun 9 22:03:07 CEST 2003


Hello everybody!

I've tried to apply the event handler to restart a service,which is probed
to be down by nagios,on a remote host.I don't know what's wrong with my
work. Please take a look at my work as mentioned below.

1. the script that is called by nagios to restart a service.

    #!/bin/sh

    case "$1" in
    OK)
            ;;
    WARNING)
            ;;
    UNKNOWN)
            ;;
    CRITICAL)


            case "$2" in
            SOFT)
                    case "$3" in
                    3)
                            ssh $4 /etc/rc.d/init.d/httpd restart
                            ;;
                    esac
                    ;;
            HARD)
                    ssh $4 /etc/rc.d/init.d/httpd restart
                    ;;
            esac
            ;;
    esac
    exit 0

2. Here is the syntax of serviccs.cfg

# Service definition
define service{
 use    generic-service  ; Name of service template to use


 host_name               hestia
 service_description  HTTP
 is_volatile               0
 check_period           24x7
 max_check_attempts      4
 normal_check_interval      5
 retry_check_interval      1
 contact_groups           admins
 notification_interval      120
 notification_period          24x7
 notification_options      w,u,c,r
 event_handler_enabled    1
 check_event_handler    service-restart
 check_command           check_http
 }

3. Here is the syntax of checkcommands.cfg

# 'event_handler' command definition
define command{
 command_name     service-restart
 command_line /usr/local/nagios/libexec/service-restart $SERVICESTATE$
$STATETYPE$ $SERVICEATTEMP$ $HOSTADDRESS$
 }

For test i stopped the http service on a remote machine and  tried to
execute by hand the following command:
     ssh 192.168.1.200 /etc/rc.d/init.d/httpd restart . Well, it worked well
(of course i set ssh to passwordless).

Is there anything wrong with my script?


Thanks in advance for your help




_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
_/
_/  日本アルテミス株式会社
_/  スーン・ヴァニー (Soeun Vanny)
_/  mailto : vanny at artemis-it.com
_/
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-plugins.org/archive/help/attachments/20030609/45267447/attachment.html>


More information about the Help mailing list