Allow both behaviours in alert time slots

This commit is contained in:
fbsanchez 2022-02-22 11:58:53 +01:00
parent 4eaee57c75
commit 6817278c2f
1 changed files with 30 additions and 17 deletions

View File

@ -552,7 +552,8 @@ sub pandora_evaluate_alert ($$$$$$$;$$$$) {
}
my $schedule = PandoraFMS::Tools::p_decode_json($pa_config, $alert->{'schedule'});
if (defined($schedule)) {
# New behaviour.
return $status unless defined($schedule) && ref $schedule eq "HASH";
return $status unless defined($schedule->{$DayNames[$wday]});
@ -576,6 +577,18 @@ sub pandora_evaluate_alert ($$$$$$$;$$$$) {
}
return $status if $inSlot eq 0;
} else {
# Old behaviour.
# Check time slot
my $time = sprintf ("%.2d:%.2d:%.2d", $hour, $min, $sec);
if (($alert->{'time_from'} ne $alert->{'time_to'})) {
if ($alert->{'time_from'} lt $alert->{'time_to'}) {
return $status if (($time le $alert->{'time_from'}) || ($time ge $alert->{'time_to'}));
} else {
return $status if (($time le $alert->{'time_from'}) && ($time ge $alert->{'time_to'}));
}
}
}
# Check time threshold
my $limit_utimestamp = $alert->{'last_reference'} + $alert->{'time_threshold'};