diff --git a/pandora_console/include/functions_snmp.php b/pandora_console/include/functions_snmp.php index 40dfc2764a..eff4991765 100644 --- a/pandora_console/include/functions_snmp.php +++ b/pandora_console/include/functions_snmp.php @@ -394,24 +394,14 @@ function print_snmp_tags_active_filters($filter_resume=[]) } // 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, - [ - 'title' => __('From'), - 'value' => $filter_resume['date_from_trap'].' '.$filter_resume['time_from_trap'], - ] - ); - } else { - array_push( - $tags_set, - [ - 'title' => __('From'), - 'value' => $filter_resume['date_from_trap'], - ] - ); - } + if (isset($filter_resume['hours_ago']) === true) { + array_push( + $tags_set, + [ + 'title' => __('Max. hours old'), + 'value' => $filter_resume['hours_ago'].' '.__('hours'), + ] + ); } // Date to diff --git a/pandora_console/operation/snmpconsole/snmp_view.php b/pandora_console/operation/snmpconsole/snmp_view.php index dfa7296c1d..e1a501ea1a 100755 --- a/pandora_console/operation/snmpconsole/snmp_view.php +++ b/pandora_console/operation/snmpconsole/snmp_view.php @@ -32,6 +32,8 @@ enterprise_include('include/functions_snmp.php'); require_once 'include/functions_agents.php'; require_once 'include/functions_snmp.php'; +ui_require_css_file('snmp_view'); + check_login(); $agent_a = check_acl($config['id_user'], 0, 'AR'); $agent_w = check_acl($config['id_user'], 0, 'AW'); @@ -46,25 +48,29 @@ if (!$agent_a && !$agent_w) { } // Read parameters. -$now = new DateTime(); -$ago = new DateTime(); -$interval = new DateInterval('PT8H'); -$ago->sub($interval); - $filter_severity = (int) get_parameter('filter_severity', -1); $filter_fired = (int) get_parameter('filter_fired', -1); $filter_status = (int) get_parameter('filter_status', 0); $free_search_string = (string) get_parameter('free_search_string', ''); $pagination = (int) get_parameter('pagination', $config['block_size']); $offset = (int) get_parameter('offset', 0); +$pure = (int) get_parameter('pure', 0); $trap_type = (int) get_parameter('trap_type', -1); $group_by = (int) get_parameter('group_by', 0); $refr = (int) get_parameter('refresh'); $default_refr = !empty($refr) ? $refr : $config['vc_refr']; -$date_from_trap = get_parameter('date_from_trap', $ago->format('Y/m/d')); -$date_to_trap = get_parameter('date_to_trap', $now->format('Y/m/d')); -$time_from_trap = get_parameter('time_from_trap', $ago->format('H:i:s')); -$time_to_trap = get_parameter('time_to_trap', $now->format('H:i:s')); +$hours_ago = get_parameter('hours_ago', 8); + +// Build ranges. +$now = new DateTime(); +$ago = new DateTime(); +$interval = new DateInterval(sprintf('PT%dH', $hours_ago)); +$ago->sub($interval); + +$date_from_trap = $ago->format('Y/m/d'); +$date_to_trap = $now->format('Y/m/d'); +$time_from_trap = $ago->format('H:i:s'); +$time_to_trap = $now->format('H:i:s'); $user_groups = users_get_groups($config['id_user'], $access, false); @@ -80,7 +86,11 @@ foreach ($user_groups as $id => $name) { $i++; } -$url = 'index.php?sec=estado&sec2=operation/snmpconsole/snmp_view&filter_severity='.$filter_severity.'&filter_fired='.$filter_fired.'&free_search_string='.$free_search_string.'&pagination='.$pagination.'&offset='.$offset.'&trap_type='.$trap_type.'&group_by='.$group_by.'&date_from_trap='.$date_from_trap.'&date_to_trap='.$date_to_trap.'&time_from_trap='.$time_from_trap.'&time_to_trap='.$time_to_trap; +$url = 'index.php?sec=estado&sec2=operation/snmpconsole/snmp_view'; +$url .= '&filter_severity='.$filter_severity.'&filter_fired='.$filter_fired; +$url .= '&free_search_string='.$free_search_string.'&pagination='.$pagination; +$url .= '&offset='.$offset.'&trap_type='.$trap_type.'&group_by='.$group_by; +$url .= '&hours_ago='.$hours_ago.'&pure='.$pure; $statistics['text'] = ''.html_print_image('images/op_reporting.png', true, ['title' => __('Statistics')]).''; $list['text'] = ''.html_print_image('images/op_snmp.png', true, ['title' => __('List')]).''; @@ -594,15 +604,16 @@ $table->data[2][4] = html_print_input_text( true ); -$table->data[4][0] = ''.__('From (Date)').''; -$table->data[4][1] = html_print_input_text('date_from_trap', $date_from_trap, '', 15, 10, true); -$table->data[4][2] = ''.__('To (Date)').''; -$table->data[4][3] = html_print_input_text('date_to_trap', $date_to_trap, '', 15, 10, true); - -$table->data[5][0] = ''.__('From (Time)').''; -$table->data[5][1] = html_print_input_text('time_from_trap', $time_from_trap, false, 15, 10, true); -$table->data[5][2] = ''.__('To (Time)').''; -$table->data[5][3] = html_print_input_text('time_to_trap', $time_to_trap, false, 15, 10, true); +$table->data[4][0] = ''.__('Max. hours old').''; +$table->data[4][1] = html_print_input( + [ + 'type' => 'number', + 'name' => 'hours_ago', + 'value' => $hours_ago, + 'step' => 1, + 'return' => true, + ] +); // Type filter (ColdStart, WarmStart, LinkDown, LinkUp, authenticationFailure, Other). $table->data[6][1] = ''.__('Trap type').''.ui_print_help_tip(__('Search by trap type'), true); @@ -634,7 +645,7 @@ if ($config['dbtype'] != 'oracle') { $table->data[3][4] .= __('No').' '.html_print_radio_button('group_by', 0, '', $group_by, true); } -$filter = '