From be7a82bf7cbceec3b205956a0879678f0d94ffc4 Mon Sep 17 00:00:00 2001 From: juanmanuelr Date: Wed, 8 Feb 2012 13:04:18 +0000 Subject: [PATCH] 2012-02-08 Juan Manuel Ramon * images/skin/skin_default/include/styles/menu.css include/styles/menu.css: Added godmode events icon in menu. * include/functions_events.php: Added functions to support custom event filters. * pandoradb.sql pandoradb.postgreSQL.sql pandoradb.oracle.sql extras/pandoradb_migrate_4.0.x_to_4.1.mysql.sql extras/pandoradb_migrate_4.0.x_to_4.1.oracle.sql extras/pandoradb_migrate_4.0.x_to_4.1.postgreSQL.sql: Added table tevent_filter. * operation/events/events_list.php operation/events/events.php: Added event filters 'live' editor. * general/shortcut_bar.php: Fixed some bugs due to ACLs. * general/header.php: Removed trace. * godmode/menu.php: Added event godmode section. * godmode/events/event_edit_filter.php godmode/events/custom_events.php godmode/events/events.php godmode/events/event_filter.php: Added files: Entry point in event godmode section, events filter editor and event custom fields view. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5517 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 31 ++ .../pandoradb_migrate_4.0.x_to_4.1.mysql.sql | 22 ++ .../pandoradb_migrate_4.0.x_to_4.1.oracle.sql | 20 ++ ...doradb_migrate_4.0.x_to_4.1.postgreSQL.sql | 20 ++ pandora_console/general/header.php | 1 - pandora_console/general/shortcut_bar.php | 45 ++- .../godmode/events/custom_events.php | 4 +- .../godmode/events/event_edit_filter.php | 293 ++++++++++++++++ .../godmode/events/event_filter.php | 188 ++++++++++ pandora_console/godmode/events/events.php | 71 ++++ pandora_console/godmode/menu.php | 15 +- .../skin/skin_default/include/styles/menu.css | 4 +- pandora_console/include/functions_events.php | 203 +++++++++++ pandora_console/include/styles/menu.css | 4 +- pandora_console/operation/events/events.php | 74 ++-- .../operation/events/events_list.php | 321 +++++++++++++++++- pandora_console/pandoradb.oracle.sql | 20 ++ pandora_console/pandoradb.postgreSQL.sql | 20 ++ pandora_console/pandoradb.sql | 22 ++ 19 files changed, 1333 insertions(+), 45 deletions(-) create mode 100644 pandora_console/godmode/events/event_edit_filter.php create mode 100644 pandora_console/godmode/events/event_filter.php create mode 100644 pandora_console/godmode/events/events.php diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index ce87594f95..4e863a446b 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,34 @@ +2012-02-08 Juan Manuel Ramon + + * images/skin/skin_default/include/styles/menu.css + include/styles/menu.css: Added godmode events icon in menu. + + * include/functions_events.php: Added functions to support custom + event filters. + + * pandoradb.sql + pandoradb.postgreSQL.sql + pandoradb.oracle.sql + extras/pandoradb_migrate_4.0.x_to_4.1.mysql.sql + extras/pandoradb_migrate_4.0.x_to_4.1.oracle.sql + extras/pandoradb_migrate_4.0.x_to_4.1.postgreSQL.sql: Added table + tevent_filter. + + * operation/events/events_list.php + operation/events/events.php: Added event filters 'live' editor. + + * general/shortcut_bar.php: Fixed some bugs due to ACLs. + + * general/header.php: Removed trace. + + * godmode/menu.php: Added event godmode section. + + * godmode/events/event_edit_filter.php + godmode/events/custom_events.php + godmode/events/events.php + godmode/events/event_filter.php: Added files: Entry point in event + godmode section, events filter editor and event custom fields view. + 2012-02-08 Vanessa Gil * godmode/events/custom_events.php * operation/events/events_list.php: Added criticity alert to event view. 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 103980236c..ce6340f370 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 @@ -125,3 +125,25 @@ ALTER TABLE `tnetwork_component` CHANGE COLUMN `post_process` `post_process` dou -- Table `tgraph_source` Alter table to allow negative values in weight -- ----------------------------------------------------- ALTER TABLE tgraph_source MODIFY weight FLOAT(5,3) NOT NULL DEFAULT '0.000'; + +-- ----------------------------------------------------- +-- Table `tevent_filter` +-- ----------------------------------------------------- + +CREATE TABLE IF NOT EXISTS `tevent_filter` ( + `id_filter` int(10) unsigned NOT NULL auto_increment, + `id_name` varchar(600) NOT NULL, + `id_group` int(10) NOT NULL default 0, + `event_type` text NOT NULL default '', + `severity` int(10) NOT NULL default -1, + `status` int(10) NOT NULL default -1, + `search` TEXT default '', + `text_agent` TEXT default '', + `pagination` int(10) NOT NULL default 25, + `event_view_hr` int(10) NOT NULL default 8, + `id_user_ack` TEXT, + `group_rep` int(10) NOT NULL default 0, + `tag` varchar(600) NOT NULL default '', + `filter_only_alert` int(10) NOT NULL default -1, +PRIMARY KEY (`id_filter`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; 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 ae120810c7..bd59b345c1 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 @@ -122,3 +122,23 @@ ALTER TABLE talert_snmp add (_snmp_f5_ CLOB default ''); ALTER TABLE talert_snmp add (_snmp_f6_ CLOB default ''); ALTER TABLE talert_snmp add (trap_type NUMBER(10, 0) DEFAULT -1 NOT NULL); ALTER TABLE talert_snmp add (single_value VARCHAR2(255) DEFAULT ''); + +-- ----------------------------------------------------- +-- Table `tevent_filter` +-- ----------------------------------------------------- +CREATE TABLE tevent_filter ( + id_filter NUMBER(10, 0) NOT NULL PRIMARY KEY, + id_name VARCHAR2(600) NOT NULL, + id_group NUMBER(10, 0) default 0 NOT NULL, + event_type CLOB default '' NOT NULL, + severity NUMBER(10, 0) default -1 NOT NULL, + status NUMBER(10, 0) default -1 NOT NULL, + search CLOB default '', + text_agent CLOB default '', + pagination NUMBER(10, 0) default 25 NOT NULL, + event_view_hr NUMBER(10, 0) default 8 NOT NULL, + id_user_ack CLOB, + group_rep NUMBER(10, 0) default 0 NOT NULL, + tag VARCHAR2(600) default '' NOT NULL, + filter_only_alert NUMBER(10, 0) default -1 NOT NULL +); \ No newline at end of file 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 e1f2e90047..2a8d49a350 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 @@ -107,3 +107,23 @@ ALTER TABLE "talert_snmp" ADD COLUMN "_snmp_f5_" text DEFAULT ''; ALTER TABLE "talert_snmp" ADD COLUMN "_snmp_f6_" text DEFAULT ''; ALTER TABLE "talert_snmp" ADD COLUMN "trap_type" INTEGER NOT NULL DEFAULT '-1'; ALTER TABLE "talert_snmp" ADD COLUMN "single_value" varchar(255) DEFAULT ''; + +-- ----------------------------------------------------- +-- Table `tevent_filter` +-- ----------------------------------------------------- +CREATE TABLE "tevent_filter" ( + "id_filter" SERIAL NOT NULL PRIMARY KEY, + "id_name" varchar(600) NOT NULL, + "id_group" INTEGER NOT NULL default 0, + "event_type" TEXT NOT NULL default '', + "severity" INTEGER NOT NULL default -1, + "status" INTEGER NOT NULL default -1, + "search" TEXT default '', + "text_agent" TEXT default '', + "pagination" INTEGER NOT NULL default 25, + "event_view_hr" INTEGER NOT NULL default 8, + "id_user_ack" TEXT, + "group_rep" INTEGER NOT NULL default 0, + "tag" varchar(600) NOT NULL default '', + "filter_only_alert" INTEGER NOT NULL default -1 +); diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index 11addc44db..dcd7f960d9 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -208,7 +208,6 @@ $("#yougotalert").click(function () { $("#agent_access").css("display", "none"); }); $("#ui_close_dialog_titlebar").click(function () { - alert("LOLOLO"); $("#agent_access").css("display",""); }); diff --git a/pandora_console/general/shortcut_bar.php b/pandora_console/general/shortcut_bar.php index b8e294b80e..4a2bca36d2 100644 --- a/pandora_console/general/shortcut_bar.php +++ b/pandora_console/general/shortcut_bar.php @@ -39,9 +39,9 @@ $own_info = get_user_info ($config['id_user']); if ($own_info['is_admin'] || check_acl ($config['id_user'], 0, "PM")) - $own_groups = array_keys(users_get_groups($config['id_user'], "LM")); + $own_groups = array_keys(users_get_groups($config['id_user'], "IR")); else - $own_groups = array_keys(users_get_groups($config['id_user'], "LM", false)); + $own_groups = array_keys(users_get_groups($config['id_user'], "IR", false)); // Get events in the last 8 hours $shortcut_events_update = events_get_group_events($own_groups, 28800, time()); @@ -63,9 +63,9 @@ $own_info = get_user_info ($config['id_user']); if ($own_info['is_admin'] || check_acl ($config['id_user'], 0, "PM")) - $own_groups = array_keys(users_get_groups($config['id_user'], "LM")); + $own_groups = array_keys(users_get_groups($config['id_user'], "IR")); else - $own_groups = array_keys(users_get_groups($config['id_user'], "LM", false)); + $own_groups = array_keys(users_get_groups($config['id_user'], "IR", false)); $sql = "SELECT count(*) total_incidents FROM tincidencia WHERE id_grupo IN (".implode (",",array_keys ($own_groups)).") AND estado IN (0) @@ -104,7 +104,19 @@ } echo "     "; - echo ""; + $own_info = get_user_info ($config['id_user']); + + // If user is admin can see all groups + if ($own_info['is_admin'] || check_acl ($config['id_user'], 0, "PM")){ + echo ""; + } + else{ + $own_groups = array_keys(users_get_groups($config['id_user'], "AR", false)); + if (!empty($own_groups)){ + $alerts_group = array_shift($own_groups); + echo ""; + } + } html_print_image("images/bell.png", false, array("title" => __("Alerts fired"), "style" => "margin-bottom: -5px;")); echo " "; @@ -112,9 +124,24 @@ $data_reporting = reporting_get_group_stats(); echo "" . $data_reporting['monitor_alerts_fired'] . ""; - echo ""; + if (!empty($own_groups)){ + echo ""; + } echo "     "; - echo ""; + + $own_info = get_user_info ($config['id_user']); + + // If user is admin can see all groups + if ($own_info['is_admin'] || check_acl ($config['id_user'], 0, "PM")){ + echo ""; + } + else { + $own_groups = array_keys(users_get_groups($config['id_user'], "IR", false)); + if (!empty($own_groups)){ + $events_group = array_shift($own_groups); + echo ""; + } + } html_print_image("images/lightning_go.png", false, array("title" => __("Critical events"), "style" => "margin-bottom: -5px;")); echo " "; @@ -122,9 +149,9 @@ $own_info = get_user_info ($config['id_user']); if ($own_info['is_admin'] || check_acl ($config['id_user'], 0, "PM")) - $own_groups = array_keys(users_get_groups($config['id_user'], "LM")); + $own_groups = array_keys(users_get_groups($config['id_user'], "IR")); else - $own_groups = array_keys(users_get_groups($config['id_user'], "LM", false)); + $own_groups = array_keys(users_get_groups($config['id_user'], "IR", false)); // Get events in the last 8 hours $shortcut_events = events_get_group_events($own_groups, 28800, time()); diff --git a/pandora_console/godmode/events/custom_events.php b/pandora_console/godmode/events/custom_events.php index 697ac2db08..e9333e7606 100644 --- a/pandora_console/godmode/events/custom_events.php +++ b/pandora_console/godmode/events/custom_events.php @@ -25,8 +25,6 @@ if (! check_acl($config['id_user'], 0, "PM")) { return; } -// Header -ui_print_page_header (__('Custom events'), "", false, "", true); $update = get_parameter('update_config', 0); @@ -105,7 +103,7 @@ $table->data[1][2] .= '



' . html_print_image('images/darrowleft.p $table->data[1][3] = '' . __('Fields selected') . ''; $table->data[1][4] = html_print_select($result_selected, 'fields_selected[]', true, '', __('None'), '', true, true, false); -echo '
'; +echo ''; html_print_table($table); diff --git a/pandora_console/godmode/events/event_edit_filter.php b/pandora_console/godmode/events/event_edit_filter.php new file mode 100644 index 0000000000..d5261cf7d4 --- /dev/null +++ b/pandora_console/godmode/events/event_edit_filter.php @@ -0,0 +1,293 @@ + array('active' => false, + 'text' => '' . + html_print_image("images/zoom.png", true, array("title" => __('View events'))) . ''), + 'filter' => array('active' => true, + 'text' => '' . + html_print_image("images/lightning_go.png", true, array ("title" => __('Create filter'))) . ''), + 'fields' => array('active' => false, + 'text' => '' . + html_print_image("images/god6.png", true, array ("title" => __('Custom fields'))) . ''), + ); + +ui_print_page_header (__("Manage events") . ' - ' . __('Filters'), "images/lightning_go.png", false, "", true, $buttons); + +if ($id) { + $filter = events_get_event_filter ($id); + $id_group = $filter['id_group']; + $id_name = $filter['id_name']; + $event_type = $filter['event_type']; + $severity = $filter['severity']; + $status = $filter['status']; + $search = $filter['search']; + $text_agent = $filter['text_agent']; + $pagination = $filter['pagination']; + $event_view_hr = $filter['event_view_hr']; + $id_user_ack = $filter['id_user_ack']; + $group_rep = $filter['group_rep']; + $tag = $filter['tag']; + $filter_only_alert = $filter['filter_only_alert']; +} else { + $id_group = ''; + $id_name = ''; + $event_type = ''; + $severity = ''; + $status = ''; + $search = ''; + $text_agent = __('All'); + $pagination = ''; + $event_view_hr = ''; + $id_user_ack = ''; + $group_rep = ''; + $tag = ''; + $filter_only_alert = ''; +} + +if ($update) { + $id_group = (string) get_parameter ('id_group'); + $id_name = (string) get_parameter ('id_name'); + $event_type = get_parameter('event_type', ''); + $severity = get_parameter('severity', ''); + $status = get_parameter('status', ''); + $search = get_parameter('search', ''); + $text_agent = get_parameter('text_agent', __('All')); + $pagination = get_parameter('pagination', ''); + $event_view_hr = get_parameter('event_view_hr', ''); + $id_user_ack = get_parameter('id_user_ack', ''); + $group_rep = get_parameter('group_rep', ''); + $tag = get_parameter('tag', ''); + $filter_only_alert = get_parameter('filter_only_alert',''); + + if ($id_name == '') { + ui_print_error_message (__('Not updated. Blank name')); + } else { + $values = array ('id_filter' => $id, + 'id_name' => $id_name, + 'id_group' => $id_group, + 'event_type' => $event_type, + 'severity' => $severity, + 'status' => $status, + 'search' => $search, + 'text_agent' => $text_agent, + 'pagination' => $pagination, + 'event_view_hr' => $event_view_hr, + 'id_user_ack' => $id_user_ack, + 'group_rep' => $group_rep, + 'tag' => $tag, + 'filter_only_alert' => $filter_only_alert + ); + + $result = db_process_sql_update ('tevent_filter', $values, array ('id_filter' => $id)); + + ui_print_result_message ($result, + __('Successfully updated'), + __('Not updated. Error updating data')); + } +} + +if ($create) { + $id_group = (string) get_parameter ('id_group'); + $id_name = (string) get_parameter ('id_name'); + $event_type = get_parameter('event_type', ''); + $severity = get_parameter('severity', ''); + $status = get_parameter('status', ''); + $search = get_parameter('search', ''); + $text_agent = get_parameter('text_agent', ''); + $pagination = get_parameter('pagination', ''); + $event_view_hr = get_parameter('event_view_hr', ''); + $id_user_ack = get_parameter('id_user_ack', ''); + $group_rep = get_parameter('group_rep',' '); + $tag = get_parameter('tag', ''); + $filter_only_alert = get_parameter('filter_only_alert', ''); + + $values = array ( + 'id_name' => $id_name, + 'id_group' => $id_group, + 'event_type' => $event_type, + 'severity' => $severity, + 'status' => $status, + 'search' => $search, + 'text_agent' => $text_agent, + 'pagination' => $pagination, + 'event_view_hr' => $event_view_hr, + 'id_user_ack' => $id_user_ack, + 'group_rep' => $group_rep, + 'tag' => $tag, + 'filter_only_alert' => $filter_only_alert + ); + + $id = db_process_sql_insert('tevent_filter', $values); + + if ($id === false) { + ui_print_error_message ('Error creating filter'); + } else { + ui_print_success_message ('Filter created successfully'); + } +} + +$table->width = '98%'; +$table->border = 0; +$table->cellspacing = 3; +$table->cellpadding = 5; +$table->class = "databox_color"; +$table->style[0] = 'vertical-align: top;'; + +$table->data = array (); +$table->data[0][0] = ''.__('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][1] = html_print_select_groups($config['id_user'], "IW", + $own_info['is_admin'], 'id_group', $id_group, '', '', -1, true, + false, false); + +$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] = '' . __('Severity') . ''; +$table->data[3][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] = '' . __('Free search') . ''; +$table->data[5][1] = html_print_input_text ('search', io_safe_output($search), '', 15, 255, true); + +$table->data[6][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, '', +array('style' => 'background: url(' . $src_code . ') no-repeat right;'), true) +. ' ' . __("Type at least two characters to search") . ''; + +$lpagination[25] = 25; +$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] = '' . __('Max. hours old') . ''; +$table->data[8][1] = html_print_input_text ('event_view_hr', $event_view_hr, '', 5, 255, true); + +$table->data[9][0] = '' . __('User ack.') . ''; +$users = users_get_info (); +$table->data[9][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); + +$tags = tags_search_tag(); +if($tags === false) { + $tags = array(); +} + +$tags_name = array(); +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] = '' . __('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); + +echo ''; +html_print_table ($table); +echo '
'; +if ($id) { + html_print_input_hidden ('update', 1); + html_print_input_hidden ('id', $id); + html_print_submit_button (__('Update'), 'crt', false, 'class="sub upd"'); +} else { + html_print_input_hidden ('create', 1); + html_print_submit_button (__('Create'), 'crt', false, 'class="sub wand"'); +} +echo '
'; +echo '
'; + +ui_require_jquery_file ('bgiframe'); +ui_require_jquery_file ('autocomplete'); +?> + + diff --git a/pandora_console/godmode/events/event_filter.php b/pandora_console/godmode/events/event_filter.php new file mode 100644 index 0000000000..58a922f1c3 --- /dev/null +++ b/pandora_console/godmode/events/event_filter.php @@ -0,0 +1,188 @@ + array('active' => false, + 'text' => '' . + html_print_image("images/zoom.png", true, array("title" => __('View events'))) . ''), + 'filter' => array('active' => true, + 'text' => '' . + html_print_image("images/lightning_go.png", true, array ("title" => __('Create filter'))) . ''), + 'fields' => array('active' => false, + 'text' => '' . + html_print_image("images/god6.png", true, array ("title" => __('Custom fields'))) . ''), + ); + + ui_print_page_header (__("Manage events") . ' - ' . __('Filters'), "images/lightning_go.png", false, "", true, $buttons); +} + +if ($delete){ + + $id = (int) get_parameter('id'); + + $id_filter = db_get_value('id_name', 'tevent_filter', 'id_filter', $id); + + if ($id_filter === false) { + $result = false; + } + else { + $result = db_process_sql_delete ('tevent_filter', array ('id_filter' => $id)); + } + + if ($result !== false) { + $result = true; + } else { + $result = false; + } + + ui_print_result_message ($result, + __('Successfully deleted'), + __('Not deleted. Error deleting data')); + +} + +if ($multiple_delete) { + $ids = (array)get_parameter('delete_multiple', array()); + + db_process_sql_begin(); + + foreach ($ids as $id) { + $result = db_process_sql_delete ('tevent_filter', + array ('id_filter' => $id)); + + if ($result === false) { + db_process_sql_rollback(); + break; + } + } + + if ($result !== false) { + db_process_sql_commit(); + } + + if ($result !== false) $result = true; + else $result = false; + + ui_print_result_message ($result, + __('Successfully deleted'), + __('Not deleted. Error deleting data')); +} + +$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)).")"; +$filters = db_get_all_rows_sql($sql); + +if ($filters === false) + $filters = array (); + +$table->width = '98%'; +$table->head = array (); +$table->head[0] = __('Name'); +$table->head[1] = __('Group'); +$table->head[2] = __('Event type'); +$table->head[3] = __('Event status'); +$table->head[4] = __('Severity'); +$table->head[5] = __('Action') . + html_print_checkbox('all_delete', 0, false, true, false, 'check_all_checkboxes();'); +$table->style = array (); +$table->style[0] = 'font-weight: bold'; +$table->align = array (); +$table->align[1] = 'center'; +$table->align[2] = 'center'; +$table->align[3] = 'center'; +$table->align[4] = 'center'; +$table->align[5] = 'center'; +$table->size = array (); +$table->size[0] = '50%'; +$table->size[1] = '5px'; +$table->size[2] = '80px'; +$table->size[3] = '80px'; +$table->size[4] = '80px'; +$table->size[5] = '40px'; +$table->data = array (); + +$total_filters = db_get_all_rows_filter ('tevent_filter', false, 'COUNT(*) AS total'); +$total_filters = $total_filters[0]['total']; + +//ui_pagination ($total_filters, $url); + +foreach ($filters as $filter) { + $data = array (); + + $data[0] = ''.$filter['id_name'].''; + $data[1] = ui_print_group_icon ($filter['id_group'], 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']); + $data[5] = "" . + html_print_image('images/cross.png', true, array('title' => __('Delete'))) . "" . + html_print_checkbox_extended ('delete_multiple[]', $filter['id_filter'], false, false, '', 'class="check_delete"', true); + + array_push ($table->data, $data); +} + +if(isset($data)) { + echo "
"; + html_print_input_hidden('multiple_delete', 1); + html_print_table ($table); + echo "
"; + html_print_submit_button(__('Delete'), 'delete_btn', false, 'class="sub delete"'); + echo "
"; + echo "
"; +} +else { + echo "
".__('There are no defined filters')."
"; +} + +echo '
'; + echo "
"; + html_print_submit_button (__('Create filter'), 'crt', false, 'class="sub wand"'); + echo "
"; + echo '
'; + +?> + + diff --git a/pandora_console/godmode/events/events.php b/pandora_console/godmode/events/events.php new file mode 100644 index 0000000000..9b0447d4d3 --- /dev/null +++ b/pandora_console/godmode/events/events.php @@ -0,0 +1,71 @@ + array('active' => false, + 'text' => '' . + html_print_image("images/zoom.png", true, array("title" => __('View events'))) . ''), + 'separator' => array(), + 'filter' => array('active' => false, + 'text' => '' . + html_print_image("images/lightning_go.png", true, array ("title" => __('Create filter'))) . ''), + 'fields' => array('active' => false, + 'text' => '' . + html_print_image("images/god6.png", true, array ("title" => __('Custom fields'))) . ''), + ); + +switch ($section){ + case 'filter': $buttons['filter']['active'] = true; + $subpage = ' - ' . __('Filters'); + break; + case 'fields': $buttons['fields']['active'] = true; + $subpage = ' - ' . __('Custom fields'); + break; + case 'view': $buttons['view']['active'] = true; + break; + default: $buttons['filter']['active'] = true; + $subpage = ' - ' . __('Filters'); + break; +} + +ui_print_page_header (__("Manage events") . $subpage, "images/lightning_go.png", false, "", true, $buttons); + + +switch($section) { + case 'filter': + require_once('godmode/events/event_filter.php'); + break; + case 'fields': + require_once('godmode/events/custom_events.php'); + break; +} + +?> diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index e6c6e90a06..bd5bc06267 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -164,6 +164,19 @@ if (check_acl ($config['id_user'], 0, "IW")) { } } +if (check_acl ($config['id_user'], 0, "IW")) { + // Manage events + $menu["geventos"]["text"] = __('Manage events'); + $menu["geventos"]["sec2"] = "godmode/events/events&section=filter"; + $menu["geventos"]["id"] = "god-events"; + + // Custom event fields + $sub = array (); + $sub["godmode/events/events&section=fields"]["text"] = __('Custom events'); + + $menu["geventos"]["sub"] = $sub; +} + if (check_acl ($config['id_user'], 0, "AW")) { // Servers @@ -223,8 +236,6 @@ if (check_acl ($config['id_user'], 0, "PM")) { enterprise_hook ('enterprise_acl_submenu'); enterprise_hook ('skins_submenu'); $sub["extras/pandora_diag"]["text"] = __('Diagnostic info'); - - $sub["godmode/events/custom_events"]["text"] = __('Custom events'); $menu["gsetup"]["sub"] = $sub; } diff --git a/pandora_console/images/skin/skin_default/include/styles/menu.css b/pandora_console/images/skin/skin_default/include/styles/menu.css index ce874c118c..046d224437 100644 --- a/pandora_console/images/skin/skin_default/include/styles/menu.css +++ b/pandora_console/images/skin/skin_default/include/styles/menu.css @@ -189,4 +189,6 @@ #icon_god-tag { background-image: url(../../images/tag_red.png); } - +#icon_god-events { + background-image: url(../../images/lightning_go.png); +} diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 80593fa6fd..28255a6481 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -727,4 +727,207 @@ function events_get_module ($id_agent_module, $period, $date = 0) { return db_get_all_rows_sql ($sql); } +/** + * Decode a numeric type into type description. + * + * @param int $type_id Numeric type. + * + * @return string Type description. + */ +function events_get_event_types ($type_id){ + + $diferent_types = get_event_types (); + + $type_desc = ''; + switch($type_id) { + case 'unknown': $type_desc = __('Unknown'); + break; + case 'critical': $type_desc = __('Monitor Critical'); + break; + case 'warning': $type_desc = __('Monitor Warning'); + break; + case 'normal': $type_desc = __('Monitor Normal'); + break; + case 'alert_fired': $type_desc = __('Alert fired'); + break; + case 'alert_recovered': $type_desc = __('Alert recovered'); + break; + case 'alert_ceased': $type_desc = __('Alert ceased'); + break; + case 'alert_manual_validation': $type_desc = __('Alert manual validation'); + break; + case 'recon_host_detected': $type_desc = __('Recon host detected'); + break; + case 'system': $type_desc = __('System'); + break; + case 'error': $type_desc = __('Error'); + break; + case 'not_normal': $type_desc = __('Not normal'); + break; + default: + if (isset($config['text_char_long'])) { + foreach ($diferent_types as $key => $type) { + if ($key == $type_id){ + $type_desc = ui_print_truncate_text($type, $config['text_char_long'], false, true, false); + } + } + } + break; + } + + return $type_desc; +} + + +/** + * Decode a numeric severity into severity description. + * + * @param int $severity_id Numeric severity. + * + * @return string Severity description. + */ +function events_get_severity_types ($severity_id){ + + $diferent_types = get_priorities (); + + $severity_desc = ''; + switch ($severity_id) { + case 0: $severity_desc = __('Maintenance'); + break; + case 1: $severity_desc = __('Informational'); + break; + case 2: $severity_desc = __('Normal'); + break; + case 3: $severity_desc = __('Warning'); + break; + case 4: $severity_desc = __('Critical'); + break; + default: + if (isset($config['text_char_long'])) { + foreach ($diferent_types as $key => $type) { + if ($key == $severity_id){ + $severity_desc = ui_print_truncate_text($type, $config['text_char_long'], false, true, false); + } + } + } + break; + } + + return $severity_desc; +} + +/** + * Return all descriptions of event status. + * + * @return array Status description array. + */ +function events_get_all_status (){ + $fields = array (); + $fields[-1] = __('All event'); + $fields[0] = __('Only new'); + $fields[1] = __('Only validated'); + $fields[2] = __('Only in process'); + $fields[3] = __('Only not validated'); + + return $fields; +} + +/** + * Decode a numeric status into status description. + * + * @param int $status_id Numeric status. + * + * @return string Status description. + */ +function events_get_status ($status_id){ + switch($status_id) { + case -1: $status_desc = __('All event'); + break; + case 0: $status_desc = __('Only new'); + break; + case 1: $status_desc = __('Only validated'); + break; + case 2: $status_desc = __('Only in process'); + break; + case 3: $status_desc = __('Only not validated'); + break; + } + + return $status_desc; +} + +/** + * Checks if a user has permissions to see an event filter. + * + * @param int $id_filter Id of the event filter. + * + * @return bool True if the user has permissions or false otherwise. + */ +function events_check_event_filter_group ($id_filter) { + global $config; + + $id_group = db_get_value('id_group', 'tevent_filter', 'id_filter', $id_filter); + $own_info = get_user_info ($config['id_user']); + // Get group list that user has access + $groups_user = users_get_groups ($config['id_user'], "IW", $own_info['is_admin'], true); + $groups_id = array(); + $has_permission = false; + + foreach($groups_user as $key => $groups){ + if ($groups['id_grupo'] == $id_group) + return true; + } + + return false; +} + +/** + * Get a event filter. + * + * @param int Filter id to be fetched. + * @param array Extra filter. + * @param array Fields to be fetched. + * + * @return array A event filter matching id and filter or false. + */ +function events_get_event_filter ($id_filter, $filter = false, $fields = false) { + + if (empty($id_filter)){ + return false; + } + + if (! is_array ($filter)){ + $filter = array (); + $filter['id_filter'] = (int) $id_filter; + } + + return db_get_row_filter ('tevent_filter', $filter, $fields); +} + +/** + * Get a event filters in select format. + * + * @return array A event filter matching id and filter or false. + */ +function events_get_event_filter_select(){ + global $config; + + $user_groups = users_get_groups ($config['id_user'], "AW", true, true); + $sql = "SELECT id_filter, id_name FROM tevent_filter WHERE id_group IN (".implode(',', array_keys ($user_groups)).")"; + + $event_filters = db_get_all_rows_sql($sql); + + if ($event_filters === false){ + return array(); + } + else{ + $result = array(); + foreach ($event_filters as $event_filter){ + $result[$event_filter['id_filter']] = $event_filter['id_name']; + } + } + + return $result; +} + ?> diff --git a/pandora_console/include/styles/menu.css b/pandora_console/include/styles/menu.css index c898b9ea69..d780e3bfce 100644 --- a/pandora_console/include/styles/menu.css +++ b/pandora_console/include/styles/menu.css @@ -194,4 +194,6 @@ #icon_god-tag { background-image: url(../../images/tag_red.png); } - +#icon_god-events { + background-image: url(../../images/lightning_go.png); +} diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 391379b237..4663d53cb3 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -166,8 +166,10 @@ $group_rep = (int) get_parameter ("group_rep", 1); $delete = (bool) get_parameter ("delete"); $validate = (bool) get_parameter ("validate", 0); $section = (string) get_parameter ("section", "list"); -$text_agent = (string)get_parameter('text_agent', __("All")); -$filter_only_alert = (int)get_parameter('filter_only_alert', -1); +$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', ''); $search = io_safe_output(preg_replace ("/&([A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/", "&", rawurldecode (get_parameter ("search")))); @@ -187,27 +189,57 @@ $url = "index.php?sec=eventos&sec2=operation/events/events&search=" . if ($config["pure"] == 0) { $pss = get_user_info($config['id_user']); $hashup = md5($config['id_user'] . $pss['password']); + + // Fullscreen + $fullscreen['active'] = false; + $fullscreen['text'] = '' . + html_print_image("images/fullscreen.png", true, array ("title" => __('Full screen'))) .''; - $buttons = array( - 'fullscreen' => array('active' => false, - 'text' => '' . - html_print_image("images/fullscreen.png", true, array ("title" => __('Full screen'))) .''), - 'rss' => array('active' => false, - 'text' => '' . - html_print_image("images/rss.png", true, array ("title" => __('RSS Events'))) .''), - 'marquee' => array('active' => false, - 'text' => '' . - html_print_image("images/heart.png", true, array ("title" => __('Marquee display'))) .''), - 'csv' => array('active' => false, - 'text' => '' . - html_print_image("images/disk.png", true, array ("title" => __('Export to CSV file'))) .''), - 'sound_event' => array('active' => false, - 'text' => '' . html_print_image('images/music_note.png', true, array('title' => __('Sound events'))) . '') - ); + // Event list + $list['active'] = false; + $list['text'] = '' . + html_print_image("images/god6.png", true, array("title" => __('Event list'))) . ''; + $rss['active'] = false; + $rss['text'] = '' . + html_print_image("images/rss.png", true, array ("title" => __('RSS Events'))) .''; - ui_print_page_header (__("Events"), "images/lightning_go.png", false, "eventview", false, $buttons); + // Marquee + $marquee['active'] = false; + $marquee['text'] = '' . + html_print_image("images/heart.png", true, array ("title" => __('Marquee display'))) .''; + $csv['active'] = false; + $csv['text'] = '' . + html_print_image("images/disk.png", true, array ("title" => __('Export to CSV file'))) .''; + + // Sound events + $sound_event['active'] = false; + $sound_event['text'] = '' . html_print_image('images/music_note.png', true, array('title' => __('Sound events'))) . ''; + + // If the user has administrator permission display manage tab + if (check_acl ($config["id_user"], 0, "IW")) { + // Manage events + $manage_events['active'] = false; + $manage_events['text'] = '' . + html_print_image("images/setup.png", true, array ("title" => __('Manage events'))) . ''; + + $onheader = array('manage_events' => $manage_events, 'separator' => '', 'fullscreen' => $fullscreen, + 'list' => $list, 'rss' => $rss, 'marquee' => $marquee, 'csv' => $csv, 'sound_event' => $sound_event) ; + } + else { + $onheader = array('fullscreen' => $fullscreen, + 'list' => $list, 'rss' => $rss, 'marquee' => $marquee, 'csv' => $csv, 'sound_event' => $sound_event) ; + } + + switch ($section){ + case 'sound_event': $onheader['sound_event']['active'] = true; + break; + default: $onheader['list']['active'] = true; + break; + } + + ui_print_page_header (__("Events"), "images/lightning_go.png", false, "eventview", false, $onheader); ?> + diff --git a/pandora_console/pandoradb.oracle.sql b/pandora_console/pandoradb.oracle.sql index 6fe3940501..c72a216a69 100644 --- a/pandora_console/pandoradb.oracle.sql +++ b/pandora_console/pandoradb.oracle.sql @@ -1556,3 +1556,23 @@ show_graph VARCHAR2(60), CREATE SEQUENCE tnetflow_report_content_s INCREMENT BY 1 START WITH 1; CREATE OR REPLACE TRIGGER tnetflow_report_content_inc BEFORE INSERT ON tnetflow_report_content REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tnetflow_report_content_s.nextval INTO :NEW.ID_RC FROM dual; END tnetflow_report_content_inc;; + +-- ----------------------------------------------------- +-- Table `tevent_filter` +-- ----------------------------------------------------- +CREATE TABLE tevent_filter ( + id_filter NUMBER(10, 0) NOT NULL PRIMARY KEY, + id_name VARCHAR2(600) NOT NULL, + id_group NUMBER(10, 0) default 0 NOT NULL, + event_type CLOB default '' NOT NULL, + severity NUMBER(10, 0) default -1 NOT NULL, + status NUMBER(10, 0) default -1 NOT NULL, + search CLOB default '', + text_agent CLOB default '', + pagination NUMBER(10, 0) default 25 NOT NULL, + event_view_hr NUMBER(10, 0) default 8 NOT NULL, + id_user_ack CLOB, + group_rep NUMBER(10, 0) default 0 NOT NULL, + tag VARCHAR2(600) default '' NOT NULL, + filter_only_alert NUMBER(10, 0) default -1 NOT NULL +); diff --git a/pandora_console/pandoradb.postgreSQL.sql b/pandora_console/pandoradb.postgreSQL.sql index 3dd327de5f..bd57ea784b 100644 --- a/pandora_console/pandoradb.postgreSQL.sql +++ b/pandora_console/pandoradb.postgreSQL.sql @@ -1254,3 +1254,23 @@ CREATE TABLE "tnetflow_report_content" ( "show_graph" varchar(60), "order" INTEGER NOT NULL default 0 ); + +-- ----------------------------------------------------- +-- Table `tevent_filter` +-- ----------------------------------------------------- +CREATE TABLE "tevent_filter" ( + "id_filter" SERIAL NOT NULL PRIMARY KEY, + "id_name" varchar(600) NOT NULL, + "id_group" INTEGER NOT NULL default 0, + "event_type" TEXT NOT NULL default '', + "severity" INTEGER NOT NULL default -1, + "status" INTEGER NOT NULL default -1, + "search" TEXT default '', + "text_agent" TEXT default '', + "pagination" INTEGER NOT NULL default 25, + "event_view_hr" INTEGER NOT NULL default 8, + "id_user_ack" TEXT, + "group_rep" INTEGER NOT NULL default 0, + "tag" varchar(600) NOT NULL default '', + "filter_only_alert" INTEGER NOT NULL default -1 +); diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index c7c15fc67c..e21471e8b1 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -1356,3 +1356,25 @@ CREATE TABLE IF NOT EXISTS `tnetflow_report_content` ( FOREIGN KEY (`id_filter`) REFERENCES tnetflow_filter(`id_sg`) ON DELETE CASCADE ) ENGINE = InnoDB DEFAULT CHARSET=utf8; + +-- ----------------------------------------------------- +-- Table `tevent_filter` +-- ----------------------------------------------------- + +CREATE TABLE IF NOT EXISTS `tevent_filter` ( + `id_filter` int(10) unsigned NOT NULL auto_increment, + `id_name` varchar(600) NOT NULL, + `id_group` int(10) NOT NULL default 0, + `event_type` text NOT NULL default '', + `severity` int(10) NOT NULL default -1, + `status` int(10) NOT NULL default -1, + `search` TEXT default '', + `text_agent` TEXT default '', + `pagination` int(10) NOT NULL default 25, + `event_view_hr` int(10) NOT NULL default 8, + `id_user_ack` TEXT, + `group_rep` int(10) NOT NULL default 0, + `tag` varchar(600) NOT NULL default '', + `filter_only_alert` int(10) NOT NULL default -1, +PRIMARY KEY (`id_filter`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8;