From e6efe5825bca9099edc8626f6fb43dbc0336cb1a Mon Sep 17 00:00:00 2001 From: Arturo Gonzalez Date: Thu, 22 Jun 2017 09:28:07 +0200 Subject: [PATCH] Added active filters to snmp console --- pandora_console/include/functions_snmp.php | 107 ++++++++++++++++++ .../operation/snmpconsole/snmp_view.php | 22 +++- 2 files changed, 124 insertions(+), 5 deletions(-) diff --git a/pandora_console/include/functions_snmp.php b/pandora_console/include/functions_snmp.php index 71a232280e..fe5333f162 100644 --- a/pandora_console/include/functions_snmp.php +++ b/pandora_console/include/functions_snmp.php @@ -279,4 +279,111 @@ function snmp_update_translation($oid, $new_oid, $description, $post_process) { } } } + +/* + * Print the event filter tag cloud (enterprise feature) + * @param $filter_resume: Array with the active filters + * @param $filter_refs: Array of all arrays to humanize some tags + */ +function print_snmp_tags_active_filters ($filter_resume = array()) { + global $config; + + $tags_set = array(); + + // Alert + if (isset($filter_resume['filter_fired'])) { + array_push ($tags_set, array( + 'title' => __('Alert'), + 'value' => $filter_resume['filter_fired'] + )); + } + // Severity + if (isset($filter_resume['filter_severity'])) { + array_push ($tags_set, array( + 'title' => __('Severity'), + 'value' => $filter_resume['filter_severity'] + )); + } + // Pagination + if ($filter_resume['pagination'] == "") { + $filter_resume['pagination'] = $config["block_size"]; + } + array_push ($tags_set, array( + 'title' => __('Pagination'), + 'value' => $filter_resume['pagination'] + )); + // Free search + if (isset($filter_resume['free_search_string']) && $filter_resume['free_search_string'] != "") { + array_push ($tags_set, array( + 'title' => __('Search'), + 'value' => $filter_resume['free_search_string'] + )); + } + // Status + if (isset($filter_resume['filter_status']) && $filter_resume['filter_status'] != "") { + array_push ($tags_set, array( + 'title' => __('Status'), + 'value' => $filter_resume['filter_status'] + )); + } + // Group by + if (isset($filter_resume['group_by'])) { + if ($filter_resume['group_by'] == 0) { + array_push ($tags_set, array( + 'title' => __('Group by Enterprise String / IP'), + 'value' => __('No') + )); + } + else { + array_push ($tags_set, array( + 'title' => __('Group by Enterprise String / IP'), + 'value' => __('Yes') + )); + } + } + // Date from + if (isset($filter_resume['date_from_trap']) && $filter_resume['date_from_trap'] != "") { + if (isset($filter_resume['time_from_trap']) && $filter_resume['time_from_trap'] != "") { + array_push ($tags_set, array( + 'title' => __('From'), + 'value' => $filter_resume['date_from_trap'] . " " . $filter_resume['time_from_trap'] + )); + } + else { + array_push ($tags_set, array( + 'title' => __('From'), + 'value' => $filter_resume['date_from_trap'] + )); + } + } + // Date to + if (isset($filter_resume['date_to_trap']) && $filter_resume['date_to_trap'] != "") { + if (isset($filter_resume['time_to_trap']) && $filter_resume['time_to_trap'] != "") { + array_push ($tags_set, array( + 'title' => __('To'), + 'value' => $filter_resume['date_to_trap'] . " " . $filter_resume['time_to_trap'] + )); + } + else { + array_push ($tags_set, array( + 'title' => __('To'), + 'value' => $filter_resume['date_to_trap'] + )); + } + } + // Trap type + if (isset($filter_resume['trap_type'])) { + array_push ($tags_set, array( + 'title' => __('Trap type'), + 'value' => $filter_resume['trap_type'] + )); + } + $title = ''; + if(!$config['pure']){ + $title = isset($filter_resume['title']) + ? __('Active filter') . " (" . $filter_resume['title'] . ")" + : __('Active filters'); + } + if (sizeof($filter_resume) > 0) ui_print_tags_view($title, $tags_set); +} ?> diff --git a/pandora_console/operation/snmpconsole/snmp_view.php b/pandora_console/operation/snmpconsole/snmp_view.php index 61506e85a3..79aca85153 100755 --- a/pandora_console/operation/snmpconsole/snmp_view.php +++ b/pandora_console/operation/snmpconsole/snmp_view.php @@ -518,15 +518,22 @@ $filter .= html_print_submit_button(__('Update'), 'search', false, 'class="sub u $filter .= ''; $filter .= ''; - - - +$filter_resume = array(); +$filter_resume['filter_fired'] = $alerted[$filter_fired]; +$filter_resume['filter_severity'] = $severities[$filter_severity]; +$filter_resume['pagination'] = $paginations[$pagination]; +$filter_resume['free_search_string'] = $free_search_string; +$filter_resume['filter_status'] = $status_array[$filter_status]; +$filter_resume['group_by'] = $group_by; +$filter_resume['date_from_trap'] = $date_from_trap; +$filter_resume['time_from_trap'] = $time_from_trap; +$filter_resume['date_to_trap'] = $date_to_trap; +$filter_resume['time_to_trap'] = $time_to_trap; +$filter_resume['trap_type'] = $trap_types[$trap_type]; $traps = db_get_all_rows_sql($sql); $trapcount = (int) db_get_value_sql($sql_count); - - // No traps if (empty ($traps)) { // Header @@ -546,6 +553,9 @@ if (empty ($traps)) { if(!empty ($traps2)){ ui_toggle($filter, __('Toggle filter(s)')); + + print_snmp_tags_active_filters($filter_resume); + ui_print_info_message ( array('no_close'=>true, 'message'=> __('There are no SNMP traps in database that contains this filter') ) ); } else { ui_print_info_message ( array('no_close'=>true, 'message'=> __('There are no SNMP traps in database') ) ); @@ -651,6 +661,8 @@ if (empty ($traps)) { ui_toggle($filter, __('Toggle filter(s)')); unset ($table); +print_snmp_tags_active_filters($filter_resume); + if (($config['dbtype'] == 'oracle') && ($traps !== false)) { for ($i = 0; $i < count($traps); $i++) { unset($traps[$i]['rnum']);