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);
}
}
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'} ) {
$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));
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");