From: Stephen L Johnson Date: Wed, 3 May 2000 21:25:24 +0000 (+0000) Subject: prevously down services where having status redowngraded to yellow at start of main... X-Git-Tag: spong-2_7-alpha5 X-Git-Url: http://git.etc.gen.nz/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=20ff7dfdde76510e5e0fa4e2d6c6d4fb1ef7ced9;p=spong.git prevously down services where having status redowngraded to yellow at start of main loop. critical count for services were notbeing restarted at start of main loop. --- diff --git a/src/spong-network.pl b/src/spong-network.pl index 295a2f5..6f90a8b 100755 --- a/src/spong-network.pl +++ b/src/spong-network.pl @@ -86,6 +86,8 @@ while( 1 ) { foreach my $check ( split(/\s+/,$HOSTS{$host}->{'services'}) ) { $0 = "spong-network (checking $host/$check)"; + # Reset the critical error count + $HOSTS{$host}->{'service'}->{$check}->{'count'} = 0; &do_check($host,$check); } } @@ -136,7 +138,7 @@ exit(0); sub do_check { my ($host,$service) = @_; - my ( $crit_count); + my ( $crit_count ); # Get the hosts current color and warning count for service if (defined $HOSTS{$host}->{'service'}->{$service}->{'count'} ) { @@ -145,6 +147,10 @@ sub do_check { $crit_count = 0; } + # Get last known status + my $laststatus = $HOSTS{$host}->{'service'}->{$service}->{'laststatus'} + || 'green'; + # Call the check function as referenced by the PLUGIN hash eval { ($status,$summary,$message) = (&{$PLUGINS{$service}}($host)); @@ -157,18 +163,24 @@ sub do_check { my $color; - # If current status is critical, increment the critcal count counter + # If current status is critical, increment the critical count counter # If counter < $CRIT_WARN_LEVEL, reduce status to yellow - # else pass a critical as a critical + # else pass a critical as a critical # If current status is not red, reset the critical level counter. if ($status eq 'red') { $crit_count += 1; - $color = ($crit_count < $CRIT_WARN_LEVEL) ? 'yellow' : 'red'; + if ($crit_count < $CRIT_WARN_LEVEL) { + $color = 'yellow' if $laststatus eq 'green'; + } else { + $color = 'red'; + $HOSTS{$host}->{'service'}->{$service}->{'laststatus'} = 'red'; + } $summary = "($crit_count/$CRIT_WARN_LEVEL) " . $summary; push @bad_checks, "$host $service" if ($crit_count < $CRIT_WARN_LEVEL); } else { $crit_count = 0; $color = $status; + $HOSTS{$host}->{'service'}->{$service}->{'laststatus'} = 'green'; } &debug("$status - $crit_count - $CRIT_WARN_LEVEL - $color - $summary");