diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index 183d5a5c7b..61cdb1b8d4 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,9 @@ +2009-11-10 Ramon Novoa + + * lib/PandoraFMS/PredictionServer.pm: Fixed bug #2894950. + + * lib/PandoraFMS/DataServer.pm: Fixed bug #2894737. + 2009-11-08 Sancho Lerena * util/pandora_checkdep.pl: Deleted old dep checker, not used anymore. diff --git a/pandora_server/lib/PandoraFMS/DataServer.pm b/pandora_server/lib/PandoraFMS/DataServer.pm index ce6fe348b9..bc94d46527 100644 --- a/pandora_server/lib/PandoraFMS/DataServer.pm +++ b/pandora_server/lib/PandoraFMS/DataServer.pm @@ -41,6 +41,7 @@ my @TaskQueue :shared; my %PendingTasks :shared; my $Sem :shared = Thread::Semaphore->new; my $TaskSem :shared = Thread::Semaphore->new (0); +my $AgentSem :shared = Thread::Semaphore->new (1); ######################################################################################## # Data Server class constructor. @@ -171,10 +172,12 @@ sub process_xml_data ($$$$) { $os_version = 'N/A' if (! defined ($os_version) || $os_version eq ''); # Get agent id + $AgentSem->down (); my $agent_id = get_agent_id ($dbh, $agent_name); if ($agent_id < 1) { if ($pa_config->{'autocreate'} == 0) { logger($pa_config, "ERROR: There is no agent defined with name $agent_name", 3); + $AgentSem->up (); return; } @@ -188,8 +191,12 @@ sub process_xml_data ($$$$) { # Create the agent $agent_id = pandora_create_agent ($pa_config, $pa_config->{'servername'}, $agent_name, '', 0, $group_id, 0, $os, $description, $dbh); - return unless defined ($agent_id); + if (! defined ($agent_id)) { + $AgentSem->up (); + return; + } } + $AgentSem->up (); pandora_update_agent ($pa_config, $timestamp, $agent_id, $os_version, $agent_version, $interval, $dbh); pandora_module_keep_alive ($pa_config, $agent_id, $agent_name, $server_id, $dbh); diff --git a/pandora_server/lib/PandoraFMS/PredictionServer.pm b/pandora_server/lib/PandoraFMS/PredictionServer.pm index c34f355911..7f00cf36e7 100644 --- a/pandora_server/lib/PandoraFMS/PredictionServer.pm +++ b/pandora_server/lib/PandoraFMS/PredictionServer.pm @@ -190,11 +190,11 @@ sub exec_prediction_module ($$$$) { # Need to get data outside interval because no data. if (!(defined($average_interval)) || ($average_interval == 0)) { $last_data = get_db_value ($dbh, 'SELECT datos FROM tagente_datos WHERE id_agente_modulo = ? AND utimestamp > ? LIMIT 1', $target_module->{'id_agente_modulo'}, $week_utimestamp[$i]); - $sum_data++ if ($last_data != 0); - + next unless defined ($last_data); $first_data = get_db_value ($dbh, 'SELECT datos FROM tagente_datos WHERE id_agente_modulo = ? AND utimestamp < ? LIMIT 1', $target_module->{'id_agente_modulo'}, $temp1); + 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); } else { $week_data[$i] = $average_interval;