From c06189af9fb1133ae13ba2257b52668ff1b99cff Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Tue, 14 Dec 2021 11:30:03 +0100 Subject: [PATCH] Clip predictions if the module has max. and min. values. --- pandora_server/lib/PandoraFMS/PredictionServer.pm | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pandora_server/lib/PandoraFMS/PredictionServer.pm b/pandora_server/lib/PandoraFMS/PredictionServer.pm index 45d9a8fb2f..80fcfd64d7 100644 --- a/pandora_server/lib/PandoraFMS/PredictionServer.pm +++ b/pandora_server/lib/PandoraFMS/PredictionServer.pm @@ -286,6 +286,16 @@ sub exec_capacity_planning_module($$$$) { if ($type eq 'estimation_absolute') { # y = theta_0 + x * theta_1 $pred = $theta_0 + ($now + $target_value) * $theta_1; + + # Clip predictions. + if ($target_module->{'max'} != $target_module->{'min'}) { + if ($pred < $target_module->{'min'}) { + $pred = $target_module->{'min'}; + } + elsif ($pred > $target_module->{'max'}) { + $pred = $target_module->{'max'}; + } + } } # Predict the date. else {