From f6da945f4566159ece42589e6a0019db617c6dec Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Wed, 19 Dec 2012 17:51:15 +0000 Subject: [PATCH] 2012-12-19 Ramon Novoa * lib/PandoraFMS/Core.pm: Return async modules to normal after twice the module interval has elapsed. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7313 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/ChangeLog | 5 ++ pandora_server/lib/PandoraFMS/Core.pm | 93 ++++++++++++++++++--------- 2 files changed, 69 insertions(+), 29 deletions(-) diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index a45f543b8c..2d3267ec04 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,8 @@ +2012-12-19 Ramon Novoa + + * lib/PandoraFMS/Core.pm: Return async modules to normal after + twice the module interval has elapsed. + 2012-12-19 Sergio Martin * lib/PandoraFMS/Core.pm: Added new function to update diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index ada23697b2..c0e26d03d2 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -1084,7 +1084,7 @@ sub pandora_process_module ($$$$$$$$$;$) { $current_interval = cron_next_execution ($module->{'cron_interval'}); } elsif ($module->{'module_interval'} == 0) { - $current_interval = 300; + $current_interval = $agent->{'intervalo'}; } else { $current_interval = $module->{'module_interval'}; @@ -3716,41 +3716,76 @@ sub pandora_module_unknown ($$) { AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND tagente.disabled = 0 AND tagente_modulo.disabled = 0 - AND tagente_estado.estado <> 3 - AND tagente_modulo.id_tipo_modulo NOT IN (21, 22, 23, 100) + AND ((tagente_estado.estado <> 3 AND tagente_modulo.id_tipo_modulo NOT IN (21, 22, 23, 100)) + OR (tagente_estado.estado <> 0 AND tagente_modulo.id_tipo_modulo IN (21, 22, 23))) AND tagente_estado.utimestamp != 0 AND (tagente_estado.current_interval * 2) + tagente_estado.utimestamp < UNIX_TIMESTAMP()'); foreach my $module (@modules) { + + # Async + if ($module->{'id_tipo_modulo'} == 21 || + $module->{'id_tipo_modulo'} == 22 || + $module->{'id_tipo_modulo'} == 23) { + + # Set the module state to normal + logger ($pa_config, "Module " . $module->{'nombre'} . " is going to NORMAL", 10); + db_do ($dbh, 'UPDATE tagente_estado SET last_known_status = estado, last_status = 0, estado = 0 WHERE id_agente_estado = ?', $module->{'id_agente_estado'}); + + # Get agent information + my $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 executing unknown alerts for module '" . $module->{'nombre'} . "'.", 3); + return; + } - # Set the module state to unknown - logger ($pa_config, "Module " . $module->{'nombre'} . " is going to UNKNOWN", 10); - db_do ($dbh, 'UPDATE tagente_estado SET last_known_status = estado, last_status = 3, estado = 3 WHERE id_agente_estado = ?', $module->{'id_agente_estado'}); + # Update module status count + update_module_status_count ($dbh, $agent, 0, $module->{'estado'}); + + # Generate alerts + if (pandora_inhibit_alerts ($pa_config, $agent, $dbh, 0) == 0) { + pandora_generate_alerts ($pa_config, 0, 3, $agent, $module, time (), $dbh, undef, undef, 0, 'unknown'); + } + else { + logger($pa_config, "Alerts inhibited for agent '" . $agent->{'nombre'} . "'.", 10); + } + + # Generate event with severity minor + my ($event_type, $severity) = ('going_down_normal', 5); + my $description = "Module " . safe_output($module->{'nombre'}) . " is going to NORMAL"; + pandora_event ($pa_config, $description, $agent->{'id_grupo'}, $module->{'id_agente'}, + $severity, 0, $module->{'id_agente_modulo'}, $event_type, 0, $dbh, 'Pandora', '', '', '', '', $module->{'critical_instructions'}, $module->{'warning_instructions'}, $module->{'unknown_instructions'}); + } + # Regular module + else { + # Set the module state to unknown + logger ($pa_config, "Module " . $module->{'nombre'} . " is going to UNKNOWN", 10); + db_do ($dbh, 'UPDATE tagente_estado SET last_known_status = estado, last_status = 3, estado = 3 WHERE id_agente_estado = ?', $module->{'id_agente_estado'}); + + # Get agent information + my $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 executing unknown alerts for module '" . $module->{'nombre'} . "'.", 3); + return; + } - # Get agent information - my $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 executing unknown alerts for module '" . $module->{'nombre'} . "'.", 3); - return; - } - - # Update module status count - update_module_status_count ($dbh, $agent, 3, $module->{'estado'}); - - # Generate alerts - if (pandora_inhibit_alerts ($pa_config, $agent, $dbh, 0) == 0) { - pandora_generate_alerts ($pa_config, 0, 3, $agent, $module, time (), $dbh, undef, undef, 0, 'unknown'); - } - else { - logger($pa_config, "Alerts inhibited for agent '" . $agent->{'nombre'} . "'.", 10); - } + # Update module status count + update_module_status_count ($dbh, $agent, 3, $module->{'estado'}); - # Generate event with severity minor - my ($event_type, $severity) = ('going_unknown', 5); - my $description = "Module " . safe_output($module->{'nombre'}) . " is going to UNKNOWN"; - pandora_event ($pa_config, $description, $agent->{'id_grupo'}, $module->{'id_agente'}, - $severity, 0, $module->{'id_agente_modulo'}, $event_type, 0, $dbh, 'Pandora', '', '', '', '', $module->{'critical_instructions'}, $module->{'warning_instructions'}, $module->{'unknown_instructions'}); - + # Generate alerts + if (pandora_inhibit_alerts ($pa_config, $agent, $dbh, 0) == 0) { + pandora_generate_alerts ($pa_config, 0, 3, $agent, $module, time (), $dbh, undef, undef, 0, 'unknown'); + } + else { + logger($pa_config, "Alerts inhibited for agent '" . $agent->{'nombre'} . "'.", 10); + } + + # Generate event with severity minor + my ($event_type, $severity) = ('going_unknown', 5); + my $description = "Module " . safe_output($module->{'nombre'}) . " is going to UNKNOWN"; + pandora_event ($pa_config, $description, $agent->{'id_grupo'}, $module->{'id_agente'}, + $severity, 0, $module->{'id_agente_modulo'}, $event_type, 0, $dbh, 'Pandora', '', '', '', '', $module->{'critical_instructions'}, $module->{'warning_instructions'}, $module->{'unknown_instructions'}); + } } }