From 9ec9af6bce40a1471fcb31a17e1711bde7937441 Mon Sep 17 00:00:00 2001
From: Ramon Novoa <rnovoa@artica.es>
Date: Wed, 27 May 2009 16:09:29 +0000
Subject: [PATCH] 2009-05-27  Ramon Novoa  <rnovoa@artica.es>

	* lib/PandoraFMS/DataServer.pm: Fixed timestamps for data lists. Made
          XML::Simple return an empty string instead of an empty hash when an
          empty value is found in an XML data file.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1715 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
---
 pandora_server/ChangeLog                    | 6 ++++++
 pandora_server/lib/PandoraFMS/DataServer.pm | 6 +++---
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog
index 094f51da99..0510659c7c 100644
--- a/pandora_server/ChangeLog
+++ b/pandora_server/ChangeLog
@@ -1,3 +1,9 @@
+2009-05-27  Ramon Novoa  <rnovoa@artica.es>
+
+	* lib/PandoraFMS/DataServer.pm: Fixed timestamps for data lists. Made
+	  XML::Simple return an empty string instead of an empty hash when an
+	  empty value is found in an XML data file.
+
 2009-05-12  Sancho Lerena <slerena@gmail.com>
 
 	* pandora_package_installer: Removed old, unused script.
diff --git a/pandora_server/lib/PandoraFMS/DataServer.pm b/pandora_server/lib/PandoraFMS/DataServer.pm
index b8216f5c6e..473448f302 100644
--- a/pandora_server/lib/PandoraFMS/DataServer.pm
+++ b/pandora_server/lib/PandoraFMS/DataServer.pm
@@ -118,7 +118,7 @@ sub data_consumer ($$) {
 	for (1..3) {
 		eval {
 			threads->yield;
-			$xml_data = XMLin ($file_name, forcearray => 'module');
+			$xml_data = XMLin ($file_name, forcearray => 'module', suppressempty => '');
     	};
     	
     	# Invalid XML
@@ -202,7 +202,7 @@ sub process_xml_data ($$$$) {
 				next unless defined ($data->{'value'});
 							
 				$module_data->{'data'} = $data->{'value'};
-				my $data_timestamp = (defined ($data->{'timestamp'})) ? $data->{'timestamp'} : $timestamp;
+				my $data_timestamp = (defined ($data->{'timestamp'})) ? $data->{'timestamp'}->[0] : $timestamp;
 				process_module_data ($pa_config, $module_data, $server_id, $agent_name, $module_name,
 									 $module_type, $interval, $data_timestamp, $dbh);
 			}
@@ -237,7 +237,7 @@ sub process_module_data ($$$$$$$$$) {
 		my $max = (defined ($data->{'max'})) ? $data->{'max'}->[0] : 0;
 		my $min = (defined ($data->{'min'})) ? $data->{'min'}->[0] : 0;
 		my $description = (defined ($data->{'description'})) ? $data->{'description'}->[0] : '';
-		
+
 		# Create the module
 		pandora_create_module ($agent->{'id_agente'}, $module_id, $module_name,
 	                          $max, $min, $description, $interval, $dbh);