2009-11-10 Ramon Novoa <rnovoa@artica.es>

* lib/PandoraFMS/PredictionServer.pm: Fixed bug #2894950.

        * lib/PandoraFMS/DataServer.pm: Fixed bug #2894737.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2101 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
ramonn 2009-11-10 12:25:10 +00:00
parent 0e656c5e4c
commit 12ee77bda5
3 changed files with 17 additions and 4 deletions

View File

@ -1,3 +1,9 @@
2009-11-10 Ramon Novoa <rnovoa@artica.es>
* lib/PandoraFMS/PredictionServer.pm: Fixed bug #2894950.
* lib/PandoraFMS/DataServer.pm: Fixed bug #2894737.
2009-11-08 Sancho Lerena <slerena@artica.es>
* util/pandora_checkdep.pl: Deleted old dep checker, not used anymore.

View File

@ -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);

View File

@ -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;