How does one notify on event handler failure ?

Stanley.Hopcroft at ipaustralia.gov.au Stanley.Hopcroft at ipaustralia.gov.au
Tue Jul 19 11:25:05 CEST 2005


-Dear Sir,

I am writing to thank you for your letter and say,

> Hi Stanley,

>> I would like to have an event handler attempt a service restart __and__
>> then
>> have Nagios process a restart failure by notifying the contact group 
and
>> doing
>> all the other Nag things (log, pace notifications, re-invoke event
>> handlers ..) as
>> long as the service fails to restart.

> How about: set your max_check_attempts to 10. On the 5th soft failure,
> restart the service. If the service doesn't come back up properly, 
Nagios
> will check it another 5 times and then report an error in the normal 
way.

Sounds great to me.

Since eventhandlers are called with args of $SERVICESTATE$, 
$SERVICESTATETYPE$, $SERVICEATTEMPT$
the event handler prologue should be something like

#!/usr/bin/perl -w

use strict ;

exit 0
             unless $ARGV[0] eq 'CRITICAL' ;
 
exit 0
                 if     $ARGV[1] eq 'HARD' ;
                 # will only see a HARD state if restart fails

exit 0
             if     $ARGV[2] != 5 ;
 
# Go ahead and try and restart the service ..
# Take as long as we like since we won't get called again if the
# restart fails.

# Chronology is
# retry             state   notes

# 1                 SOFT   retry service check to confirm fault
# restart_threshold SOFT   fault confirmed; try event handler/restart
# .. threshold + 1  SOFT   retry service to check restart
# max_checks        HARD   restart failure confirmed; notify etc


> Cheers, Chris.

Thank you very much for this elegant solution so closely aligned to the 
what
seems to me the conception of the event handler signature.

Yours sincerely


-- 
Stanley Hopcroft



-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: disclaimer.txt
URL: <https://www.monitoring-lists.org/archive/users/attachments/20050719/c59e7078/attachment.txt>


More information about the Users mailing list