mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-29 00:34:46 +02:00
Allow both behaviours in alert time slots
This commit is contained in:
parent
4eaee57c75
commit
6817278c2f
@ -552,30 +552,43 @@ sub pandora_evaluate_alert ($$$$$$$;$$$$) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
my $schedule = PandoraFMS::Tools::p_decode_json($pa_config, $alert->{'schedule'});
|
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) && ref $schedule eq "HASH";
|
return $status unless defined($schedule->{$DayNames[$wday]});
|
||||||
|
|
||||||
return $status unless defined($schedule->{$DayNames[$wday]});
|
return $status unless ref($schedule->{$DayNames[$wday]}) eq "ARRAY";
|
||||||
|
|
||||||
return $status unless ref($schedule->{$DayNames[$wday]}) eq "ARRAY";
|
my $time = sprintf ("%.2d:%.2d:%.2d", $hour, $min, $sec);
|
||||||
|
|
||||||
my $time = sprintf ("%.2d:%.2d:%.2d", $hour, $min, $sec);
|
#
|
||||||
|
# Check time slots
|
||||||
|
#
|
||||||
|
my $inSlot = 0;
|
||||||
|
foreach my $timeBlock (@{$schedule->{$DayNames[$wday]}}) {
|
||||||
|
if ($timeBlock->{'start'} eq $timeBlock->{'end'}) {
|
||||||
|
# All day.
|
||||||
|
$inSlot = 1;
|
||||||
|
} elsif ($timeBlock->{'start'} le $time && $timeBlock->{'end'} ge $time) {
|
||||||
|
# In range.
|
||||||
|
$inSlot = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#
|
return $status if $inSlot eq 0;
|
||||||
# Check time slots
|
} else {
|
||||||
#
|
# Old behaviour.
|
||||||
my $inSlot = 0;
|
# Check time slot
|
||||||
foreach my $timeBlock (@{$schedule->{$DayNames[$wday]}}) {
|
my $time = sprintf ("%.2d:%.2d:%.2d", $hour, $min, $sec);
|
||||||
if ($timeBlock->{'start'} eq $timeBlock->{'end'}) {
|
if (($alert->{'time_from'} ne $alert->{'time_to'})) {
|
||||||
# All day.
|
if ($alert->{'time_from'} lt $alert->{'time_to'}) {
|
||||||
$inSlot = 1;
|
return $status if (($time le $alert->{'time_from'}) || ($time ge $alert->{'time_to'}));
|
||||||
} elsif ($timeBlock->{'start'} le $time && $timeBlock->{'end'} ge $time) {
|
} else {
|
||||||
# In range.
|
return $status if (($time le $alert->{'time_from'}) && ($time ge $alert->{'time_to'}));
|
||||||
$inSlot = 1;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $status if $inSlot eq 0;
|
|
||||||
|
|
||||||
# Check time threshold
|
# Check time threshold
|
||||||
my $limit_utimestamp = $alert->{'last_reference'} + $alert->{'time_threshold'};
|
my $limit_utimestamp = $alert->{'last_reference'} + $alert->{'time_threshold'};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user