diff --git a/pandora_console/extras/pandoradb_migrate_4.0.x_to_4.1.mysql.sql b/pandora_console/extras/pandoradb_migrate_4.0.x_to_4.1.mysql.sql index d29227ed00..4e13781cc2 100644 --- a/pandora_console/extras/pandoradb_migrate_4.0.x_to_4.1.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_4.0.x_to_4.1.mysql.sql @@ -132,6 +132,7 @@ ALTER TABLE tgraph_source MODIFY weight FLOAT(5,3) NOT NULL DEFAULT '0.000'; CREATE TABLE IF NOT EXISTS `tevent_filter` ( `id_filter` int(10) unsigned NOT NULL auto_increment, + `id_group_filter` int(10) NOT NULL default 0, `id_name` varchar(600) NOT NULL, `id_group` int(10) NOT NULL default 0, `event_type` text NOT NULL default '', diff --git a/pandora_console/extras/pandoradb_migrate_4.0.x_to_4.1.oracle.sql b/pandora_console/extras/pandoradb_migrate_4.0.x_to_4.1.oracle.sql index 82793616a0..6b2cc8f048 100644 --- a/pandora_console/extras/pandoradb_migrate_4.0.x_to_4.1.oracle.sql +++ b/pandora_console/extras/pandoradb_migrate_4.0.x_to_4.1.oracle.sql @@ -127,6 +127,7 @@ ALTER TABLE talert_snmp add (single_value VARCHAR2(255) DEFAULT ''); -- ----------------------------------------------------- CREATE TABLE tevent_filter ( id_filter NUMBER(10, 0) NOT NULL PRIMARY KEY, + id_group_filter NUMBER(10, 0) default 0 NOT NULL, id_name VARCHAR2(600) NOT NULL, id_group NUMBER(10, 0) default 0 NOT NULL, event_type CLOB default '' NOT NULL, diff --git a/pandora_console/extras/pandoradb_migrate_4.0.x_to_4.1.postgreSQL.sql b/pandora_console/extras/pandoradb_migrate_4.0.x_to_4.1.postgreSQL.sql index c4da9de0aa..be37b7d066 100644 --- a/pandora_console/extras/pandoradb_migrate_4.0.x_to_4.1.postgreSQL.sql +++ b/pandora_console/extras/pandoradb_migrate_4.0.x_to_4.1.postgreSQL.sql @@ -112,6 +112,7 @@ ALTER TABLE "talert_snmp" ADD COLUMN "single_value" varchar(255) DEFAULT ''; -- ----------------------------------------------------- CREATE TABLE "tevent_filter" ( "id_filter" SERIAL NOT NULL PRIMARY KEY, + "id_group_filter" INTEGER NOT NULL default 0, "id_name" varchar(600) NOT NULL, "id_group" INTEGER NOT NULL default 0, "event_type" TEXT NOT NULL default '', diff --git a/pandora_console/godmode/events/event_edit_filter.php b/pandora_console/godmode/events/event_edit_filter.php index d5261cf7d4..c8e62b3e04 100644 --- a/pandora_console/godmode/events/event_edit_filter.php +++ b/pandora_console/godmode/events/event_edit_filter.php @@ -53,6 +53,7 @@ ui_print_page_header (__("Manage events") . ' - ' . __('Filters'), "images/light if ($id) { $filter = events_get_event_filter ($id); + $id_group_filter = $filter['id_group_filter']; $id_group = $filter['id_group']; $id_name = $filter['id_name']; $event_type = $filter['event_type']; @@ -68,6 +69,7 @@ if ($id) { $filter_only_alert = $filter['filter_only_alert']; } else { $id_group = ''; + $id_group_filter = ''; $id_name = ''; $event_type = ''; $severity = ''; @@ -84,6 +86,7 @@ if ($id) { if ($update) { $id_group = (string) get_parameter ('id_group'); + $id_group_filter = get_parameter('id_group_filter'); $id_name = (string) get_parameter ('id_name'); $event_type = get_parameter('event_type', ''); $severity = get_parameter('severity', ''); @@ -102,6 +105,7 @@ if ($update) { } else { $values = array ('id_filter' => $id, 'id_name' => $id_name, + 'id_group_filter' => $id_group_filter, 'id_group' => $id_group, 'event_type' => $event_type, 'severity' => $severity, @@ -127,6 +131,7 @@ if ($update) { if ($create) { $id_group = (string) get_parameter ('id_group'); $id_name = (string) get_parameter ('id_name'); + $id_group_filter = get_parameter('id_group_filter'); $event_type = get_parameter('event_type', ''); $severity = get_parameter('severity', ''); $status = get_parameter('status', ''); @@ -140,7 +145,8 @@ if ($create) { $filter_only_alert = get_parameter('filter_only_alert', ''); $values = array ( - 'id_name' => $id_name, + 'id_name' => $id_name, + 'id_group_filter' => $id_group_filter, 'id_group' => $id_group, 'event_type' => $event_type, 'severity' => $severity, @@ -172,12 +178,17 @@ $table->class = "databox_color"; $table->style[0] = 'vertical-align: top;'; $table->data = array (); -$table->data[0][0] = ''.__('Name').''; +$table->data[0][0] = ''.__('Filter name').''; $table->data[0][1] = html_print_input_text ('id_name', $id_name, false, 20, 80, true); -$own_info = get_user_info ($config['id_user']); -$table->data[1][0] = ''.__('Group').''; +$table->data[1][0] = ''.__('Filter group').'' . ui_print_help_tip(__('This group will be use to restrict the visibility of this filter with ACLs'), true); $table->data[1][1] = html_print_select_groups($config['id_user'], "IW", + $own_info['is_admin'], 'id_group_filter', $id_group_filter, '', '', -1, true, + false, false); + +$own_info = get_user_info ($config['id_user']); +$table->data[2][0] = ''.__('Group').''; +$table->data[2][1] = html_print_select_groups($config['id_user'], "IW", $own_info['is_admin'], 'id_group', $id_group, '', '', -1, true, false, false); @@ -185,23 +196,23 @@ $types = get_event_types (); // Expand standard array to add not_normal (not exist in the array, used only for searches) $types["not_normal"] = __("Not normal"); -$table->data[2][0] = '' . __('Event type') . ''; -$table->data[2][1] = html_print_select ($types, 'event_type', $event_type, '', __('All'), '', true); +$table->data[3][0] = '' . __('Event type') . ''; +$table->data[3][1] = html_print_select ($types, 'event_type', $event_type, '', __('All'), '', true); -$table->data[3][0] = '' . __('Severity') . ''; -$table->data[3][1] = html_print_select (get_priorities (), "severity", $severity, '', __('All'), '-1', true); +$table->data[4][0] = '' . __('Severity') . ''; +$table->data[4][1] = html_print_select (get_priorities (), "severity", $severity, '', __('All'), '-1', true); $fields = events_get_all_status(); -$table->data[4][0] = '' . __('Event status') . ''; -$table->data[4][1] = html_print_select ($fields, 'status', $status, '', '', '', true); +$table->data[5][0] = '' . __('Event status') . ''; +$table->data[5][1] = html_print_select ($fields, 'status', $status, '', '', '', true); -$table->data[5][0] = '' . __('Free search') . ''; -$table->data[5][1] = html_print_input_text ('search', io_safe_output($search), '', 15, 255, true); +$table->data[6][0] = '' . __('Free search') . ''; +$table->data[6][1] = html_print_input_text ('search', io_safe_output($search), '', 15, 255, true); -$table->data[6][0] = '' . __('Agent search') . ''; +$table->data[7][0] = '' . __('Agent search') . ''; $src_code = html_print_image('images/lightning.png', true, false, true); -$table->data[6][1] = html_print_input_text_extended ('text_agent', $text_agent, 'text_id_agent', '', 30, 100, false, '', +$table->data[7][1] = html_print_input_text_extended ('text_agent', $text_agent, 'text_id_agent', '', 30, 100, false, '', array('style' => 'background: url(' . $src_code . ') no-repeat right;'), true) . ' ' . __("Type at least two characters to search") . ''; @@ -210,20 +221,20 @@ $lpagination[50] = 50; $lpagination[100] = 100; $lpagination[200] = 200; $lpagination[500] = 500; -$table->data[7][0] = '' . __('Block size for pagination') . ''; -$table->data[7][1] = html_print_select ($lpagination, "pagination", $pagination, '', __('Default'), $config["block_size"], true); +$table->data[8][0] = '' . __('Block size for pagination') . ''; +$table->data[8][1] = html_print_select ($lpagination, "pagination", $pagination, '', __('Default'), $config["block_size"], true); -$table->data[8][0] = '' . __('Max. hours old') . ''; -$table->data[8][1] = html_print_input_text ('event_view_hr', $event_view_hr, '', 5, 255, true); +$table->data[9][0] = '' . __('Max. hours old') . ''; +$table->data[9][1] = html_print_input_text ('event_view_hr', $event_view_hr, '', 5, 255, true); -$table->data[9][0] = '' . __('User ack.') . ''; +$table->data[10][0] = '' . __('User ack.') . ''; $users = users_get_info (); -$table->data[9][1] = html_print_select ($users, "id_user_ack", $id_user_ack, '', __('Any'), 0, true); +$table->data[10][1] = html_print_select ($users, "id_user_ack", $id_user_ack, '', __('Any'), 0, true); $repeated_sel[0] = __("All events"); $repeated_sel[1] = __("Group events"); -$table->data[10][0] = '' . __('Repeated') . ''; -$table->data[10][1] = html_print_select ($repeated_sel, "group_rep", $group_rep, '', '', '', true); +$table->data[11][0] = '' . __('Repeated') . ''; +$table->data[11][1] = html_print_select ($repeated_sel, "group_rep", $group_rep, '', '', '', true); $tags = tags_search_tag(); if($tags === false) { @@ -235,11 +246,11 @@ foreach($tags as $t) { $tags_name[$t['name']] = $t['name']; } -$table->data[11][0] = '' . __('Tag') . ''; -$table->data[11][1] = html_print_select ($tags_name, "tag", $tag, '', __('All'), "", true); +$table->data[12][0] = '' . __('Tag') . ''; +$table->data[12][1] = html_print_select ($tags_name, "tag", $tag, '', __('All'), "", true); -$table->data[12][0] = '' . __('Alert events') . ''; -$table->data[12][1] = html_print_select (array('-1' => __('All'), '0' => __('Filter alert events'), '1' => __('Only alert events')), "filter_only_alert", $filter_only_alert, '', '', '', true); +$table->data[13][0] = '' . __('Alert events') . ''; +$table->data[13][1] = html_print_select (array('-1' => __('All'), '0' => __('Filter alert events'), '1' => __('Only alert events')), "filter_only_alert", $filter_only_alert, '', '', '', true); echo '
'; html_print_table ($table); diff --git a/pandora_console/godmode/events/event_filter.php b/pandora_console/godmode/events/event_filter.php index 58a922f1c3..6cb913a56a 100644 --- a/pandora_console/godmode/events/event_filter.php +++ b/pandora_console/godmode/events/event_filter.php @@ -102,7 +102,7 @@ $own_info = get_user_info ($config['id_user']); // Get group list that user has access $groups_user = users_get_groups ($config['id_user'], "AW", $own_info['is_admin'], true); -$sql = "SELECT * FROM tevent_filter WHERE id_group IN (".implode(',', array_keys ($groups_user)).")"; +$sql = "SELECT * FROM tevent_filter WHERE id_group_filter IN (".implode(',', array_keys ($groups_user)).")"; $filters = db_get_all_rows_sql($sql); if ($filters === false) @@ -111,7 +111,7 @@ if ($filters === false) $table->width = '98%'; $table->head = array (); $table->head[0] = __('Name'); -$table->head[1] = __('Group'); +$table->head[1] = __('Filter group'); $table->head[2] = __('Event type'); $table->head[3] = __('Event status'); $table->head[4] = __('Severity'); @@ -143,7 +143,7 @@ foreach ($filters as $filter) { $data = array (); $data[0] = ''.$filter['id_name'].''; - $data[1] = ui_print_group_icon ($filter['id_group'], true); + $data[1] = ui_print_group_icon ($filter['id_group_filter'], true); $data[2] = events_get_event_types($filter['event_type']); $data[3] = events_get_status($filter['status']); $data[4] = events_get_severity_types($filter['severity']); diff --git a/pandora_console/godmode/snmpconsole/snmp_alert.php b/pandora_console/godmode/snmpconsole/snmp_alert.php index 893c49915f..88a7d51b42 100644 --- a/pandora_console/godmode/snmpconsole/snmp_alert.php +++ b/pandora_console/godmode/snmpconsole/snmp_alert.php @@ -185,7 +185,9 @@ if (isset ($_GET["delete_alert"])) { // Delete alert if (isset ($_GET["update_alert"])) { //the update_alert means the form should be displayed. If update_alert > 1 then an existing alert is updated echo ''; - echo ''; + echo '
'; + + echo ''; // Alert type (e-mail, event etc.) echo ''; - // Custom - echo ''; // Custom OID/Data #1 - echo ''; // Custom OID/Data #2 - echo ''; // Custom OID/Data #3 - echo ''; // Custom OID/Data #4 - echo ''; // Custom OID/Data #5 - echo ''; // Custom OID/Data #6 - echo ''; - - // SNMP Agent - echo ''; - + // Alert fields echo ''; + echo '
' . __('Alert configuration') . ui_print_help_icon("snmp_alert_configuration", true) . '
'.__('Alert action').''; @@ -223,25 +225,17 @@ if (isset ($_GET["update_alert"])) { html_print_input_text ("oid", $oid, '', 50); echo '
'.__('Global match'); - echo ui_print_help_icon ("snmp_alert_custom", true); - - echo ''; - html_print_textarea ("custom_value", $custom_value, 2, $custom_value, 'style="width:400px;"'); - - echo '
'.__('Custom OID/Data #1'); - //echo ui_print_help_icon ("snmp_alert_custom", true); + echo '
'.__('Field #1 Match'); + echo ui_print_help_icon ("field_match_snmp", true); echo ''; html_print_input_text ("custom_oid_data_1", $custom_oid_data_1, '', 60); echo '
'.__('Custom OID/Data #2'); + echo '
'.__('Field #2 Match'); //echo ui_print_help_icon ("snmp_alert_custom", true); echo ''; @@ -249,7 +243,7 @@ if (isset ($_GET["update_alert"])) { echo '
'.__('Custom OID/Data #3'); + echo '
'.__('Field #3 Match'); //echo ui_print_help_icon ("snmp_alert_custom", true); echo ''; @@ -257,7 +251,7 @@ if (isset ($_GET["update_alert"])) { echo '
'.__('Custom OID/Data #4'); + echo '
'.__('Field #4 Match'); //echo ui_print_help_icon ("snmp_alert_custom", true); echo ''; @@ -265,7 +259,7 @@ if (isset ($_GET["update_alert"])) { echo '
'.__('Custom OID/Data #5'); + echo '
'.__('Field #5 Match'); //echo ui_print_help_icon ("snmp_alert_custom", true); echo ''; @@ -273,18 +267,13 @@ if (isset ($_GET["update_alert"])) { echo '
'.__('Custom OID/Data #6'); + echo '
'.__('Field #6 Match'); //echo ui_print_help_icon ("snmp_alert_custom", true); echo ''; html_print_input_text ("custom_oid_data_6", $custom_oid_data_6, '', 60); echo '
'.__('SNMP Agent').' (IP)'; - html_print_input_text ("source_ip", $source_ip, '', 20); - echo '
'.__('Field #1 (Alias, name)'); echo ui_print_help_icon ("snmp_alert_field1", true); @@ -334,6 +323,27 @@ if (isset ($_GET["update_alert"])) { echo '
'.__('Priority').''; echo html_print_select (get_priorities (), "priority", $priority, '', '', '0', false, false, false); echo '
'; + + /* SNMP alert filters */ + + echo ''; + + echo ''; + + // Custom + echo ''; + + // SNMP Agent + echo ''; // Trap type echo ''; //Button + //echo '
' . __('Alert filters') . ui_print_help_icon("snmp_alert_filters", true) . '
'.__('Custom Value/OID'); + echo ui_print_help_icon ("snmp_alert_custom", true); + + echo ''; + html_print_textarea ("custom_value", $custom_value, 2, $custom_value, 'style="width:400px;"'); + + echo '
'.__('SNMP Agent').' (IP)'; + html_print_input_text ("source_ip", $source_ip, '', 20); + echo '
'.__('Trap type').''; @@ -347,15 +357,21 @@ if (isset ($_GET["update_alert"])) { echo '
'; + + + // End table + echo "
"; + + echo ""; echo '
'; if ($id_as > 0) { html_print_submit_button (__('Update'), "submit", false, 'class="sub upd"', false); } else { html_print_submit_button (__('Create'), "submit", false, 'class="sub wand"', false); } - - // End table - echo "
"; + echo ''; + echo ""; } else { require_once ('include/functions_alerts.php'); diff --git a/pandora_console/include/help/en/help_field_match_snmp.php b/pandora_console/include/help/en/help_field_match_snmp.php new file mode 100644 index 0000000000..b03a07f565 --- /dev/null +++ b/pandora_console/include/help/en/help_field_match_snmp.php @@ -0,0 +1,9 @@ + + +

Fields match 1-6

+ +

There are regular expressions. It is possible to use selectors in order to select a part of the regular expression that will be load in _snmp_fx_ macro. You can use these macros in Field #1 (Alias, name), Field #2 (Single Line) and Field #3 (Full Text).

diff --git a/pandora_console/include/help/en/help_snmp_alert_configuration.php b/pandora_console/include/help/en/help_snmp_alert_configuration.php new file mode 100644 index 0000000000..290a98aaa6 --- /dev/null +++ b/pandora_console/include/help/en/help_snmp_alert_configuration.php @@ -0,0 +1,9 @@ + + +

Alert configuration

+ +

These are the fields needed to perfom the SNMP alert configuration. Part of the fields could be parametrized by the macros obtained in fields "Field #x Match" and "Custom Value/OID".

diff --git a/pandora_console/include/help/en/help_snmp_alert_custom.php b/pandora_console/include/help/en/help_snmp_alert_custom.php index 33058b016e..00ef6ad872 100644 --- a/pandora_console/include/help/en/help_snmp_alert_custom.php +++ b/pandora_console/include/help/en/help_snmp_alert_custom.php @@ -4,6 +4,7 @@ */ ?> -

Global match

+

Custom Value/OID

-

This search in the trap "Value" fields, and also in the fields "Custom OID" and "Custom Value", that is, in the rest of the TRAP fields.

+

This search in the trap "Value" fields, and also in the fields "Custom OID" and "Custom Value", that is, in the rest of the TRAP fields. If you use a regular expression you can use selectors in order to load _snmp_f1_, _snmp_f2_ and _snmp_f3_ macros and replace it in Field #1 (Alias, name), Field #2 (Single Line) +and Field #3 (Full Text).

diff --git a/pandora_console/include/help/en/help_snmp_alert_filters.php b/pandora_console/include/help/en/help_snmp_alert_filters.php new file mode 100644 index 0000000000..bb316eb4b2 --- /dev/null +++ b/pandora_console/include/help/en/help_snmp_alert_filters.php @@ -0,0 +1,9 @@ + + +

Alert filters

+ +

These are the conditions needed to fire the SNMP alert. All conditions must be fullfiled in order to fire the SNMP alert.

diff --git a/pandora_console/include/help/es/help_field_match_snmp.php b/pandora_console/include/help/es/help_field_match_snmp.php new file mode 100644 index 0000000000..02c2dae108 --- /dev/null +++ b/pandora_console/include/help/es/help_field_match_snmp.php @@ -0,0 +1,9 @@ + + +

Fields match 1-6

+ +

Son expresiones regulares. Es posible usar selectores para seleccionar parte de la expresión regular que se cargará en la macro _snmp_fx_. Puedes usar estas macros en los campos Field #1 (Alias, name), Field #2 (Single Line) y Field #3 (Full Text).

diff --git a/pandora_console/include/help/es/help_snmp_alert_configuration.php b/pandora_console/include/help/es/help_snmp_alert_configuration.php new file mode 100644 index 0000000000..bb3c08203a --- /dev/null +++ b/pandora_console/include/help/es/help_snmp_alert_configuration.php @@ -0,0 +1,9 @@ + + +

Alert configuration

+ +

Estos campos son necesarios para realizar la configuración de la alerta SNMP. Parte de estos campos pueden ser configurados por las macros obtenidas por los campos "Field #x Match" y "Custom Value/OID".

diff --git a/pandora_console/include/help/es/help_snmp_alert_custom.php b/pandora_console/include/help/es/help_snmp_alert_custom.php index 92ab2643ce..fb2882fc4e 100644 --- a/pandora_console/include/help/es/help_snmp_alert_custom.php +++ b/pandora_console/include/help/es/help_snmp_alert_custom.php @@ -4,6 +4,7 @@ */ ?> -

Global match

+

Custom Value/OID

-

Campos personalizados enviados en el trap. Pueden ser datos muy complejos, que tengan una lógica específica en función del dispositivo que envía el trap. Un trap puede enviar varios datos en este campo.

+

Campos personalizados enviados en el trap. Pueden ser datos muy complejos, que tengan una lógica específica en función del dispositivo que envía el trap. Un trap puede enviar varios datos en este campo. Si usas expresion regular puedes usar selectores para cargar las macros _snmp_f1_, _snmp_f2_ y _snmp_f3_ y reemplazarlas Field #1 (Alias, name), Field #2 (Single Line) +y Field #3 (Full Text).

diff --git a/pandora_console/include/help/es/help_snmp_alert_filters.php b/pandora_console/include/help/es/help_snmp_alert_filters.php new file mode 100644 index 0000000000..1ee32f5bf3 --- /dev/null +++ b/pandora_console/include/help/es/help_snmp_alert_filters.php @@ -0,0 +1,9 @@ + + +

Alert filters

+ +

Estas son las condiciones necesarias para que se dispare la alerta SNMP. Todas las condiciones tienen que satisfacerse para que la alarma SNMP se dispare.

diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 4663d53cb3..9a9d4fe345 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -170,6 +170,7 @@ $text_agent = (string) get_parameter('text_agent', __("All")); $filter_only_alert = (int) get_parameter('filter_only_alert', -1); $filter_id = (int) get_parameter('filter_id', 0); $id_name = (string) get_parameter('id_name', ''); +$id_group = (int) get_parameter('id_group', 0); $search = io_safe_output(preg_replace ("/&([A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/", "&", rawurldecode (get_parameter ("search")))); @@ -379,6 +380,13 @@ $(document).ready( function() { $("#tgl_event_control").click (function () { $("#event_control").toggle (); + // Trick to don't collapse filter if autorefresh button has been pushed + if ($("#hidden-toogle_filter").val() == 'true'){ + $("#hidden-toogle_filter").val('false'); + } + else{ + $("#hidden-toogle_filter").val('true'); + } return false; }); diff --git a/pandora_console/operation/events/events_list.php b/pandora_console/operation/events/events_list.php index 79e759b5ae..f8f05dff98 100644 --- a/pandora_console/operation/events/events_list.php +++ b/pandora_console/operation/events/events_list.php @@ -68,7 +68,8 @@ if (is_ajax()){ $values['id_user_ack'] = get_parameter('id_user_ack'); $values['group_rep'] = get_parameter('group_rep'); $values['tag'] = get_parameter('tag'); - $values['filter_only_alert'] = get_parameter('filter_only_alert'); + $values['filter_only_alert'] = get_parameter('filter_only_alert'); + $values['id_group_filter'] = get_parameter('id_group_filter'); $result = db_process_sql_insert('tevent_filter', $values); @@ -95,9 +96,9 @@ if (is_ajax()){ $values['id_user_ack'] = get_parameter('id_user_ack'); $values['group_rep'] = get_parameter('group_rep'); $values['tag'] = get_parameter('tag'); - $values['filter_only_alert'] = get_parameter('filter_only_alert'); - - + $values['filter_only_alert'] = get_parameter('filter_only_alert'); + $values['id_group_filter'] = get_parameter('id_group_filter'); + $result = db_process_sql_update('tevent_filter', $values, array('id_filter' => $id)); if ($result === false){ @@ -251,12 +252,17 @@ echo ''.__('Event control filter').'&n echo '