2010-01-15 Pablo de la Concepción <pablo.concepcion@artica.es>
* 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
This commit is contained in:
parent
c185bdd415
commit
14d2755ffe
|
@ -1,3 +1,9 @@
|
|||
2010-01-15 Pablo de la Concepción <pablo.concepcion@artica.es>
|
||||
|
||||
* 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 <pablo.concepcion@artica.es>
|
||||
|
||||
* lib/PandoraFMS/Core.pm: Modified to have different functions for the
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue