diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index dd9072e86d..181a0ae36b 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,10 @@ +2010-05-11 Ramon Novoa + + * lib/PandoraFMS/PluginServer.pm, lib/PandoraFMS/Core.pm, + lib/PandoraFMS/NetworkServer.pm, lib/PandoraFMS/WMIServer.pm: Fixed + bug #2941736. Made pandora_update_module_on_error set + tagente_estado.current_interval. + 2010-05-11 Sancho Lerena * util/plugin/bgp_plugin.pl: New plugin: Connect the device via SNMP diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index ac610d96a1..1693aa1b1c 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -679,7 +679,7 @@ sub pandora_process_module ($$$$$$$$$;$) { $module_type = get_db_value ($dbh, 'SELECT nombre FROM ttipo_modulo WHERE id_tipo = ?', $module->{'id_tipo_modulo'}); if (! defined ($module_type)) { logger($pa_config, "Invalid module type ID " . $module->{'id_tipo_modulo'} . " module '" . $module->{'nombre'} . "' agent " . (defined ($agent) ? "'" . $agent->{'nombre'} . "'" : 'ID ' . $module->{'id_agente'}) . ".", 10); - pandora_update_module_on_error ($pa_config, $module->{'id_agente_modulo'}, $dbh); + pandora_update_module_on_error ($pa_config, $module, $dbh); return; } } @@ -689,7 +689,7 @@ sub pandora_process_module ($$$$$$$$$;$) { $agent = get_db_single_row ($dbh, 'SELECT * FROM tagente WHERE id_agente = ?', $module->{'id_agente'}); if (! defined ($agent)) { logger($pa_config, "Agent ID " . $module->{'id_agente'} . " not found while processing module '" . $module->{'nombre'} . "'.", 3); - pandora_update_module_on_error ($pa_config, $module->{'id_agente_modulo'}, $dbh); + pandora_update_module_on_error ($pa_config, $module, $dbh); return; } } @@ -698,7 +698,7 @@ sub pandora_process_module ($$$$$$$$$;$) { my $processed_data = process_data ($dataObject, $module, $module_type, $utimestamp, $dbh); if (! defined ($processed_data)) { logger($pa_config, "Received invalid data '" . $dataObject . "' from agent '" . $agent->{'nombre'} . "' module '" . $module->{'nombre'} . "' agent " . (defined ($agent) ? "'" . $agent->{'nombre'} . "'" : 'ID ' . $module->{'id_agente'}) . ".", 3); - pandora_update_module_on_error ($pa_config, $module->{'id_agente_modulo'}, $dbh); + pandora_update_module_on_error ($pa_config, $module, $dbh); return; } @@ -711,7 +711,7 @@ sub pandora_process_module ($$$$$$$$$;$) { my $agent_status = get_db_single_row ($dbh, 'SELECT * FROM tagente_estado WHERE id_agente_modulo = ?', $module->{'id_agente_modulo'}); if (! defined ($agent_status)) { logger($pa_config, "Status for agent '" . $agent->{'nombre'} . "' not found while processing module " . $module->{'nombre'} . ".", 3); - pandora_update_module_on_error ($pa_config, $module->{'id_agente_modulo'}, $dbh); + pandora_update_module_on_error ($pa_config, $module, $dbh); return; } my $last_status = $agent_status->{'last_status'}; @@ -750,7 +750,7 @@ sub pandora_process_module ($$$$$$$$$;$) { # Do we have to save module data? if ($agent_status->{'last_try'} !~ /(\d+)\-(\d+)\-(\d+) +(\d+):(\d+):(\d+)/) { logger($pa_config, "Invalid last try timestamp '" . $agent_status->{'last_try'} . "' for agent '" . $agent->{'nombre'} . "' not found while processing module '" . $module->{'nombre'} . "'.", 3); - pandora_update_module_on_error ($pa_config, $module->{'id_agente_modulo'}, $dbh); + pandora_update_module_on_error ($pa_config, $module, $dbh); return; } @@ -1137,13 +1137,16 @@ Update module status on error. =cut ########################################################################## sub pandora_update_module_on_error ($$$) { - my ($pa_config, $id_agent_module, $dbh) = @_; + my ($pa_config, $module, $dbh) = @_; - logger($pa_config, "Updating module ID $id_agent_module on error.", 10); + # Set tagente_estado.current_interval to make sure it is not 0 + my $current_interval = ($module->{'module_interval'} == 0 ? 300 : $module->{'module_interval'}); + + logger($pa_config, "Updating module " . $module->{'nombre'} . " (ID " . $module->{'id_agente_modulo'} . ") on error.", 10); # Update last_execution_try - db_do ($dbh, 'UPDATE tagente_estado SET last_execution_try = ? - WHERE id_agente_modulo = ?', time (), $id_agent_module); + db_do ($dbh, 'UPDATE tagente_estado SET last_execution_try = ?, current_interval = ? + WHERE id_agente_modulo = ?', time (), $current_interval, $module->{'id_agente_modulo'}); } ########################################################################## diff --git a/pandora_server/lib/PandoraFMS/NetworkServer.pm b/pandora_server/lib/PandoraFMS/NetworkServer.pm index dbdc7ffe0b..eaa98c6b5f 100644 --- a/pandora_server/lib/PandoraFMS/NetworkServer.pm +++ b/pandora_server/lib/PandoraFMS/NetworkServer.pm @@ -428,7 +428,7 @@ sub exec_network_module ($$$$) { } else { # Modules who cannot connect or something go bad, update last_execution_try field - pandora_update_module_on_error ($pa_config, $id_agente_modulo, $dbh); + pandora_update_module_on_error ($pa_config, $module, $dbh); } } diff --git a/pandora_server/lib/PandoraFMS/PluginServer.pm b/pandora_server/lib/PandoraFMS/PluginServer.pm index 2a629ffffc..301a132430 100644 --- a/pandora_server/lib/PandoraFMS/PluginServer.pm +++ b/pandora_server/lib/PandoraFMS/PluginServer.pm @@ -201,7 +201,7 @@ sub data_consumer ($$) { } if (! defined $module_data || $module_data eq '') { - pandora_update_module_on_error ($pa_config, $module_id, $dbh); + pandora_update_module_on_error ($pa_config, $module, $dbh); return; } diff --git a/pandora_server/lib/PandoraFMS/WMIServer.pm b/pandora_server/lib/PandoraFMS/WMIServer.pm index a6063c27a8..06b847b3be 100644 --- a/pandora_server/lib/PandoraFMS/WMIServer.pm +++ b/pandora_server/lib/PandoraFMS/WMIServer.pm @@ -153,7 +153,7 @@ sub data_consumer ($$) { # Execute command my $module_data = `$wmi_command`; if (! defined ($module_data)) { - pandora_update_module_on_error ($pa_config, $module_id, $dbh); + pandora_update_module_on_error ($pa_config, $module, $dbh); return; } @@ -163,13 +163,13 @@ sub data_consumer ($$) { # CPU0|2 my @output = split("\n", $module_data); if ($#output < 2) { - pandora_update_module_on_error ($pa_config, $module_id, $dbh); + pandora_update_module_on_error ($pa_config, $module, $dbh); return; } # Check for errors if ($output[0] =~ m/ERROR/) { - pandora_update_module_on_error ($pa_config, $module_id, $dbh); + pandora_update_module_on_error ($pa_config, $module, $dbh); return; } @@ -179,7 +179,7 @@ sub data_consumer ($$) { # Get the specified column $module_data = $row[$module->{'tcp_port'}] if defined ($row[$module->{'tcp_port'}]); if ($module_data =~ m/^ERROR/) { - pandora_update_module_on_error ($pa_config, $module_id, $dbh); + pandora_update_module_on_error ($pa_config, $module, $dbh); return; }