diff --git a/pandora_console/extras/mr/37.sql b/pandora_console/extras/mr/37.sql new file mode 100644 index 0000000000..9f240d889d --- /dev/null +++ b/pandora_console/extras/mr/37.sql @@ -0,0 +1,7 @@ +START TRANSACTION; + +ALTER TABLE `talert_templates` ADD COLUMN `disable_event` tinyint(1) DEFAULT 0; +ALTER TABLE `tevent_alert` ADD COLUMN `disable_event` tinyint(1) DEFAULT 0; +ALTER TABLE `talert_snmp` ADD COLUMN `disable_event` tinyint(1) DEFAULT 0; + +COMMIT; diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index d9fe58ee64..9236f7a5d8 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -666,6 +666,7 @@ CREATE TABLE IF NOT EXISTS `tevent_alert` ( ALTER TABLE `tevent_alert` ADD COLUMN `special_days` tinyint(1) default 0; ALTER TABLE `tevent_alert` MODIFY COLUMN `time_threshold` int(10) NOT NULL default 86400; +ALTER TABLE `tevent_alert` ADD COLUMN `disable_event` tinyint(1) DEFAULT 0; -- ----------------------------------------------------- -- Table `tevent_alert_action` @@ -1239,6 +1240,7 @@ ALTER TABLE talert_templates ADD COLUMN `field12_recovery` TEXT NOT NULL DEFAULT ALTER TABLE talert_templates ADD COLUMN `field13_recovery` TEXT NOT NULL DEFAULT ""; ALTER TABLE talert_templates ADD COLUMN `field14_recovery` TEXT NOT NULL DEFAULT ""; ALTER TABLE talert_templates ADD COLUMN `field15_recovery` TEXT NOT NULL DEFAULT ""; +ALTER TABLE `talert_templates` ADD COLUMN `disable_event` tinyint(1) DEFAULT 0; -- --------------------------------------------------------------------- -- Table `talert_snmp` @@ -1248,6 +1250,7 @@ ALTER TABLE talert_snmp ADD COLUMN `al_field12` TEXT NOT NULL DEFAULT ""; ALTER TABLE talert_snmp ADD COLUMN `al_field13` TEXT NOT NULL DEFAULT ""; ALTER TABLE talert_snmp ADD COLUMN `al_field14` TEXT NOT NULL DEFAULT ""; ALTER TABLE talert_snmp ADD COLUMN `al_field15` TEXT NOT NULL DEFAULT ""; +ALTER TABLE `talert_snmp` ADD COLUMN `disable_event` tinyint(1) DEFAULT 0; ALTER TABLE `talert_snmp` MODIFY COLUMN `al_field11` text NOT NULL, MODIFY COLUMN `al_field12` text NOT NULL, MODIFY COLUMN `al_field13` text NOT NULL, diff --git a/pandora_console/godmode/alerts/configure_alert_template.php b/pandora_console/godmode/alerts/configure_alert_template.php index d79ca90ca8..b801e4ddb9 100644 --- a/pandora_console/godmode/alerts/configure_alert_template.php +++ b/pandora_console/godmode/alerts/configure_alert_template.php @@ -290,6 +290,7 @@ function update_template($step) $max_alerts = (int) get_parameter('max_alerts'); $min_alerts = (int) get_parameter('min_alerts'); $min_alerts_reset_counter = (int) get_parameter('min_alerts_reset_counter'); + $disable_event = (int) get_parameter('disable_event'); $type = (string) get_parameter('type'); $value = (string) html_entity_decode(get_parameter('value')); $max = (float) get_parameter('max'); @@ -320,6 +321,7 @@ function update_template($step) 'max_value' => $max, 'min_value' => $min, 'matches_value' => $matches, + 'disable_event' => $disable_event, ]; // Different datetimes format for oracle @@ -532,6 +534,7 @@ if ($id && ! $create_template) { $max_alerts = $template['max_alerts']; $min_alerts = $template['min_alerts']; $min_alerts_reset_counter = $template['min_alerts_reset_counter']; + $disable_event = $template['disable_event']; $threshold = $template['time_threshold']; $fields = []; for ($i = 1; $i <= $config['max_macro_fields']; $i++) { @@ -578,8 +581,7 @@ if ($step == 2) { // Firing conditions and events $table->colspan = []; - $table->colspan[4][1] = 3; - + // $table->colspan[4][1] = 1; $table->data[0][0] = __('Days of week'); $table->data[0][1] = __('Mon'); $table->data[0][1] .= html_print_checkbox('monday', 1, $monday, true); @@ -653,6 +655,9 @@ if ($step == 2) { true ); + $table->data[4][2] = __('Disable event'); + $table->data[4][3] = html_print_checkbox('disable_event', 1, $disable_event, true); + $table->data[5][0] = __('Default action'); $usr_groups = implode(',', array_keys(users_get_groups($config['id_user'], 'LM', true))); switch ($config['dbtype']) { diff --git a/pandora_console/godmode/modules/manage_nc_groups.php b/pandora_console/godmode/modules/manage_nc_groups.php index 403a871622..e32644b9a8 100644 --- a/pandora_console/godmode/modules/manage_nc_groups.php +++ b/pandora_console/godmode/modules/manage_nc_groups.php @@ -283,7 +283,6 @@ html_print_input_hidden('new', 1); html_print_submit_button(__('Create'), 'crt', false, 'class="sub next"'); echo ''; echo ''; -hd('entra o que ase'); enterprise_hook('close_meta_frame'); ?> diff --git a/pandora_console/godmode/snmpconsole/snmp_alert.php b/pandora_console/godmode/snmpconsole/snmp_alert.php index 66651d6522..7d0fc75876 100755 --- a/pandora_console/godmode/snmpconsole/snmp_alert.php +++ b/pandora_console/godmode/snmpconsole/snmp_alert.php @@ -170,6 +170,7 @@ if ($save_alert || $modify_alert) { $trap_type = (int) get_parameter('trap_type', -1); $single_value = (string) get_parameter('single_value'); $position = (int) get_parameter('position'); + $disable_event = (int) get_parameter('disable_event'); $group = (int) get_parameter('group'); if ($time_threshold == -1) { @@ -245,6 +246,7 @@ if ($save_alert || $modify_alert) { 'trap_type' => $trap_type, 'single_value' => $single_value, 'position' => $position, + 'disable_event' => $disable_event, 'id_group' => $group, ]; @@ -296,8 +298,8 @@ if ($save_alert || $modify_alert) { order_11 = '%d', order_12 = '%d', order_13 = '%d', order_14 = '%d', order_15 = '%d', order_16 = '%d', order_17 = '%d', order_18 = '%d', order_19 = '%d', - order_20 = '%d', trap_type = %d, - single_value = '%s', position = '%s', id_group ='%s' + order_20 = '%d', trap_type = %d, single_value = '%s', + position = '%s', disable_event = %d, id_group ='%s' WHERE id_as = %d", $priority, $alert_type, @@ -366,6 +368,7 @@ if ($save_alert || $modify_alert) { $trap_type, $single_value, $position, + $disable_event, $group, $id_as ); @@ -460,6 +463,7 @@ if ($update_alert || $duplicate_alert) { $trap_type = $alert['trap_type']; $single_value = $alert['single_value']; $position = $alert['position']; + $disable_event = $alert['disable_event']; $group = $alert['id_group']; } else if ($create_alert) { // Variable init @@ -532,6 +536,7 @@ if ($update_alert || $duplicate_alert) { $trap_type = -1; $single_value = ''; $position = 0; + $disable_event = 0; $group = 0; } @@ -566,7 +571,7 @@ if ($duplicate_alert) { '.db_escape_key_identifier('_snmp_f18_').', '.db_escape_key_identifier('_snmp_f19_').', '.db_escape_key_identifier('_snmp_f20_').", - trap_type, single_value, position, id_group, + trap_type, single_value, position, disable_event, id_group, order_1, order_2, order_3, order_4, order_5, order_6, order_7, order_8, order_9, order_10, order_11, order_12, order_13, order_14, order_15, order_16, order_17, order_18, order_19, order_20) @@ -574,7 +579,7 @@ if ($duplicate_alert) { (%d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, '%s', '%s', '%s', %d, %d, %d, %d, %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', - '%s', '%s', '%s', '%s', %d, '%s', %d, %d, %d, %d, %d, %d, %d, %d, + '%s', '%s', '%s', '%s', %d, '%s', %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d)", $id_alert, $al_field1, @@ -627,6 +632,7 @@ if ($duplicate_alert) { $trap_type, $single_value, $position, + $disable_event, $group, $order_1, $order_2, @@ -1080,6 +1086,10 @@ if ($create_alert || $update_alert) { html_print_input_text('position', $position, '', 3); echo ''; + echo ''.__('Disable event').''; + + html_print_checkbox('disable_event', 1, $disable_event, false); + echo ''; echo ''; echo ""; diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index e07fc5f6ad..2a5ce407be 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -342,6 +342,7 @@ CREATE TABLE IF NOT EXISTS `talert_snmp` ( `trap_type` int(11) NOT NULL default '-1', `single_value` varchar(255) default '', `position` int(10) unsigned NOT NULL default '0', + `disable_event` tinyint(1) default 0, `id_group` int(10) unsigned NOT NULL default '0', `order_1` int(10) unsigned NOT NULL default 1, `order_2` int(10) unsigned NOT NULL default 2, @@ -487,6 +488,7 @@ CREATE TABLE IF NOT EXISTS `talert_templates` ( `special_day` tinyint(1) default 0, `wizard_level` enum('basic','advanced','nowizard') default 'nowizard', `min_alerts_reset_counter` tinyint(1) default 0, + `disable_event` tinyint(1) default 0, PRIMARY KEY (`id`), KEY `idx_template_action` (`id_alert_action`), FOREIGN KEY (`id_alert_action`) REFERENCES talert_actions(`id`) @@ -2857,6 +2859,7 @@ CREATE TABLE IF NOT EXISTS `tevent_alert` ( `force_execution` tinyint(1) default '0', `group_by` enum ('','id_agente','id_agentmodule','id_alert_am','id_grupo') default '', `special_days` tinyint(1) default 0, + `disable_event` tinyint(1) default 0, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 6abacb2429..f2ca2c162b 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -916,8 +916,7 @@ sub pandora_execute_alert ($$$$$$$$$;$) { } # Generate an event only if an event has not already been generated by an alert action - if ($event_generated == 0) { - + if ($event_generated == 0 && (! defined ($alert->{'disable_event'}) || (defined ($alert->{'disable_event'}) && $alert->{'disable_event'} == 0))) { #If we've spotted an alert recovered, we set the new event's severity to 2 (NORMAL), otherwise the original value is maintained. my ($text, $event, $severity) = ($alert_mode == RECOVERED_ALERT) ? ('recovered', 'alert_recovered', 2) : ('fired', 'alert_fired', $alert->{'priority'}); @@ -1426,8 +1425,9 @@ sub pandora_execute_action ($$$$$$$$$;$) { # Field 8 (comments); my $comment = $field8; - - pandora_event( + + if ((! defined($alert->{'disable_event'})) || (defined($alert->{'disable_event'}) && $alert->{'disable_event'} == 0)) { + pandora_event( $pa_config, $event_text, (defined ($agent) ? $agent->{'id_grupo'} : 0), @@ -1447,7 +1447,8 @@ sub pandora_execute_action ($$$$$$$$$;$) { $comment, $id_extra, $tags); - # Validate event (field1: agent name; field2: module name) + # Validate event (field1: agent name; field2: module name) + } } elsif ($clean_name eq "Validate Event") { my $agent_id = -1; my $module_id = -1; @@ -3866,6 +3867,7 @@ sub pandora_evaluate_snmp_alerts ($$$$$$$$$) { 'time_threshold' => 0, 'id' => $alert->{'id_alert'}, 'priority' => $alert->{'priority'}, + 'disable_event' => $alert->{'disable_event'} ); my %agent; @@ -3901,7 +3903,7 @@ sub pandora_evaluate_snmp_alerts ($$$$$$$$$) { pandora_execute_action ($pa_config, $trap_rcv_full, \%agent, \%alert, 1, $action, undef, $dbh, $timestamp, \%macros) if (defined ($action)); # Generate an event, ONLY if our alert action is different from generate an event. - if ($action->{'id_alert_command'} != 3){ + if ($action->{'id_alert_command'} != 3 && $alert->{'disable_event'} == 0){ pandora_event ($pa_config, "SNMP alert fired (" . safe_output($alert->{'description'}) . ")", 0, 0, $alert->{'priority'}, 0, 0, 'alert_fired', 0, $dbh); } @@ -3950,12 +3952,13 @@ sub pandora_evaluate_snmp_alerts ($$$$$$$$$) { 'time_threshold' => 0, 'id' => $other_alert->{'alert_type'}, 'priority' => $alert->{'priority'}, + 'disable_event' => $alert->{'disable_event'} ); pandora_execute_action ($pa_config, $trap_rcv_full, \%agent, \%alert_action, 1, $other_action, undef, $dbh, $timestamp, \%macros) if (defined ($other_action)); # Generate an event, ONLY if our alert action is different from generate an event. - if ($other_action->{'id_alert_command'} != 3){ + if ($other_action->{'id_alert_command'} != 3 && $alert->{'disable_event'} == 0){ pandora_event ($pa_config, "SNMP alert fired (" . safe_output($alert->{'description'}) . ")", 0, 0, $alert->{'priority'}, 0, 0, 'alert_fired', 0, $dbh); }