[Mon-commit] mon mon,1.4.2.7,1.4.2.8
Brought to you by:
trockij
From: Jim T. <tr...@us...> - 2004-07-09 03:17:47
|
Update of /cvsroot/mon/mon In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2645 Modified Files: Tag: mon-1-0-0pre1 mon Log Message: received traps now reset the trap timeout counter, and fixed some other stuff wrt trap timeouts added sub process_event and made proc_cleanup and handle_trap use it so that the alert mgmt code is shared rather than in two places. i tested as much of it as i could and all seems to work well now, especially upalert, alertafter, alertevery with traps. added per-service "_monitor_duration" variable which records how many seconds the previous monitor took to execute. this is available via "list opstatus". if no monitor has executed yet then the value is -1. added per-service "_monitor_running" variable whose value is 0 or 1 depending on whether the monitor is currently running for that service. removed gunk from handle_trap regarding the various TRAP_COLDSTART, etc. processing, since most of it was a bad idea anyway, or at least as far as i could tell. traps and their exit values are now processed exactly as monitors are, which simplifies things greatly and adds to more intuitive functionality. this means the "spc" value in a trap is now ignored. fixed some args processing in call_alert Index: mon =================================================================== RCS file: /cvsroot/mon/mon/mon,v retrieving revision 1.4.2.7 retrieving revision 1.4.2.8 diff -C2 -d -r1.4.2.7 -r1.4.2.8 *** mon 28 Jun 2004 20:10:21 -0000 1.4.2.7 --- mon 9 Jul 2004 03:17:32 -0000 1.4.2.8 *************** *** 96,99 **** --- 96,100 ---- sub pam_conv_func; sub proc_cleanup; + sub process_event; sub randomize_startdelay; sub read_cf; *************** *** 389,394 **** $sref->{"_trap_timer"} -= $t; ! if ($sref->{"_trap_timer"} <= 0 && $tm - $sref->{"_last_uptrap"} > ! $sref->{"traptimeout"}) { handle_trap_timeout ($group, $service); } --- 390,395 ---- $sref->{"_trap_timer"} -= $t; ! if ($sref->{"_trap_timer"} <= 0) ! { handle_trap_timeout ($group, $service); } *************** *** 508,511 **** --- 509,514 ---- my ($sref, $range, @alerts); + debug (1, "do_alert flags=$flags\n"); + $sref = \%{$watch{$group}->{$service}}; *************** *** 1207,1210 **** --- 1210,1219 ---- $sref->{"_exitval"} = "undef" if (!defined($sref->{"_exitval"})); $sref->{"_last_check"} = undef; + # + # -1 for _monitor_duration means no monitor has been run yet + # so there is no duration data available + # + $sref->{"_monitor_duration"} = -1; + $sref->{"_monitor_running"} = 0; $sref->{"_depend_status"} = undef; $sref->{"failure_interval"} = undef; *************** *** 2678,2683 **** if ($sref->{"_last_failure"}); ! $buf .= " interval=$sref->{interval}" ! if ($sref->{"interval"}); $buf .= " exclude_period='$sref->{exclude_period}'" --- 2687,2697 ---- if ($sref->{"_last_failure"}); ! ! if ($sref->{"interval"}) ! { ! $buf .= " interval=$sref->{interval}" . ! " monitor_duration=$sref->{_monitor_duration}" . ! " monitor_running=$sref->{_monitor_running}" ! } $buf .= " exclude_period='$sref->{exclude_period}'" *************** *** 2864,3011 **** } ! $sref->{"_exitval"} = int($?>>8); ! debug (1, "PID $p ($runningpid{$p}) exited with [$sref->{'_exitval'}]\n"); ! $sref->{"_last_checked"} = $tmnow; ! if ($sref->{"depend"} ne "" && ! $sref->{"dep_behavior"} eq "a") ! { ! dep_ok ($sref); ! } # ! # error exit value # ! if ($?) { ! # ! # accounting ! # ! $sref->{"_failure_count"}++; ! $sref->{"_consec_failures"}++; ! $sref->{"_last_failure"} = $tmnow; ! if ($sref->{"_op_status"} == $STAT_OK || ! $sref->{"_op_status"} == $STAT_UNKNOWN || ! $sref->{"_op_status"} == $STAT_UNTESTED) ! { ! $sref->{"_first_failure"} = $tmnow; ! } ! set_op_status ($group, $service, $STAT_FAIL); ! my ($summary, $detail) = split("\n", $ibufs{$runningpid{$p}}, 2); ! $summary = "(NO SUMMARY)" if ($summary =~ /^\s*$/m); ! $sref->{"_last_summary"} = $summary; ! $sref->{"_last_detail"} = $detail; ! shift @last_failures if (@last_failures > $CF{"MAX_KEEP"}); ! push @last_failures, "$group $service" . ! " $tm $summary"; ! syslog ('crit', "failure for $last_failures[-1]"); ! # ! # send an alert if necessary ! # ! do_alert ($group, $service, $ibufs{$runningpid{$p}}, ! $?>>8, $FL_MONITOR); # # change interval if needed # if (defined ($sref->{"failure_interval"}) && ! $sref->{"_old_interval"} == undef) { ! $sref->{"_old_interval"} = $sref->{"interval"}; $sref->{"interval"} = $sref->{"failure_interval"}; $sref->{"_next_check"} = 0; } - - $sref->{"_failure_output"} = $ibufs{$runningpid{$p}}; } ! # ! # success exit value ! # ! else { ! if ($CF{"DTLOGGING"} && defined ($sref->{"_op_status"}) && ! $sref->{"_op_status"} == $STAT_FAIL) ! { ! write_dtlog ($sref, $group, $service); ! } ! my $old_status = $sref->{"_op_status"}; ! set_op_status ($group, $service, $STAT_OK); ! # ! # if this service has just come back up and ! # we are paying attention to this event, ! # let someone know ! # ! if ((defined ($sref->{"_op_status"})) && ! ($old_status == $STAT_FAIL) && ! (defined($sref->{"_upalert"})) && ! (!defined($sref->{"upalertafter"}) ! || (($tmnow - $sref->{"_first_failure"}) >= $sref->{"upalertafter"}))) ! { ! do_alert ($group, $service, $sref->{"_upalertoutput"}, 0, $FL_UPALERT); ! } ! # ! # send also when no upalertafter set ! # ! elsif (defined($sref->{"_upalert"})) ! { ! do_alert ($group, $service, $sref->{"_upalertoutput"}, 0, $FL_UPALERT); ! } ! $sref->{"_ack"} = 0; ! $sref->{"_ack_comment"} = ''; ! $sref->{"_first_failure"} = 0; ! $sref->{"_last_failure"} = 0; ! $sref->{"_consec_failures"} = 0; ! my ($summary, $detail) = split("\n", $ibufs{$runningpid{$p}}, 2); ! $sref->{"_last_summary"} = $summary; ! $sref->{"_last_detail"} = $detail; ! # ! # reset the alertevery timer ! # ! 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; ! } # ! # change interval back to original # ! if (defined ($sref->{"failure_interval"}) && ! $sref->{"_old_interval"} != undef) { ! $sref->{"interval"} = $sref->{"_old_interval"}; ! $sref->{"_old_interval"} = undef; ! $sref->{"_next_check"} = 0; } ! $sref->{"_last_success"} = $tmnow; ! } # ! # save the output # ! $sref->{"_last_output"} = $ibufs{$runningpid{$p}}; ! reset_timer ($group, $service); - remove_proc ($p); } } --- 2878,3057 ---- } ! debug (1, "PID $p ($runningpid{$p}) exited with [" . int ($?>>8) . "]\n"); ! $sref->{"_monitor_duration"} = $tmnow - $sref->{"_last_check"}; ! $sref->{"_monitor_running"} = 0; ! ! process_event ("m", $group, $service, int ($?>>8), $ibufs{$runningpid{$p}}); + reset_timer ($group, $service); + + remove_proc ($p); + } + } + + + # + # handle the event where a monitor exits or a trap is received + # + # $type is "m" for monitor, "t" for trap + # + sub process_event { + my ($type, $group, $service, $exitval, $output) = @_; + + debug (1, "process_event type=$type group=$group service=$service exitval=$exitval output=[$output]\n"); + + my $sref = \%{$watch{$group}->{$service}}; + my $tmnow = time; + + my ($summary, $detail) = split("\n", $output, 2); + + $sref->{"_exitval"} = $exitval; + + if ($sref->{"depend"} ne "" && + $sref->{"dep_behavior"} eq "a") + { + dep_ok ($sref); + } + + # + # error exit value + # + if ($exitval) + { # ! # accounting # ! $sref->{"_failure_count"}++; ! $sref->{"_consec_failures"}++; ! $sref->{"_last_failure"} = $tmnow; ! if ($sref->{"_op_status"} == $STAT_OK || ! $sref->{"_op_status"} == $STAT_UNKNOWN || ! $sref->{"_op_status"} == $STAT_UNTESTED) { ! $sref->{"_first_failure"} = $tmnow; ! } ! set_op_status ($group, $service, $STAT_FAIL); ! $summary = "(NO SUMMARY)" if ($summary =~ /^\s*$/m); ! $sref->{"_last_summary"} = $summary; ! $sref->{"_last_detail"} = $detail; ! shift @last_failures if (@last_failures > $CF{"MAX_KEEP"}); ! push @last_failures, "$group $service" . ! " $tm $summary"; ! syslog ('crit', "failure for $last_failures[-1]"); + # + # send an alert if necessary + # + if ($type eq "m") + { + do_alert ($group, $service, $output, $exitval, $FL_MONITOR); # # change interval if needed # if (defined ($sref->{"failure_interval"}) && ! $sref->{"_old_interval"} == undef) { ! $sref->{"_old_interval"} = $sref->{"interval"}; $sref->{"interval"} = $sref->{"failure_interval"}; $sref->{"_next_check"} = 0; } } ! elsif ($type eq "t") { ! do_alert ($group, $service, $output, $exitval, $FL_TRAP); ! } ! $sref->{"_failure_output"} = $output; ! } ! # ! # success exit value ! # ! else ! { ! if ($CF{"DTLOGGING"} && defined ($sref->{"_op_status"}) && ! $sref->{"_op_status"} == $STAT_FAIL) ! { ! write_dtlog ($sref, $group, $service); ! } ! my $old_status = $sref->{"_op_status"}; ! set_op_status ($group, $service, $STAT_OK); ! if ($type eq "t") ! { ! $sref->{"_last_uptrap"} = $tmnow; ! } ! # ! # if this service has just come back up and ! # we are paying attention to this event, ! # let someone know ! # ! if ((defined ($sref->{"_op_status"})) && ! ($old_status == $STAT_FAIL) && ! (defined($sref->{"_upalert"})) && ! (!defined($sref->{"upalertafter"}) ! || (($tmnow - $sref->{"_first_failure"}) >= $sref->{"upalertafter"}))) ! { ! do_alert ($group, $service, $sref->{"_upalertoutput"}, 0, $FL_UPALERT); ! } ! # ! # send also when no upalertafter set ! # ! elsif (defined($sref->{"_upalert"}) && $old_status == $STAT_FAIL) ! { ! do_alert ($group, $service, $sref->{"_upalertoutput"}, 0, $FL_UPALERT); ! } ! ! $sref->{"_ack"} = 0; ! $sref->{"_ack_comment"} = ''; ! $sref->{"_first_failure"} = 0; ! $sref->{"_last_failure"} = 0; ! $sref->{"_consec_failures"} = 0; + # + # reset the alertevery timer + # + 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; } # ! # change interval back to original # ! if (defined ($sref->{"failure_interval"}) && ! $sref->{"_old_interval"} != undef) ! { ! $sref->{"interval"} = $sref->{"_old_interval"}; ! $sref->{"_old_interval"} = undef; ! $sref->{"_next_check"} = 0; ! } ! $sref->{"_last_success"} = $tmnow; } + + # + # save the output + # + $sref->{"_last_output"} = $output; + $sref->{"_last_summary"} = $summary; + $sref->{"_last_detail"} = $detail; } *************** *** 3162,3165 **** --- 3208,3212 ---- $sref->{"_last_check"} = scalar (time); + $sref->{"_monitor_running"} = 1; debug (1, "watching file handle ", fileno ($fhandles{"$group/$service"}), *************** *** 3729,3736 **** my $time = time; - my $noalert = 0; my %trap = (); my $flags = 0; my $tmnow = time; # --- 3776,3784 ---- my $time = time; my %trap = (); my $flags = 0; my $tmnow = time; + my $intended; + my $fromip; # *************** *** 3741,3750 **** # pas password # typ type ("failure", "up", "startup", "trap", "traptimeout") ! # spc specific type (TRAP_*) # seq sequence # grp group # svc service # hst host ! # sta status (opstatus) # tsp timestamp as time(2) value # sum summary output --- 3789,3798 ---- # pas password # typ type ("failure", "up", "startup", "trap", "traptimeout") ! # spc specific type (STAT_OK, etc.) THIS IS NO LONGER USED # seq sequence # grp group # svc service # hst host ! # sta status (same as exit status of a monitor) # tsp timestamp as time(2) value # sum summary output *************** *** 3752,3877 **** # ! foreach my $line (split (/\n/, $buf)) { ! if ($line =~ /^(\w+)=(.*)/) { ! my $trap_name = $1; ! my $trap_val = $2; ! chomp $trap_val; ! $trap_val =~ s/^\'(.*)\'$/\1/; ! $trap{$trap_name} = un_esc_str ($trap_val); } else { ! syslog ('err', "unspecified tag in trap: $line"); } - } - - $trap{"sum"} = "$trap{sum}\n" if ($trap{"sum"} !~ /\n$/); ! my ($port, $addr) = sockaddr_in ($from); ! my $fromip = inet_ntoa ($addr); ! # ! # trap authentication ! # ! my ($traphost, $trapuser, $trappass); ! if (defined ($AUTHTRAPS{"*"})) ! { ! $traphost = "*"; ! } ! ! else ! { ! $traphost = $fromip; ! } ! if (defined ($AUTHTRAPS{$traphost}{"*"})) ! { ! $trapuser = "*"; ! $trappass = ""; ! } ! else ! { ! $trapuser = $trap{"usr"}; ! $trappass = $trap{"pas"}; ! } ! if (!defined ($AUTHTRAPS{$traphost})) ! { ! syslog ('err', "received trap from unauthorized host: $fromip"); ! return undef; ! } ! if ($trapuser ne "*" && $AUTHTRAPS{$traphost}{$trapuser} && ! crypt ($trappass, $AUTHTRAPS{$traphost}{$trapuser}) ne ! $AUTHTRAPS{$traphost}{$trapuser}) ! { ! syslog ('err', "received trap from unauthorized user $trapuser, host $traphost"); ! return undef; ! } ! # ! # protocol version ! # ! if ($trap{"pro"} < $TRAP_PRO_VERSION) ! { ! syslog ('err', "cannot handle traps from version less than $TRAP_PRO_VERSION"); ! return undef; ! } ! # ! # validate trap type ! # ! if (!defined $trap{"typ"} || !defined ($trap{"spc"})) ! { ! syslog ('err', "no trap type specified from $fromip"); ! return undef; } # ! # validate trap type ! # ! ! # ! # if mon receives a trap for an unknown group/service, then the ! # default/default group/service should catch these if it is defined # - - my $intended; - if (!defined $watch{$trap{"grp"}} && defined $watch{"default"}) - { - $trap{"grp"} = "default"; - } - - if ((!defined ($groups{$trap{"grp"}}) && - !defined $watch{$trap{"grp"}}->{$trap{"svc"}}) && - (defined($groups{'default'}) && - defined($watch{'default'}->{'default'}))) - { - $intended = "$trap{'grp'}:$trap{'svc'}"; - $trap{"grp"} = "default"; - $trap{"svc"} = "default"; - } - - if (!defined ($groups{$trap{"grp"}})) - { - syslog ('err', "trap received for undefined group $trap{grp}"); - return; - } - - elsif (!defined $watch{$trap{"grp"}}->{$trap{"svc"}}) - { - syslog ('err', "trap received for undefined service type $trap{grp}/$trap{svc}"); - return; - } - my $sref = \%{$watch{$trap{"grp"}}->{$trap{"svc"}}}; - $sref->{"_last_trap"} = $time; - $sref->{"_last_detail"} = $trap{"dtl"}; - $sref->{"_last_summary"} = $trap{"sum"}; # --- 3800,3925 ---- # ! # ! # this part validates the trap ! # ! if (1) { ! foreach my $line (split (/\n/, $buf)) { ! if ($line =~ /^(\w+)=(.*)/) ! { ! my $trap_name = $1; ! my $trap_val = $2; ! chomp $trap_val; ! $trap_val =~ s/^\'(.*)\'$/\1/; ! $trap{$trap_name} = un_esc_str ($trap_val); ! } ! ! else ! { ! syslog ('err', "unspecified tag in trap: $line"); ! } ! } ! ! $trap{"sum"} = "$trap{sum}\n" if ($trap{"sum"} !~ /\n$/); ! ! my ($port, $addr) = sockaddr_in ($from); ! my $fromip = inet_ntoa ($addr); ! ! # ! # trap authentication ! # ! my ($traphost, $trapuser, $trappass); ! ! if (defined ($AUTHTRAPS{"*"})) ! { ! $traphost = "*"; } else { ! $traphost = $fromip; } ! if (defined ($AUTHTRAPS{$traphost}{"*"})) ! { ! $trapuser = "*"; ! $trappass = ""; ! } ! else ! { ! $trapuser = $trap{"usr"}; ! $trappass = $trap{"pas"}; ! } ! if (!defined ($AUTHTRAPS{$traphost})) ! { ! syslog ('err', "received trap from unauthorized host: $fromip"); ! return undef; ! } ! if ($trapuser ne "*" && $AUTHTRAPS{$traphost}{$trapuser} && ! crypt ($trappass, $AUTHTRAPS{$traphost}{$trapuser}) ne ! $AUTHTRAPS{$traphost}{$trapuser}) ! { ! syslog ('err', "received trap from unauthorized user $trapuser, host $traphost"); ! return undef; ! } ! # ! # protocol version ! # ! if ($trap{"pro"} < $TRAP_PRO_VERSION) ! { ! syslog ('err', "cannot handle traps from version less than $TRAP_PRO_VERSION"); ! return undef; ! } ! # ! # validate trap type ! # ! if (!defined $trap{"sta"}) ! { ! syslog ('err', "no trap sta value specified from $fromip"); ! return undef; ! } ! # ! # if mon receives a trap for an unknown group/service, then the ! # default/default group/service should catch these if it is defined ! # ! if (!defined $watch{$trap{"grp"}} && defined $watch{"default"}) ! { ! $trap{"grp"} = "default"; ! } ! if ((!defined ($groups{$trap{"grp"}}) && ! !defined $watch{$trap{"grp"}}->{$trap{"svc"}}) && ! (defined($groups{'default'}) && ! defined($watch{'default'}->{'default'}))) ! { ! $intended = "$trap{'grp'}:$trap{'svc'}"; ! $trap{"grp"} = "default"; ! $trap{"svc"} = "default"; ! } ! if (!defined ($groups{$trap{"grp"}})) ! { ! syslog ('err', "trap received for undefined group $trap{grp}"); ! return; ! } ! ! elsif (!defined $watch{$trap{"grp"}}->{$trap{"svc"}}) ! { ! syslog ('err', "trap received for undefined service type $trap{grp}/$trap{svc}"); ! return; ! } } # ! # trap has been validated, proceed # my $sref = \%{$watch{$trap{"grp"}}->{$trap{"svc"}}}; # *************** *** 3880,3886 **** if (exists $sref->{"traptimeout"}) { ! $sref->{"_trap_timer"} = $sref->{"traptimeout"}; } if ($intended) { --- 3928,3936 ---- if (exists $sref->{"traptimeout"}) { ! $sref->{"_trap_timer"} = $sref->{"traptimeout"}; } + $sref->{"_last_trap"} = $time; + if ($intended) { *************** *** 3888,4016 **** } - my $old_status = $sref->{"_op_status"}; - syslog ('info', "trap $trap{typ} $trap{spc} from " . "$fromip for $trap{grp} $trap{svc}, status $trap{sta}"); ! my $group = $trap{"grp"}; ! my $service = $trap{"svc"}; ! ! # ! # Not sure what I want to do with this. It's not done, and ! # just because it's here doesn't mean that it is meant to work ! # how it is coded. ! # ! if (1) ! { ! if ($trap{"spc"} == $STAT_COLDSTART) ! { ! set_op_status ($group, $service, $STAT_COLDSTART); ! $sref->{"_trap_duration_timer"} = $sref->{"trapduration"} ! if ($sref->{"trapduration"}); ! } ! ! elsif ($trap{"spc"} == $STAT_WARMSTART) ! { ! set_op_status ($group, $service, $STAT_WARMSTART); ! $sref->{"_trap_duration_timer"} = $sref->{"trapduration"} ! if ($sref->{"trapduration"}); ! $sref->{"_last_uptrap"} = $time; ! } ! ! elsif ($trap{"spc"} == $STAT_LINKDOWN) ! { ! set_op_status ($group, $service, $STAT_LINKDOWN); ! $sref->{"_failure_count"}++; ! $sref->{"_first_failure"} = $tm if ($sref->{"_op_status"} != $STAT_FAIL); ! $sref->{"_trap_duration_timer"} = $sref->{"trapduration"} ! if ($sref->{"trapduration"}); ! } ! ! elsif ($trap{"spc"} == $STAT_OK) ! { ! if ($CF{"DTLOGGING"} && defined ($sref->{"_op_status"}) && ! $sref->{"_op_status"} == $STAT_FAIL) ! { ! write_dtlog ($sref, $group, $service); ! } ! ! set_op_status ($group, $service, $STAT_OK); ! $sref->{"_last_uptrap"} = $time; ! $sref->{"_trap_duration_timer"} = $sref->{"trapduration"} ! if ($sref->{"trapduration"}); ! } ! ! elsif ($trap{"spc"} == $STAT_FAIL) ! { ! set_op_status ($group, $service, $STAT_FAIL); ! $sref->{"_first_failure"} = $tm if ($sref->{"_op_status"} != $STAT_FAIL); ! $sref->{"_trap_duration_timer"} = $sref->{"trapduration"} ! if ($sref->{"trapduration"}); ! } ! ! elsif ($trap{"spc"} == $STAT_WARN) ! { ! set_op_status ($group, $service, $STAT_WARN); ! ! # } elsif ($trap{"spc"} == $STAT_HEARTBEAT) { ! # set_op_status ($group, $service, $STAT_OK); ! # $sref->{"_last_uptrap"} = $time; ! # $noalert++; ! } ! ! else ! { ! syslog ('err', "trap received from $fromip" . ! " for undefined type $trap{typ} $trap{spc} $trap{grp}"); ! return; ! } ! } ! ! shift @last_failures if (@last_failures > $CF{"MAX_KEEP"}); ! ! push @last_failures, "$trap{grp} $trap{svc}" . ! " $tm $trap{typ} $trap{spc} $trap{sum}"; ! ! if ($sref->{"depend"} ne "" && ! $sref->{"dep_behavior"} eq "a") ! { ! dep_ok ($sref); ! } ! ! # ! # if trap is FAIL, send an alert ! # if trap is OK send upalert ! # upalert only gets sent if an upalert for this ! # trap is actually defined, and if the ! # upalertafter config is satisfied ! # ! ! $flags = 0; ! ! if ( $trap{"spc"} == $STAT_OK ) { ! ! $flags = $FL_UPALERT; ! ! if ( defined($sref->{"_upalert"}) ) { ! if ( $tmnow - $sref->{"_first_failure"} < ! $sref->{"upalertafter"}) ! { ! $noalert++; ! } ! } ! else { ! $noalert++; ! } ! } ! #### else just fall through and send alert ! do_alert ( ! $trap{"grp"}, ! $trap{"svc"}, ! $trap{"sum"} . $trap{"dtl"}, ! $trap{"sta"}, ! $FL_TRAP | $flags, ! ) unless ($noalert); if( defined($sref->{"_intended"}) ) --- 3938,3951 ---- } syslog ('info', "trap $trap{typ} $trap{spc} from " . "$fromip for $trap{grp} $trap{svc}, status $trap{sta}"); ! debug (1, "trap type=$trap{typ} spc=$trap{spc} from " . ! "$fromip grp=$trap{grp} svc=$trap{svc}, sta=$trap{sta}\n"); ! $sref->{"_trap_duration_timer"} = $sref->{"trapduration"} ! if ($sref->{"trapduration"}); ! process_event ("t", $trap{"grp"}, $trap{"svc"}, $trap{"sta"}, "$trap{sum}\n$trap{dtl}"); if( defined($sref->{"_intended"}) ) *************** *** 4033,4046 **** $sref->{"_trap_timer"} = $sref->{"traptimeout"}; $sref->{"_failure_count"}++; $sref->{"_last_failure"} = $tmnow; ! $sref->{"_first_failure"} = $tmnow if ($sref->{"_op_status"} != $STAT_FAIL); set_op_status ($group, $service, $STAT_FAIL); $sref->{"_last_summary"} = "trap timeout"; ! $sref->{"_last_detail"} = ""; shift @last_failures if (@last_failures > $CF{"MAX_KEEP"}); push @last_failures, "$group $service $tm $sref->{_last_summary}"; syslog ('crit', "failure for $last_failures[-1]"); ! do_alert ($group, $service, undef, undef, $FL_TRAPTIMEOUT); } --- 3968,3990 ---- $sref->{"_trap_timer"} = $sref->{"traptimeout"}; $sref->{"_failure_count"}++; + $sref->{"_consec_failures"}++; $sref->{"_last_failure"} = $tmnow; ! if ($sref->{"_op_status"} == $STAT_OK || ! $sref->{"_op_status"} == $STAT_UNKNOWN || ! $sref->{"_op_status"} == $STAT_UNTESTED) ! { ! $sref->{"_first_failure"} = $tmnow; ! } set_op_status ($group, $service, $STAT_FAIL); $sref->{"_last_summary"} = "trap timeout"; ! $sref->{"_last_detail"} = "trap timeout after " . $sref->{"traptimeout"} . "s at " . localtime ($tmnow) . "\n"; shift @last_failures if (@last_failures > $CF{"MAX_KEEP"}); push @last_failures, "$group $service $tm $sref->{_last_summary}"; syslog ('crit', "failure for $last_failures[-1]"); ! do_alert ($group, $service, "$sref->{_last_summary}\n$sref->{_last_detail}", ! 0, $FL_TRAPTIMEOUT); ! ! $sref->{"_failure_output"} = "$sref->{_last_summary}\n$sref->{_last_detail}"; } *************** *** 4656,4664 **** } - my $t; - $t = "-u" if ($args{"flags"} & $FL_UPALERT); - $t = "-T" if ($args{"flags"} & $FL_TRAP); - $t = "-O" if ($args{"flags"} & $FL_TRAPTIMEOUT); - my @execargs = ( $alert, --- 4600,4603 ---- *************** *** 4669,4675 **** ); ! if ($t) { ! push @execargs, $t; ! } if ($args{"args"} ne "") { --- 4608,4614 ---- ); ! push (@execargs, "-u") if ($args{"flags"} & $FL_UPALERT); ! push (@execargs, "-T") if ($args{"flags"} & $FL_TRAP); ! push (@execargs, "-O") if ($args{"flags"} & $FL_TRAPTIMEOUT); if ($args{"args"} ne "") { |