[Nagiosplug-help] help with event handler

Mitchell K. Smith mksmith at pa.eplus.com
Wed May 28 04:42:04 CEST 2003


Hmmm...that could explain why it's not working. I was following the sample script included with Nagios.

But I'm still not clear on where the argument ($4) would come from. Can you explain that a little further.

Thanks.

Mitch


-----Original Message-----
From: James Fillman [mailto:JFillman at cucbc.com]
Sent: Tuesday, May 27, 2003 5:29 PM
To: Mitchell K. Smith
Subject: RE: [Nagiosplug-help] help with event handler


Does your script literally have $HOSTADDRESS$ in it?  Because that does not get inherited within your script. You need to pass the host address to the script as an argument just like you with the state type and status.

ssh $4 sudo /etc/rc.d/init.d/httpd restart
 
cheers,
--james

//~~~~~~~~~
// Don't put off for tomorrow what you can do today,
// because if you enjoy it today you can do it again tomorrow.



-----Original Message-----
From: Mitchell K. Smith [mailto:mksmith at pa.eplus.com]
Sent: Tuesday, May 27, 2003 8:20 AM
To: nagiosplug-help at lists.sourceforge.net
Subject: [Nagiosplug-help] help with event handler


Greetings all.
I need some help with the event handlers.
I am trying to have Nagios restart services on remote servers when it sees the service is down. I can do all the commands manually to restart the services. The problem seems to be in the event handler script.

Here is my service config:
# Service definition - test server
define service{
        use                             eplus-service
        event_handler_enabled           1       ; Service event handler is enabled
        host_name                       test
        service_description             HTTP
        event_handler                   remote-restart-httpd
        contact_groups                  linux-admins
        check_command                   check_http
        notification_options            c,r
        is_volatile                     0
        check_period                    24x7
        max_check_attempts              3 
        normal_check_interval           3   
        retry_check_interval            1  
        notification_interval           120
        notification_period             workhours
        }

Here is my remote-restart-httpd script:
#!/bin/sh
case "$1" in
OK)
        ;;
WARNING)  
        ;;
UNKNOWN)  
        ;;
CRITICAL) 
        # Is this a "soft" or a "hard" state?
        case "$2" in
        SOFT)
                case "$3" in
                
                3)
                        echo -n "Restarting HTTP service (3rd soft critical state)..."
                        # Call the init script to restart the HTTPD server
                        ssh $HOSTADDRESS$ sudo /etc/rc.d/init.d/httpd restart
                        ;;
                        esac
                ;;
                  
        HARD)
                echo -n "Restarting HTTP service..."
                # Call the init script to restart the HTTPD server
                ssh $HOSTADDRESS$ sudo /etc/rc.d/init.d/httpd restart
                ;;
        esac
        ;;  
esac
exit 0

I can run commands from the Nagios server as the Nagios user and they work.
ssh 172.31.1.34 sudo /etc/rc.d/init.d/httpd status
This will return my httpd server status.

Thanks for any help you can offer.

Mitchell K. Smith


-------------------------------------------------------
This SF.net email is sponsored by: ObjectStore.
If flattening out C++ or Java code to make your application fit in a
relational database is painful, don't do it! Check out ObjectStore.
Now part of Progress Software. http://www.objectstore.net/sourceforge
_______________________________________________
Nagiosplug-help mailing list
Nagiosplug-help at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagiosplug-help
::: Please include plugins version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null




More information about the Help mailing list