2010-07-26 Ramon Novoa <rnovoa@artica.es>

* lib/PandoraFMS/Core.pm: Do not compress data for async modules.

        * lib/PandoraFMS/DataServer.pm: Check that the file exists before
          trying to parse the XML to avoid XML::Simple error messages.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3060 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
ramonn 2010-07-26 11:51:49 +00:00
parent 883d142545
commit 8295dcbdf8
3 changed files with 21 additions and 11 deletions

View File

@ -1,3 +1,10 @@
2010-07-26 Ramon Novoa <rnovoa@artica.es>
* lib/PandoraFMS/Core.pm: Do not compress data for async modules.
* lib/PandoraFMS/DataServer.pm: Check that the file exists before
trying to parse the XML to avoid XML::Simple error messages.
2010-07-22 Ramon Novoa <rnovoa@artica.es> 2010-07-22 Ramon Novoa <rnovoa@artica.es>
* lib/PandoraFMS/DataServer.pm: Sort files by creation date before * lib/PandoraFMS/DataServer.pm: Sort files by creation date before

View File

@ -767,8 +767,8 @@ sub pandora_process_module ($$$$$$$$$;$) {
$current_utimestamp, $timestamp, $module->{'id_agente'}, $current_interval, $server_id, $current_utimestamp, $timestamp, $module->{'id_agente'}, $current_interval, $server_id,
$utimestamp, ($save == 1) ? $timestamp : $agent_status->{'last_try'}, $module->{'id_agente_modulo'}); $utimestamp, ($save == 1) ? $timestamp : $agent_status->{'last_try'}, $module->{'id_agente_modulo'});
# Save module data # Save module data. Async and log4x modules are not compressed.
if ($module_type eq "log4x" || $save == 1) { if ($module_type =~ m/(async)|(log4x)/) || $save == 1) {
save_module_data ($dataObject, $module, $module_type, $utimestamp, $dbh); save_module_data ($dataObject, $module, $module_type, $utimestamp, $dbh);
} }
} }

View File

@ -127,6 +127,9 @@ sub data_consumer ($$) {
$file_name .= "/" unless (substr ($file_name, -1, 1) eq '/'); $file_name .= "/" unless (substr ($file_name, -1, 1) eq '/');
$file_name .= $task; $file_name .= $task;
# Double check that the file exists
return unless (-f $file_name);
# Try to parse the XML 3 times # Try to parse the XML 3 times
my $xml_data; my $xml_data;
@ -134,18 +137,18 @@ sub data_consumer ($$) {
eval { eval {
threads->yield; threads->yield;
$xml_data = XMLin ($file_name, forcearray => 'module'); $xml_data = XMLin ($file_name, forcearray => 'module');
}; };
# Invalid XML # Invalid XML
if ($@) { if ($@) {
sleep (10); sleep (10);
next; next;
} }
# Ignore the timestamp in the XML and use the file timestamp instead # Ignore the timestamp in the XML and use the file timestamp instead
$xml_data->{'timestamp'} = strftime ("%Y-%m-%d %H:%M:%S", localtime((stat($file_name))[9])) if ($pa_config->{'use_xml_timestamp'} eq '1' || ! defined ($xml_data->{'timestamp'})); $xml_data->{'timestamp'} = strftime ("%Y-%m-%d %H:%M:%S", localtime((stat($file_name))[9])) if ($pa_config->{'use_xml_timestamp'} eq '1' || ! defined ($xml_data->{'timestamp'}));
unlink ($file_name); unlink ($file_name);
process_xml_data ($self->getConfig (), $file_name, $xml_data, $self->getServerID (), $self->getDBH ()); process_xml_data ($self->getConfig (), $file_name, $xml_data, $self->getServerID (), $self->getDBH ());
return; return;
} }