2010-02-22 Pablo de la Concepción <pablo.concepcion@artica.es>
* lib/PandoraFMS/Core.pm: Updated documentation, fixed wrong parameters in the call to distance_moved. * man/man3/PandoraFMS::Core.pm.3: Updated manpage. * lib/PandoraFMS/DataServer.pm: Added the process of position_description, parent_agent_name now is readed (TODO: process it). Fixed bug #2926077 by handling the error returned by timelocal and ignoring the received timestamp to use the server one. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2402 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
beb85ab9f0
commit
21fc24c548
|
@ -1,3 +1,15 @@
|
|||
2010-02-22 Pablo de la Concepción <pablo.concepcion@artica.es>
|
||||
|
||||
* lib/PandoraFMS/Core.pm: Updated documentation, fixed wrong parameters
|
||||
in the call to distance_moved.
|
||||
|
||||
* man/man3/PandoraFMS::Core.pm.3: Updated manpage.
|
||||
|
||||
* lib/PandoraFMS/DataServer.pm: Added the process of position_description,
|
||||
parent_agent_name now is readed (TODO: process it). Fixed bug #2926077
|
||||
by handling the error returned by timelocal and ignoring the received
|
||||
timestamp to use the server one.
|
||||
|
||||
2010-02-19 Pablo de la Concepción <pablo.concepcion@artica.es>
|
||||
|
||||
|
||||
|
|
|
@ -864,7 +864,8 @@ sub pandora_update_server ($$$$$;$$) {
|
|||
##########################################################################
|
||||
=head2 C<< pandora_update_agent (I<$pa_config>, I<$agent_timestamp>, I<$agent_id>, I<$os_version>, I<$agent_version>, I<$agent_interval>, I<$dbh>, [I<$timezone_offset>], [I<$longitude>], [I<$latitude>], [I<$altitude>], [I<$position_description>]) >>
|
||||
|
||||
Update last contact, timezone and position fields in B<tagente>
|
||||
Update last contact, timezon fields in B<tagente> and current position (this
|
||||
can affect B<tgis_data_status> and B<tgis_data_history>).
|
||||
|
||||
=cut
|
||||
##########################################################################
|
||||
|
@ -912,8 +913,8 @@ sub pandora_update_agent ($$$$$$$;$$$$$) {
|
|||
.$last_agent_position->{'current_latitude'}. " current_altitude=". $last_agent_position->{'current_altitude'}. " ID: $agent_id ", 10);
|
||||
|
||||
# If the agent has moved outside the range stablised as location error
|
||||
if (distance_moved($pa_config, $last_agent_position->{'current_longitude'}, $last_agent_position->{'current_latitude'},
|
||||
$last_agent_position->{'current_altitude'}, $longitude, $latitude, $altitude) > $pa_config->{'location_error'}) {
|
||||
if (distance_moved($pa_config, $last_agent_position->{'stored_longitude'}, $last_agent_position->{'stored_latitude'},
|
||||
$last_agent_position->{'stored_altitude'}, $longitude, $latitude, $altitude) > $pa_config->{'location_error'}) {
|
||||
#Archive the old position and save new one as status
|
||||
archive_agent_position($pa_config, $last_agent_position->{'start_timestamp'},$timestamp,$last_agent_position->{'stored_longitude'}, $last_agent_position->{'stored_latitude'},
|
||||
$last_agent_position->{'stored_altitude'},$last_agent_position->{'description'}, $last_agent_position->{'number_of_packages'},$agent_id, $dbh);
|
||||
|
|
|
@ -162,18 +162,18 @@ sub process_xml_data ($$$$$) {
|
|||
$timezone_offset = 0; # Default value
|
||||
}
|
||||
|
||||
# Parent Agent Name
|
||||
my $parent_agent_name = $data->{'parent_agent_name'};
|
||||
|
||||
my $valid_position_data = 1;
|
||||
|
||||
# Get GIS information
|
||||
my ($longitude, $latitude, $altitude) = (
|
||||
$data->{'longitude'}, $data->{'latitude'}, $data->{'altitude'});
|
||||
my ($longitude, $latitude, $altitude, $position_description) = (
|
||||
$data->{'longitude'}, $data->{'latitude'}, $data->{'altitude'}, $data->{'position_description'});
|
||||
|
||||
if ($pa_config->{'activate_gis'}) {
|
||||
|
||||
# Validate the GIS informtation
|
||||
if (!defined($altitude) || $altitude !~ /[-+]?[0-9,11,12]/) {
|
||||
$altitude = 0; # Default value
|
||||
}
|
||||
|
||||
# If position data (at least longitude and latitde) are not valid should be ignored
|
||||
if ($longitude !~ /[-+]?[0-9]*\.?[0-9]+/ || $latitude !~ /[-+]?[0-9]*\.?[0-9]+/ || !defined($longitude) || !defined($latitude)) {
|
||||
|
@ -183,7 +183,15 @@ sub process_xml_data ($$$$$) {
|
|||
$altitude='';
|
||||
}
|
||||
|
||||
logger($pa_config, "Getting GIS Data=timezone_offset=$timezone_offset longitude=$longitude latitude=$latitude altitude=$altitude", 10);
|
||||
if (!defined($altitude) || $altitude !~ /[-+]?[0-9,11,12]/) {
|
||||
$altitude = 0; # Default value
|
||||
}
|
||||
|
||||
if (!defined($position_description) ) { #FIXME: Validate the data with a regexp
|
||||
$position_description = ''; # Default value
|
||||
}
|
||||
|
||||
logger($pa_config, "Getting GIS Data=timezone_offset=$timezone_offset longitude=$longitude latitude=$latitude altitude=$altitude position_description=$position_description", 8);
|
||||
}
|
||||
# Unknown agent!
|
||||
if (! defined ($agent_name) || $agent_name eq '') {
|
||||
|
@ -201,7 +209,14 @@ sub process_xml_data ($$$$$) {
|
|||
logger($pa_config, "Unmodified timestamp = $timestamp", 5);
|
||||
$timestamp =~ /(\d+)[\/|\-](\d+)[\/|\-](\d+) +(\d+):(\d+):(\d+)/;
|
||||
logger($pa_config, "Unmodified timestamp = $1/$2/$3 $4:$5:$6", 5);
|
||||
my $utimestamp = timelocal($6, $5, $4, $3, $2 -1 , $1 - 1900) + ($timezone_offset * 3600);
|
||||
my $utimestamp = ($timezone_offset * 3600);
|
||||
eval {
|
||||
$utimestamp += timelocal($6, $5, $4, $3, $2 -1 , $1 - 1900);
|
||||
};
|
||||
if ($@) {
|
||||
logger($pa_config,"WARNING: Invalid timestamp ($@) using server timestamp.", 4);
|
||||
$timestamp = strftime ("%Y/%m/%d %H:%M:%S", localtime());
|
||||
}
|
||||
logger($pa_config, "Seconds timestamp = $timestamp modified timestamp in seconds $utimestamp with timezone_offset = $timezone_offset", 5);
|
||||
$timestamp = strftime ("%Y-%m-%d %H:%M:%S", localtime($utimestamp));
|
||||
}
|
||||
|
@ -235,7 +250,7 @@ sub process_xml_data ($$$$$) {
|
|||
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, '', 0, $group_id, 0, $os,
|
||||
$description, $interval, $dbh, $timezone_offset, $longitude, $latitude, $altitude);
|
||||
$description, $interval, $dbh, $timezone_offset, $longitude, $latitude, $altitude, $position_description);
|
||||
}
|
||||
else { # Ignore agent positional data
|
||||
logger($pa_config, "Creating agent $agent_name", 5);
|
||||
|
@ -252,7 +267,7 @@ sub process_xml_data ($$$$$) {
|
|||
if ($valid_position_data == 1 && $pa_config->{'activate_gis'} != 0) {
|
||||
logger($pa_config, "Updating agent $agent_name at long: $longitude lat: $latitude alt: $altitude", 5);
|
||||
# Update agent information including position information
|
||||
pandora_update_agent($pa_config, $timestamp, $agent_id, $os_version, $agent_version, $interval, $dbh, $timezone_offset, $longitude, $latitude, $altitude);
|
||||
pandora_update_agent($pa_config, $timestamp, $agent_id, $os_version, $agent_version, $interval, $dbh, $timezone_offset, $longitude, $latitude, $altitude, $position_description);
|
||||
}
|
||||
else {
|
||||
logger($pa_config, "Updating agent $agent_name", 5);
|
||||
|
|
|
@ -124,7 +124,7 @@
|
|||
.\" ========================================================================
|
||||
.\"
|
||||
.IX Title "PandoraFMS::Core 3"
|
||||
.TH PandoraFMS::Core 3 "2010-02-19" "perl v5.10.0" "User Contributed Perl Documentation"
|
||||
.TH PandoraFMS::Core 3 "2010-02-22" "perl v5.10.0" "User Contributed Perl Documentation"
|
||||
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
|
||||
.\" way too many mistakes in technical documents.
|
||||
.if n .ad l
|
||||
|
@ -269,7 +269,8 @@ Update server status:
|
|||
.ie n .SS """pandora_update_agent (\fI$pa_config\fP, \fI$agent_timestamp\fP, \fI$agent_id\fP, \fI$os_version\fP, \fI$agent_version\fP, \fI$agent_interval\fP, \fI$dbh\fP, [\fI$timezone_offset\fP], [\fI$longitude\fP], [\fI$latitude\fP], [\fI$altitude\fP], [\fI$position_description\fP])"""
|
||||
.el .SS "\f(CWpandora_update_agent (\fP\f(CI$pa_config\fP\f(CW, \fP\f(CI$agent_timestamp\fP\f(CW, \fP\f(CI$agent_id\fP\f(CW, \fP\f(CI$os_version\fP\f(CW, \fP\f(CI$agent_version\fP\f(CW, \fP\f(CI$agent_interval\fP\f(CW, \fP\f(CI$dbh\fP\f(CW, [\fP\f(CI$timezone_offset\fP\f(CW], [\fP\f(CI$longitude\fP\f(CW], [\fP\f(CI$latitude\fP\f(CW], [\fP\f(CI$altitude\fP\f(CW], [\fP\f(CI$position_description\fP\f(CW])\fP"
|
||||
.IX Subsection "pandora_update_agent ($pa_config, $agent_timestamp, $agent_id, $os_version, $agent_version, $agent_interval, $dbh, [$timezone_offset], [$longitude], [$latitude], [$altitude], [$position_description])"
|
||||
Update last contact, timezone and position fields in \fBtagente\fR
|
||||
Update last contact, timezon fields in \fBtagente\fR and current position (this
|
||||
can affect \fBtgis_data_status\fR and \fBtgis_data_history\fR).
|
||||
.ie n .SS """pandora_module_keep_alive (\fI$pa_config\fP, \fI$id_agent\fP, \fI$agent_name\fP, \fI$server_id\fP, \fI$dbh\fP)"""
|
||||
.el .SS "\f(CWpandora_module_keep_alive (\fP\f(CI$pa_config\fP\f(CW, \fP\f(CI$id_agent\fP\f(CW, \fP\f(CI$agent_name\fP\f(CW, \fP\f(CI$server_id\fP\f(CW, \fP\f(CI$dbh\fP\f(CW)\fP"
|
||||
.IX Subsection "pandora_module_keep_alive ($pa_config, $id_agent, $agent_name, $server_id, $dbh)"
|
||||
|
|
Loading…
Reference in New Issue