diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index 80d2fbb401..f680c2ab17 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,13 @@ +2011-12-01 Juan Manuel Ramon + + * lib/PandoraFMS/NetworkServer.pm + lib/PandoraFMS/WMIServer.pm + lib/PandoraFMS/PluginServer.pm + lib/PandoraFMS/PredictionServer.pm: Fixed os_version when an agent + is updated. + + Fixes: #3314285 + 2011-12-01 Juan Manuel Ramon * lib/PandoraFMS/DB.pm diff --git a/pandora_server/lib/PandoraFMS/NetworkServer.pm b/pandora_server/lib/PandoraFMS/NetworkServer.pm index 76cbff30db..ea05db671e 100644 --- a/pandora_server/lib/PandoraFMS/NetworkServer.pm +++ b/pandora_server/lib/PandoraFMS/NetworkServer.pm @@ -393,7 +393,9 @@ sub exec_network_module ($$$$) { my $module_result = 1; # Fail by default my $module_data = 0; my $id_agente = $module->{'id_agente'}; - my $agent_name = get_agent_name ($dbh, $id_agente); + my $agent_row = get_db_single_row ($dbh, 'SELECT * FROM tagente WHERE id_agente = ?', $id_agente); + my $agent_name = $agent_row->{'nombre'}; + my $agent_os_version = $agent_row->{'os_version'}; my $id_tipo_modulo = $module->{'id_tipo_modulo'}; my $ip_target = $module->{'ip_target'}; my $snmp_oid = $module->{'snmp_oid'}; @@ -481,8 +483,12 @@ sub exec_network_module ($$$$) { my %data = ("data" => $module_data); pandora_process_module ($pa_config, \%data, '', $module, '', $timestamp, $utimestamp, $server_id, $dbh); + if ($agent_os_version eq ''){ + $agent_os_version = $pa_config->{'servername'}.'_Net'; + } + # Update agent last contact using Pandora version as agent version - pandora_update_agent ($pa_config, $timestamp, $id_agente, $pa_config->{'servername'}.'_Net', $pa_config->{'version'}, -1, $dbh); + pandora_update_agent ($pa_config, $timestamp, $id_agente, $agent_os_version, $pa_config->{'version'}, -1, $dbh); } else { # Modules who cannot connect or something go bad, update last_execution_try field diff --git a/pandora_server/lib/PandoraFMS/PluginServer.pm b/pandora_server/lib/PandoraFMS/PluginServer.pm index a5d6a93d93..d4267bd035 100644 --- a/pandora_server/lib/PandoraFMS/PluginServer.pm +++ b/pandora_server/lib/PandoraFMS/PluginServer.pm @@ -213,7 +213,14 @@ sub data_consumer ($$) { my %data = ("data" => $module_data); pandora_process_module ($pa_config, \%data, '', $module, '', $timestamp, $utimestamp, $self->getServerID (), $dbh); - pandora_update_agent ($pa_config, $timestamp, $module->{'id_agente'}, $pa_config->{'servername'}.'_Plugin', $pa_config->{'version'}, -1, $dbh); + + my $agent_os_version = get_db_value ($dbh, 'SELECT os_version FROM tagente WHERE id_agente = ?', $module->{'id_agente'}); + + if ($agent_os_version eq ''){ + $agent_os_version = $pa_config->{'servername'}.'_Plugin'; + } + + pandora_update_agent ($pa_config, $timestamp, $module->{'id_agente'}, $agent_os_version, $pa_config->{'version'}, -1, $dbh); } 1; diff --git a/pandora_server/lib/PandoraFMS/PredictionServer.pm b/pandora_server/lib/PandoraFMS/PredictionServer.pm index b8beea0625..e21978ea24 100644 --- a/pandora_server/lib/PandoraFMS/PredictionServer.pm +++ b/pandora_server/lib/PandoraFMS/PredictionServer.pm @@ -256,7 +256,14 @@ sub exec_prediction_module ($$$$) { my %data = ("data" => $module_data); pandora_process_module ($pa_config, \%data, '', $agent_module, '', $timestamp, $utimestamp, $server_id, $dbh); - pandora_update_agent ($pa_config, $timestamp, $agent_module->{'id_agente'}, $pa_config->{'servername'}.'_Prediction', $pa_config->{'version'}, -1, $dbh); + + my $agent_os_version = get_db_value ($dbh, 'SELECT os_version FROM tagente WHERE id_agente = ?', $agent_module->{'id_agente'}); + + if ($agent_os_version eq ''){ + $agent_os_version = $pa_config->{'servername'}.'_Prediction'; + } + + pandora_update_agent ($pa_config, $timestamp, $agent_module->{'id_agente'}, $agent_os_version, $pa_config->{'version'}, -1, $dbh); } 1; diff --git a/pandora_server/lib/PandoraFMS/WMIServer.pm b/pandora_server/lib/PandoraFMS/WMIServer.pm index 8e6f173467..b717dd8dbd 100644 --- a/pandora_server/lib/PandoraFMS/WMIServer.pm +++ b/pandora_server/lib/PandoraFMS/WMIServer.pm @@ -197,7 +197,14 @@ sub data_consumer ($$) { my %data = ("data" => $module_data); pandora_process_module ($pa_config, \%data, '', $module, '', $timestamp, $utimestamp, $self->getServerID (), $dbh); - pandora_update_agent ($pa_config, $timestamp, $module->{'id_agente'}, $pa_config->{'servername'} . '_WMI', $pa_config->{'version'}, -1, $dbh); + + my $agent_os_version = get_db_value ($dbh, 'SELECT os_version FROM tagente WHERE id_agente = ?', $module->{'id_agente'}); + + if ($agent_os_version eq ''){ + $agent_os_version = $pa_config->{'servername'}.'_WMI'; + } + + pandora_update_agent ($pa_config, $timestamp, $module->{'id_agente'}, $agent_os_version, $pa_config->{'version'}, -1, $dbh); } 1;