diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index 371f2b0a24..ff41b94000 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,9 @@ +2010-07-28 Junichi Satoh + + * lib/PandoraFMS/PredictionServer.pm: Fixed problem that pandora + server daemon is aborted by division by zero, if numeric data to + predict are mostly 0. + 2010-07-27 Ramon Novoa * lib/PandoraFMS/Core.pm: Make sure delete_pending is set to 0 diff --git a/pandora_server/lib/PandoraFMS/PredictionServer.pm b/pandora_server/lib/PandoraFMS/PredictionServer.pm index 933d9ab55f..51f9879c5e 100644 --- a/pandora_server/lib/PandoraFMS/PredictionServer.pm +++ b/pandora_server/lib/PandoraFMS/PredictionServer.pm @@ -205,7 +205,7 @@ sub exec_prediction_module ($$$$) { next unless defined ($first_data); $sum_data++ if ($last_data != 0); $sum_data++ if ($first_data != 0); - $week_data[$i] = (($last_data + $first_data) / $sum_data); + $week_data[$i] = ($sum_data > 0) ? (($last_data + $first_data) / $sum_data) : 0; } else { $week_data[$i] = $average_interval; } @@ -232,7 +232,7 @@ sub exec_prediction_module ($$$$) { $typical_deviation = $typical_deviation + (($week_data[$i] - $average)**2); } } - $typical_deviation = sqrt ($typical_deviation / ($n-1)); + $typical_deviation = ($n > 1) ? sqrt ($typical_deviation / ($n-1)) : 0; my $current_value = get_db_value ($dbh, 'SELECT datos FROM tagente_estado WHERE id_agente_modulo = ?', $target_module->{'id_agente_modulo'}); if ( ($current_value > ($average - $typical_deviation)) && ($current_value < ($average + $typical_deviation)) ){