2010-11-18 Ramon Novoa <rnovoa@artica.es>

* lib/PandoraFMS/Core.pm,
	  lib/PandoraFMS/DataServer.pm: Update agent address from the XML.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3602 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
ramonn 2010-11-18 18:24:21 +00:00
parent 2cfdfa8d05
commit 61fbdcd4c6
3 changed files with 33 additions and 2 deletions

View File

@ -1,3 +1,8 @@
2010-11-18 Ramon Novoa <rnovoa@artica.es>
* lib/PandoraFMS/Core.pm,
lib/PandoraFMS/DataServer.pm: Update agent address from the XML.
2010-11-16 Ramon Novoa <rnovoa@artica.es>
* lib/PandoraFMS/Core.pm: Decode HTML entities in macros.

View File

@ -80,6 +80,8 @@ Exported Functions:
=item * C<pandora_update_agent>
=item * C<pandora_update_agent_address>
=item * C<pandora_update_module_on_error>
=item * C<pandora_update_server>
@ -148,6 +150,7 @@ our @EXPORT = qw(
pandora_reset_server
pandora_server_keep_alive
pandora_update_agent
pandora_update_agent_address
pandora_update_module_on_error
pandora_update_module_from_hash
pandora_update_server
@ -1008,6 +1011,20 @@ sub pandora_update_agent ($$$$$$$;$$$$$$) {
}
##########################################################################
=head2 C<< pandora_update_agent_address(I<$pa_config>, I<$agent_id>, I<$address>, I<$dbh>) >>
Update the address of an agent.
=cut
##########################################################################
sub pandora_update_agent_address ($$$$$) {
my ($pa_config, $agent_id, $agent_name, $address, $dbh) = @_;
logger($pa_config, 'Updating address for agent ' . $agent_name . ' (' . $address . ')', 10);
db_do ($dbh, 'UPDATE tagente SET direccion = ? WHERE id_agente = ?', $address, $agent_id);
}
##########################################################################
=head2 C<< pandora_module_keep_alive (I<$pa_config>, I<$id_agent>, I<$agent_name>, I<$server_id>, I<$dbh>) >>

View File

@ -268,6 +268,10 @@ sub process_xml_data ($$$$$) {
# Check some variables
$interval = 300 if (! defined ($interval) || $interval eq '');
$os_version = 'N/A' if (! defined ($os_version) || $os_version eq '');
# Get agent address from the XML if available
my $address = '' ;
$address = $data->{'address'} if (defined ($data->{'address'}));
# Get agent id
$AgentSem->down ();
@ -290,12 +294,12 @@ sub process_xml_data ($$$$$) {
# Create the agent
if ($valid_position_data == 1 && $pa_config->{'activate_gis'} != 0 ) {
logger($pa_config, "Creating agent $agent_name at long: $longitude lat: $latitude alt: $altitude", 5);
$agent_id = pandora_create_agent($pa_config, $pa_config->{'servername'}, $agent_name, '', $group_id, $parent_id, $os,
$agent_id = pandora_create_agent($pa_config, $pa_config->{'servername'}, $agent_name, $address, $group_id, $parent_id, $os,
$description, $interval, $dbh, $timezone_offset, $longitude, $latitude, $altitude, $position_description);
}
else { # Ignore agent positional data
logger($pa_config, "Creating agent $agent_name", 5);
$agent_id = pandora_create_agent($pa_config, $pa_config->{'servername'}, $agent_name, '', $group_id, $parent_id, $os,
$agent_id = pandora_create_agent($pa_config, $pa_config->{'servername'}, $agent_name, $address, $group_id, $parent_id, $os,
$description, $interval, $dbh, $timezone_offset);
}
if (! defined ($agent_id)) {
@ -320,6 +324,11 @@ sub process_xml_data ($$$$$) {
$os_version = $agent->{'os_version'};
$agent_version = $agent->{'agent_version'};
$timezone_offset = $agent->{'timezone_offset'};
} else {
# Update agent address if necessary
if ($address ne '' && $address ne $agent->{'direccion'}) {
pandora_update_agent_address ($pa_config, $agent_id, $agent_name, $address, $dbh);
}
}
if ($valid_position_data == 1 && $pa_config->{'activate_gis'} != 0) {