2010-01-29 Pablo de la Concepción <pablo.concepcion@artica.es>

* lib/PandoraFMS/DataServer.pm: Improved timezone_offset management.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2321 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
Pablo de la Concepción Sanz 2010-01-29 15:40:05 +00:00
parent 5ba22ec2e3
commit 9af0431c21
2 changed files with 15 additions and 7 deletions

View File

@ -1,3 +1,7 @@
2010-01-29 Pablo de la Concepción <pablo.concepcion@artica.es>
* lib/PandoraFMS/DataServer.pm: Improved timezone_offset management.
2010-01-26 Sancho Lerena <slerena@artica.es>
* Core.pm: Fixed bug #2932694 (extra ',' in a SQL sentence). Reported by

View File

@ -157,19 +157,21 @@ sub process_xml_data ($$$$$) {
($data->{'agent_name'}, $data->{'version'}, $data->{'timestamp'},
$data->{'interval'}, $data->{'os_version'}, $data->{'timezone_offset'});
# Timezone offset must be an integer beween -12 and +12
if ($timezone_offset !~ /[-+]?[0-9,11,12]/) {
$timezone_offset = 0; # Default value
}
my $valid_position_data = 1;
# Get GIS information
my ($longitude, $latitude, $altitude) = (
$data->{'longitude'}, $data->{'latitude'}, $data->{'altitude'});
# TODO: validate that the positional parameters and timezone are defined.
if ($pa_config->{'activate_gis'}) {
# Validate the GIS informtation
# Timezone offset must be an integer beween -12 and +12
if ($timezone_offset !~ /[-+]?[0-9,11,12]/) {
$timezone_offset = 0; # Default value
}
# If position data are not valid should be ignored
if ($longitude !~ /[-+]?[0-9]*\.?[0-9]+/ || $latitude !~ /[-+]?[0-9]*\.?[0-9]+/ || $altitude !~ /[-+]?[0-9]*\.?[0-9]+/) {
@ -189,13 +191,15 @@ sub process_xml_data ($$$$$) {
$timestamp = strftime ("%Y/%m/%d %H:%M:%S", localtime());
}
else {
if ($timezone_offset != 0) {
# Modify the timestamp with the timezone_offset
logger($pa_config, "Unmodified timestamp = $timestamp", 5);
$timestamp =~ /(\d+)\/(\d+)\/(\d+) +(\d+):(\d+):(\d+)/;
#my $last_fired = ($1 > 0) ?
my $utimestamp = timelocal($6, $5, $4, $3, $2 - 1, $1 - 1900) + ($timezone_offset * 3600);
$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);
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));
}
logger($pa_config, "Modified timestamp = $timestamp with timezone_offset = $timezone_offset", 5);
}