From ae8dff9657bf07bd06a69dddd54bd2fc20e053f4 Mon Sep 17 00:00:00 2001 From: ramonn Date: Mon, 20 Jun 2011 16:32:29 +0000 Subject: [PATCH] 2011-06-20 Ramon Novoa * lib/PandoraFMS/Config.pm,, lib/PandoraFMS/NetworkServer.pm: Added a new ICMP server (enterprise). * lib/PandoraFMS/Core.pm: Reset action thresholds when an alert recovers. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4473 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/ChangeLog | 8 ++++++++ pandora_server/lib/PandoraFMS/Config.pm | 14 +++++++++++++- pandora_server/lib/PandoraFMS/Core.pm | 14 ++++++++++---- pandora_server/lib/PandoraFMS/NetworkServer.pm | 10 ++++++---- 4 files changed, 37 insertions(+), 9 deletions(-) diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index 927323e828..a5381c3d31 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,11 @@ +2011-06-20 Ramon Novoa + + * lib/PandoraFMS/Config.pm,, + lib/PandoraFMS/NetworkServer.pm: Added a new ICMP server (enterprise). + + * lib/PandoraFMS/Core.pm: Reset action thresholds when an alert + recovers. + 2011-06-20 Sergio Martin * lib/PandoraFMS/DB.pm: Added quotes to process diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index ad1e878984..238434cf99 100644 --- a/pandora_server/lib/PandoraFMS/Config.pm +++ b/pandora_server/lib/PandoraFMS/Config.pm @@ -236,7 +236,10 @@ sub pandora_load_config { $pa_config->{'openstreetmaps_description'} = 0; $pa_config->{"eventserver"} = 1; # 4.0 $pa_config->{"event_window"} = 3600; # 4.0 - + $pa_config->{"icmpserver"} = 1; # 4.0 + $pa_config->{"icmp_threads"} = 3; # 4.0 + $pa_config->{"block_size"} = 50; # 4.0 + $pa_config->{"max_queue_files"} = 500; # Internal MTA for alerts, each server need its own config. @@ -437,6 +440,12 @@ sub pandora_load_config { elsif ($parametro =~ m/^eventserver\s([0-9]*)/i) { $pa_config->{'eventserver'}= clean_blank($1); } + elsif ($parametro =~ m/^icmpserver\s([0-9]*)/i) { + $pa_config->{'icmpserver'}= clean_blank($1); + } + elsif ($parametro =~ m/^icmp_threads\s([0-9]*)/i) { + $pa_config->{'icmp_threads'}= clean_blank($1); + } elsif ($parametro =~ m/^servername\s(.*)/i) { $pa_config->{'servername'}= clean_blank($1); } @@ -588,6 +597,9 @@ sub pandora_load_config { elsif ($parametro =~ m/^event_window\s([0-9]*)/i) { $pa_config->{'event_window'}= clean_blank($1); } + elsif ($parametro =~ m/^block_size\s([0-9]*)/i) { + $pa_config->{'block_size'}= clean_blank($1); + } } # end of loop for parameter # if (($pa_config->{"verbosity"} > 4) && ($pa_config->{"quiet"} == 0)){ diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index a4325bdd32..19a372002c 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -170,7 +170,7 @@ our @EXPORT = qw( # Some global variables our @DayNames = qw(sunday monday tuesday wednesday thursday friday saturday); -our @ServerTypes = qw (dataserver networkserver snmpconsole reconserver pluginserver predictionserver wmiserver exportserver inventoryserver webserver eventserver); +our @ServerTypes = qw (dataserver networkserver snmpconsole reconserver pluginserver predictionserver wmiserver exportserver inventoryserver webserver eventserver icmpserver); our @AlertStatus = ('Execute the alert', 'Do not execute the alert', 'Do not execute the alert, but increment its internal counter', 'Cease the alert', 'Recover the alert', 'Reset internal counter'); ########################################################################## @@ -410,6 +410,11 @@ sub pandora_process_alert ($$$$$$$$;$) { db_do($dbh, 'UPDATE ' . $table . ' SET times_fired = 0, internal_counter = 0 WHERE id = ?', $id); + # Reset action thresholds + if (defined ($alert->{'id_template_module'})) { + db_do($dbh, 'UPDATE talert_template_module_actions SET last_execution = 0 WHERE id_alert_template_module = ?', $id); + } + pandora_execute_alert ($pa_config, $data, $agent, $module, $alert, 0, $dbh, $timestamp, $extra_macros); return; } @@ -578,7 +583,8 @@ sub pandora_execute_alert ($$$$$$$$;$) { # Simple alert if (defined ($alert->{'id_template_module'})) { - @actions = get_db_rows ($dbh, 'SELECT * FROM talert_template_module_actions, talert_actions, talert_commands + @actions = get_db_rows ($dbh, 'SELECT *, talert_template_module_actions.id AS id_alert_template_module_actions + FROM talert_template_module_actions, talert_actions, talert_commands WHERE talert_template_module_actions.id_alert_action = talert_actions.id AND talert_actions.id_alert_command = talert_commands.id AND talert_template_module_actions.id_alert_template_module = ? @@ -755,8 +761,8 @@ sub pandora_execute_action ($$$$$$$$$;$) { } # Update action last execution date - if (defined ($action->{'last_execution'}) && defined ($action->{'id'})) { - db_do ($dbh, 'UPDATE talert_template_module_actions SET last_execution = ? WHERE id = ?', time (), $action->{'id'}); + if (defined ($action->{'last_execution'}) && defined ($action->{'id_alert_template_module_actions'})) { + db_do ($dbh, 'UPDATE talert_template_module_actions SET last_execution = ? WHERE id = ?', time (), $action->{'id_alert_template_module_actions'}); } } diff --git a/pandora_server/lib/PandoraFMS/NetworkServer.pm b/pandora_server/lib/PandoraFMS/NetworkServer.pm index 1284e779ee..2567b58eeb 100644 --- a/pandora_server/lib/PandoraFMS/NetworkServer.pm +++ b/pandora_server/lib/PandoraFMS/NetworkServer.pm @@ -95,8 +95,9 @@ sub data_producer ($) { AND tagente_modulo.id_agente = tagente.id_agente AND tagente.disabled = 0 AND tagente_modulo.id_tipo_modulo > 4 - AND tagente_modulo.id_tipo_modulo < 19 - AND tagente_modulo.disabled = 0 + AND tagente_modulo.id_tipo_modulo < 19' + . enterprise_hook ('get_network_filter', []) . + 'AND tagente_modulo.disabled = 0 AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND (tagente_modulo.flag = 1 OR ((tagente_estado.last_execution_try + tagente_estado.current_interval) < UNIX_TIMESTAMP())) ORDER BY tagente_modulo.flag DESC, time_left DESC, tagente_estado.last_execution_try ASC ', $pa_config->{'servername'}); @@ -108,8 +109,9 @@ sub data_producer ($) { AND tagente.disabled = 0 AND tagente_modulo.disabled = 0 AND tagente_modulo.id_tipo_modulo > 4 - AND tagente_modulo.id_tipo_modulo < 19 - AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo + AND tagente_modulo.id_tipo_modulo < 19' + . enterprise_hook ('get_network_filter', []) . + 'AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND (tagente_modulo.flag = 1 OR ((tagente_estado.last_execution_try + tagente_estado.current_interval) < UNIX_TIMESTAMP())) ORDER BY tagente_modulo.flag DESC, time_left DESC, tagente_estado.last_execution_try ASC', $pa_config->{'servername'}); }