From 14d2755ffe8dbcb0a56f058fdf8b7440a907c662 Mon Sep 17 00:00:00 2001 From: pabloconcepcion Date: Fri, 15 Jan 2010 14:06:48 +0000 Subject: [PATCH] =?UTF-8?q?2010-01-15=20=20Pablo=20de=20la=20Concepci?= =?UTF-8?q?=C3=B3n=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * lib/PandoraFMS/Core.pm, lib/PandoraFMS/DataServer.pm: Fixed a bug with some parameters called on wrong order, standarized the order of the position parameters so always is longitude, latitude, altitude. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2274 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/ChangeLog | 6 ++++++ pandora_server/lib/PandoraFMS/Core.pm | 15 +++++++-------- pandora_server/lib/PandoraFMS/DataServer.pm | 8 ++++---- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index 42bfa650b3..f6954757ab 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,9 @@ +2010-01-15 Pablo de la ConcepciĆ³n + + * lib/PandoraFMS/Core.pm, lib/PandoraFMS/DataServer.pm: Fixed a bug with + some parameters called on wrong order, standarized the order of the + position parameters so always is longitude, latitude, altitude. + 2010-01-15 Pablo de la ConcepciĆ³n * lib/PandoraFMS/Core.pm: Modified to have different functions for the diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 9b31584feb..351f8d20f7 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -754,12 +754,12 @@ sub pandora_update_agent_gis ($$$$$$$$$$$) { # Get the last position to see if it has moved. my $last_agent_info= get_db_single_row ($dbh, 'SELECT * FROM tagente WHERE id_agente = ?', $agent_id); - logger($pa_config, "Old Agent data: last-latitude = ". $last_agent_info->{'last_longitude'}. " ID: $agent_id ", 10); + logger($pa_config, "Old Agent data: last-longitude = ". $last_agent_info->{'last_longitude'}. " ID: $agent_id ", 10); # If the agent has moved outside the range stablised as - if (distance_moved($last_agent_info->{'last_latitude'}, $last_agent_info->{'last_longitude'},$last_agent_info->{'last_altitude'}, $latitude, $longitude, $altitude) > 10 ){ + if (distance_moved($last_agent_info->{'last_longitude'}, $last_agent_info->{'last_latitude'}, $last_agent_info->{'last_altitude'}, $longitude, $latitude, $altitude) > 10 ){ # Save the agent data in the agent table - save_agent_position($pa_config, $timestamp, $last_agent_info->{'last_latitude'}, $last_agent_info->{'last_longitude'},$last_agent_info->{'last_altitude'}, $agent_id, $dbh); + save_agent_position($pa_config, $timestamp, $last_agent_info->{'last_longitude'},$last_agent_info->{'last_latitude'}, $last_agent_info->{'last_altitude'}, $agent_id, $dbh); } else { # Update the end timestamp for the agent @@ -768,13 +768,12 @@ sub pandora_update_agent_gis ($$$$$$$$$$$) { db_do ($dbh, 'UPDATE tagente SET intervalo = ?, agent_version = ?, ultimo_contacto_remoto = ?, ultimo_contacto = ?, os_version = ?, timezone_offset = ?, last_longitude = ?, last_latitude =?, last_altitude = ? WHERE id_agente = ?', - $agent_interval, $agent_version, $agent_timestamp, $timestamp, $os_version, $timezone_offset, $last_agent_info->{'last_latitude'}, $last_agent_info->{'last_longitude'}, - $last_agent_info->{'last_altitude'}, $agent_id); + $agent_interval, $agent_version, $agent_timestamp, $timestamp, $os_version, $timezone_offset, $longitude, $latitude, $altitude, $agent_id); } sub distance_moved ($$$$$$) { - my ($last_latitude, $last_longitude, $last_altiude, $latitude, $longitude, $altitude) = @_; + my ($last_longitude, $last_latitude, $last_altiude, $longitude, $latitude, $altitude) = @_; # Quick and dirty function to check if the point has moved. # $prec_factor = 1000000; @@ -1358,7 +1357,7 @@ sub pandora_inhibit_alerts ($$$) { sub update_agent_position($$$$) { my ($pa_config, $timestamp, $agent_id, $dbh) = @_; - logger($pa_config, "Updating agent position: end_timestamp=$timestamp agent_id=$agent_id", 10); + logger($pa_config, "Updating agent end_timestamp: end_timestamp=$timestamp agent_id=$agent_id", 10); # Find the last data from the received agent my $agent_position = get_db_single_row ($dbh, 'SELECT * FROM tgis_data WHERE tagente_id_agente = ? ORDER BY start_timestamp DESC LIMIT 1', $agent_id ); @@ -1375,7 +1374,7 @@ sub update_agent_position($$$$) { sub save_agent_position($$$$$$$) { my ($pa_config, $timestamp, $longitude,$latitude, $altitude, $agent_id, $dbh) = @_; - logger($pa_config, "Updating agent position: timestamp=$timestamp latitude=$latitude longitude=$longitude altitude=$altitude", 10); + logger($pa_config, "Saving new agent position: timestamp=$timestamp longitude=$longitude latitude=$latitude altitude=$altitude", 10); db_insert($dbh, 'INSERT INTO tgis_data (`longitude`, `latitude`, `altitude`, `tagente_id_agente`, `start_timestamp`, `end_timestamp`) VALUES (?, ?, ?, ?, ?, ?)', $longitude, $latitude, $altitude, $agent_id, $timestamp, $timestamp); diff --git a/pandora_server/lib/PandoraFMS/DataServer.pm b/pandora_server/lib/PandoraFMS/DataServer.pm index e96c39301d..53f13e8ea3 100644 --- a/pandora_server/lib/PandoraFMS/DataServer.pm +++ b/pandora_server/lib/PandoraFMS/DataServer.pm @@ -158,8 +158,8 @@ sub process_xml_data ($$$$$) { $data->{'interval'}, $data->{'os_version'}); # Get GIS information - my ($timezone_offset, $latitude, $longitude, $altitude) = ($data->{'timezone_offset'}, - $data->{'latitude'}, $data->{'longitude'}, $data->{'altitude'}); + my ($timezone_offset, $longitude, $latitude, $altitude) = ($data->{'timezone_offset'}, + $data->{'longitude'}, $data->{'latitude'}, $data->{'altitude'}); # Validate the GIS informtation # Timezone offset must be an integer beween -12 and +12 @@ -179,7 +179,7 @@ sub process_xml_data ($$$$$) { $altitude = 0.0; # Default value } - logger($pa_config, "Getting GIS Data=timezone_offset=$timezone_offset latitude=$latitude longitude=$longitude altitude=$altitude", 10); + logger($pa_config, "Getting GIS Data=timezone_offset=$timezone_offset longitude=$longitude latitude=$latitude altitude=$altitude", 10); # Unknown agent! if (! defined ($agent_name) || $agent_name eq '') { @@ -227,7 +227,7 @@ sub process_xml_data ($$$$$) { logger($pa_config, "Updating agent $agent_name at long: $longitude lat: $latitude alt: $altitude", 5); # Update agent information including position information - pandora_update_agent_gis ($pa_config, $timestamp, $agent_id, $os_version, $agent_version, $interval, $timezone_offset, $latitude, $longitude, $altitude, $dbh); + pandora_update_agent_gis ($pa_config, $timestamp, $agent_id, $os_version, $agent_version, $interval, $timezone_offset, $longitude, $latitude, $altitude, $dbh); pandora_module_keep_alive ($pa_config, $agent_id, $agent_name, $server_id, $dbh);