diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index a91f116f48..0da93ccbd8 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,9 @@ +2012-04-23 Ramon Novoa + + * lib/PandoraFMS/Core.pm: Merged from 4.0 branch. Do not insert zeroes + when something goes wrong while processing an inc module. Fixes bug + #3519591. + 2012-04-23 Ramon Novoa * lib/PandoraFMS/NetworkServer.pm, diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 3a468451e1..c8a65902d7 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -1883,8 +1883,8 @@ sub subst_alert_macros ($$) { ########################################################################## # Process module data. ########################################################################## -sub process_data ($$$$$) { - my ($data_object, $module, $module_type, $utimestamp, $dbh) = @_; +sub process_data ($$$$$$) { + my ($pa_config, $data_object, $module, $module_type, $utimestamp, $dbh) = @_; if ($module_type eq "log4x") { return log4x_get_severity_num($data_object); @@ -1915,16 +1915,10 @@ sub process_data ($$$$$) { # Process INC modules if ($module_type =~ m/_inc$/) { - $data = process_inc_data ($data, $module, $utimestamp, $dbh); - - # Not an error, no previous data - if (!defined($data)){ - $data_object->{'data'} = 0; - return 0; - } - - # Same timestamp as previous data. Discard. - return undef if($data == -1); + $data = process_inc_data ($pa_config, $data, $module, $utimestamp, $dbh); + + # No previous data or error. + return undef unless defined ($data); } # Post process @@ -1944,8 +1938,8 @@ sub process_data ($$$$$) { ########################################################################## # Process data of type *_inc. ########################################################################## -sub process_inc_data ($$$$) { - my ($data, $module, $utimestamp, $dbh) = @_; +sub process_inc_data ($$$$$) { + my ($pa_config, $data, $module, $utimestamp, $dbh) = @_; my $data_inc = get_db_single_row ($dbh, 'SELECT * FROM tagente_datos_inc WHERE id_agente_modulo = ?', $module->{'id_agente_modulo'}); @@ -1954,6 +1948,7 @@ sub process_inc_data ($$$$) { db_do ($dbh, 'INSERT INTO tagente_datos_inc (id_agente_modulo, datos, utimestamp) VALUES (?, ?, ?)', $module->{'id_agente_modulo'}, $data, $utimestamp); + logger($pa_config, "Discarding first data for incremental module " . $module->{'nombre'} . "(module id " . $module->{'id_agente_modulo'} . ").", 10); return undef; } @@ -1963,11 +1958,12 @@ sub process_inc_data ($$$$) { db_do ($dbh, 'INSERT INTO tagente_datos_inc (id_agente_modulo, datos, utimestamp) VALUES (?, ?, ?)', $module->{'id_agente_modulo'}, $data, $utimestamp); + logger($pa_config, "Discarding data and resetting counter for incremental module " . $module->{'nombre'} . "(module id " . $module->{'id_agente_modulo'} . ").", 10); return undef; } # Should not happen - return -1 if ($utimestamp == $data_inc->{'utimestamp'}); + return undef if ($utimestamp == $data_inc->{'utimestamp'}); # Update inc data db_do ($dbh, 'UPDATE tagente_datos_inc SET datos = ?, utimestamp = ? WHERE id_agente_modulo = ?', $data, $utimestamp, $module->{'id_agente_modulo'});