[Mon-commit] mon mon,1.7,1.8
Brought to you by:
trockij
From: Jim T. <tr...@us...> - 2004-06-24 21:00:17
|
Update of /cvsroot/mon/mon In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12657 Modified Files: mon Log Message: slightly reformatted the alertevery handling code in do_alert so that it's a little easier to read, and i added blow-by-blow comments to the right margin. ported "alertevery .. strict" code from the mon-1-0-0pre1 branch. tidied up the parsing of alertevery in read_cf. made all the options exclusive because they are, and the config parser shouldn't accept multiples of them. Index: mon =================================================================== RCS file: /cvsroot/mon/mon/mon,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** mon 24 Jun 2004 19:11:54 -0000 1.7 --- mon 24 Jun 2004 21:00:09 -0000 1.8 *************** *** 670,683 **** # # only alert once every "alertevery" seconds, unless ! # output from monitor is different # ! if ($pref->{"alertevery"} != 0 ! && ($tmnow - $pref->{"_last_alert"} < $pref->{"alertevery"}) ! && (($pref->{"_observe_detail"} ! && $sref->{"_failure_output"} eq $output) ! || (!$pref->{"_observe_detail"} ! && (!$pref->{"_ignore_summary"}) ! && ($prevsumm eq $summary)) ! || ($pref->{"_ignore_summary"}))) { syslog ('debug', "$group/$service/$periodlabel: Suppressing alert for now due to alertevery."); --- 670,686 ---- # # only alert once every "alertevery" seconds, unless ! # output from monitor is different or if strict alertevery # ! # strict and _ignore_summary are basically the same though ! # strict short-circuits and overrides other settings and exists ! # for compatibility with pre-1.1 configs ! # ! if ($pref->{"alertevery"} != 0 && # if alertevery is set and ! ($tmnow - $pref->{"_last_alert"} < $pref->{"alertevery"}) && # we're within the time period and one of these: ! (($pref->{"_alertevery_strict"}) || # [ strict is set or ! ($pref->{"_observe_detail"} && $sref->{"_failure_output"} eq $output) || # observing detail and output hasn't changed or ! (!$pref->{"_observe_detail"} && (!$pref->{"_ignore_summary"}) && ($prevsumm eq $summary)) || # not observing detail ! # and not ignoring summary and summ hasn't changed or ! ($pref->{"_ignore_summary"}))) # we're ignoring summary changes ] { syslog ('debug', "$group/$service/$periodlabel: Suppressing alert for now due to alertevery."); *************** *** 1451,1466 **** elsif ($var eq "alertevery") { ! my $observe_detail = 0; ! my $ignore_summary = 0; if ($args =~ /(\S+) \s+ observe_detail \s*$/ix) { ! $observe_detail = 1; $args = $1; } ! if ($args =~ /(\S+) \s+ ignore_summary \s*$/ix) { ! $ignore_summary = 1; $args = $1; } --- 1454,1470 ---- elsif ($var eq "alertevery") { ! $pref->{"_observe_detail"} = 0; ! $pref->{"_alertevery_strict"} = 0; ! $pref->{"_ignore_summary"} = 0; if ($args =~ /(\S+) \s+ observe_detail \s*$/ix) { ! $pref->{"_observe_detail"} = 1; $args = $1; } ! elsif ($args =~ /(\S+) \s+ ignore_summary \s*$/ix) { ! $pref->{"_ignore_summary"} = 1; $args = $1; } *************** *** 1474,1485 **** } if (!($args = dhmstos ($args))) { close (CFG); ! return "cf error: invalid time interval '$args' (syntax: alertevery {positive number}{smhd}), line $line_num"; } $pref->{"alertevery"} = $args; - $pref->{"_observe_detail"} = $observe_detail; - $pref->{"_ignore_summary"} = $ignore_summary; next; } --- 1478,1496 ---- } + # + # strict + # + elsif ($args =~ /(\S+) \s+ strict \s*$/ix) + { + $pref->{"_alertevery_strict"} = 1; + $args = $1; + } + if (!($args = dhmstos ($args))) { close (CFG); ! return "cf error: invalid time interval '$args' (syntax: alertevery {positive number}{smhd} [ strict | observe_detail | ignore_summary ]), line $line_num"; } $pref->{"alertevery"} = $args; next; } *************** *** 3275,3279 **** foreach my $period (keys %{$sref->{"periods"}}) { ! $sref->{"periods"}->{$period}->{"_last_alert"} = 0; $sref->{"periods"}->{$period}->{"_1stfailtime"} = 0; $sref->{"periods"}->{$period}->{"_alert_sent"} = 0; --- 3286,3297 ---- foreach my $period (keys %{$sref->{"periods"}}) { ! # ! # "alertevery strict" should not reset _last_alert ! # ! if (!$sref->{"periods"}->{$period}->{"_alertevery_strict"}) ! { ! $sref->{"periods"}->{$period}->{"_last_alert"} = 0; ! } ! $sref->{"periods"}->{$period}->{"_1stfailtime"} = 0; $sref->{"periods"}->{$period}->{"_alert_sent"} = 0; |