When mon is restarted, the alerts_sent value is reset even though the history is read.
Is there a way to get  readhistoricfile() to update the alert_count also?
Would it be safe to do the following to put the alert counts in the periods back?  
It seems to be working now for me.

*** mon Sat Sep  8 08:42:05 2001
--- mon.saved   Thu Feb 28 16:35:58 2002
***************
*** 4457,4462 ****
--- 4458,4465 ----
      }
  
      my $epochLimit = 0;
+       my %alertpertime = {};
+ 
      if ($CF{"HISTORICTIME"} != 0) {
        $epochLimit = time - $CF{"HISTORICTIME"};
      }
***************
*** 4466,4472 ****
      while (<HISTFILE>) {
        next if (/^\s*$/ || /^\s*#/);
        chomp;
!       my $epochAlert = (split(/\s+/))[3];
        push (@last_alerts, $_) if ($epochAlert >= $epochLimit);
      }
  
--- 4469,4490 ----
      while (<HISTFILE>) {
        next if (/^\s*$/ || /^\s*#/);
        chomp;
! 
!       my ($alerttype,$group,$service,$epochAlert,$junk) = split(/\s+/,$_,5);
!     my $sref = \%{$watch{$group}->{$service}};
! 
! 
!     foreach my $periodlabel (keys %{$sref->{"periods"}})
!     {
!       if ( inPeriod ($epochAlert, $sref->{"periods"}->{$periodlabel}->{"period"})) {
!                               my $pref = \%{$sref->{"periods"}->{$periodlabel}};
!                 $pref->{"_alert_sent"}++  if ($alerttype eq "alert" && 
!defined($alertpertime{$epochAlert}));
!                 $pref->{"_alert_sent"}=0  if ($alerttype eq "upalert");
! 
!               }
!       }
!       $alertpertime{$epochAlert} = 1;
! 
                push (@last_alerts, $_) if ($epochAlert >= $epochLimit);
      }


Gerald Skerbitz MDH-Environmental Health IRM
651-215-0740  TextPage: [EMAIL PROTECTED]
http://mdh-fyi.health.state.mn.us/divs/eh/information/gerry-page.html



Reply via email to