eventhandle not being executed. bug?

Hari Sekhon hpsekhon at googlemail.com
Wed Jun 6 17:41:33 CEST 2007


You have mislabeled your event handler in miscommands.cfg.

The command_name should be "restart_test", not "restart_test.sh" as you 
are calling "restart_test" without the .sh ending in your event_handler 
definition in services.cfg.


-h

Hari Sekhon



Kurt Ramsden wrote:
> Hi All,
>
> I'm trying to setup an eventhandler but it seems that it is never 
> being called/executed.  I have been over my configs with a fine-tooth 
> comb, and I just can't figure this out.  Here are my configs:
>
> misccommands.cfg:
>
> define command{
>         command_name    restart_test.sh
>         command_line    $USER2$/restart_test $SERVICESTATE$ 
> $SERVICESTATETYPE$ $SERVICEATTEMPT$ $HOSTNAME$
>         } # $USER2$ is a macro for /opt/nagios/libexec/eventhandle
>
>
> nagios.cfg:
>
> enable_event_handlers=1
>
>
> services.cfg:
>
> # Generic service definition template
> define service{
>         name                            generic-service ; The 'name' 
> of this service template, referenced in other service definitions
>         active_checks_enabled           1       ; Active service 
> checks are enabled
>         passive_checks_enabled          1       ; Passive service 
> checks are enabled/accepted
>         parallelize_check               1       ; Active service 
> checks should be parallelized (disabling this can lead to major 
> performance problems)
>         obsess_over_service             1       ; We should obsess 
> over this service (if necessary)
>         is_volatile                     0
>         check_period                    24x7
>         max_check_attempts              3
>         normal_check_interval           5
>         retry_check_interval            1
>         check_freshness                 0       ; Default is to NOT 
> check service 'freshness'
>         notifications_enabled           1       ; Service 
> notifications are enabled
>         event_handler_enabled           1       ; Service event 
> handler is enabled
>         flap_detection_enabled          1       ; Flap detection is 
> enabled
>         process_perf_data               1       ; Process performance data
>         retain_status_information       1       ; Retain status 
> information across program restarts
>         retain_nonstatus_information    1       ; Retain non-status 
> information across program restarts
>         notification_interval           120
>         notification_period             24x7
>         notification_options            c,r,u
>         process_perf_data               0
>
>         register                        0       ; DONT REGISTER THIS 
> DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
>         }
>
>
> and the service:
> define service{
>         use                             generic-service         ; Name 
> of service template to use
>         host_name                       tmail
>         service_description             msgStor Partition
>         max_check_attempts              4
>         event_handler_enabled           1
>         event_handler                   restart_test
>         contact_groups                  solaris-admins
>         check_command                   snmp_disk!7!84!89
>         }
>
>
> at this point, all I have in restart_test.sh is this (I cannot get any 
> output from this script into restart_test.log which is leading me to 
> believe that its not being called):
>
> #!/bin/sh
>
> echo "$1" "$2" "$3" "$4" >>./restart_test.log
>
> exit 0
>
>
> and directory perms:
>
> nagios at excalibur-mgt:~/libexec/eventhandlers> ls -la
> total 10
> drwxr-xr-x 2 nagios nagios  112 2007-06-05 14:41 .
> drwxr-xr-x 3 root   root   2168 2007-05-29 12:37 ..
> -rwxr-xr-- 1 nagios nagios   65 2007-06-05 14:41 restart_test.sh
>
>
> The nagios logs state that it is being called, but I don't think so:
>
> [1180991106] SERVICE ALERT: tmail;msgStor Partition;UNKNOWN;SOFT;1;No 
> valid data returned
> [1180991106] SERVICE EVENT HANDLER: tmail;msgStor 
> Partition;UNKNOWN;SOFT;1;restart_test
> [1180991126] SERVICE ALERT: tmail;iPlanet Partition;UNKNOWN;SOFT;1;No 
> valid data returned
> [1180991166] SERVICE ALERT: tmail;msgStor Partition;UNKNOWN;SOFT;2;No 
> valid data returned
> [1180991166] SERVICE EVENT HANDLER: tmail;msgStor 
> Partition;UNKNOWN;SOFT;2;restart_test
> [1180991186] SERVICE ALERT: tmail;iPlanet Partition;UNKNOWN;SOFT;2;No 
> valid data returned
> [1180991226] SERVICE ALERT: tmail;msgStor Partition;UNKNOWN;SOFT;3;No 
> valid data returned
> [1180991226] SERVICE EVENT HANDLER: tmail;msgStor 
> Partition;UNKNOWN;SOFT;3;restart_test
> [1180991246] SERVICE ALERT: tmail;iPlanet Partition;UNKNOWN;SOFT;3;No 
> valid data returned
> [1180991286] SERVICE ALERT: tmail;msgStor Partition;UNKNOWN;HARD;4;No 
> valid data returned
> [1180991286] SERVICE EVENT HANDLER: tmail;msgStor 
> Partition;UNKNOWN;HARD;4;restart_test
> [1180991306] SERVICE ALERT: tmail;iPlanet Partition;UNKNOWN;HARD;4;No 
> valid data returned
>
>
> by forcing an error (setting the script to no execute) I know that its 
> being passed the args:
>
> [1181065075] Warning: Attempting to execute the command 
> "/opt/nagios/libexec/eventhandlers/restart_test.sh UNKNOWN SOFT 1 
> <some_IP>" resulted in a return code of 126.  Make sure the script or 
> binary you are trying to execute actually exists...
>
>
> There you have it.  Can anyone help?
> Thanks,
>     Kurt
>
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> ------------------------------------------------------------------------
>
> _______________________________________________
> Nagios-users mailing list
> Nagios-users at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/nagios-users
> ::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
> ::: Messages without supporting info will risk being sent to /dev/null

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list