diff --git a/pandora_console/include/class/SnmpConsole.class.php b/pandora_console/include/class/SnmpConsole.class.php
new file mode 100644
index 0000000000..50ada73852
--- /dev/null
+++ b/pandora_console/include/class/SnmpConsole.class.php
@@ -0,0 +1,1073 @@
+ajaxController = $ajaxController;
+ }
+
+
+ /**
+ * Run view
+ *
+ * @return void
+ */
+ public function run()
+ {
+ global $config;
+ // Javascript.
+ ui_require_jquery_file('pandora');
+ // CSS.
+ ui_require_css_file('wizard');
+ ui_require_css_file('discovery');
+
+ $statistics['text'] = ''.html_print_image(
+ 'images/op_reporting.png',
+ true,
+ [
+ 'title' => __('Statistics'),
+ 'class' => 'invert_filter',
+ ]
+ ).'';
+ $list['text'] = ''.html_print_image(
+ 'images/op_snmp.png',
+ true,
+ [
+ 'title' => __('List'),
+ 'class' => 'invert_filter',
+ ]
+ ).'';
+ $list['active'] = true;
+
+ // Header
+ ui_print_standard_header(
+ __('SNMP Console'),
+ 'images/op_snmp.png',
+ false,
+ 'snmp_console',
+ false,
+ [
+ $list,
+ $statistics,
+ ],
+ [
+ [
+ 'link' => '',
+ 'label' => __('Monitoring'),
+ ],
+ [
+ 'link' => '',
+ 'label' => __('SNMP'),
+ ],
+ ]
+ );
+
+ // Datatables list.
+ try {
+ $checkbox_all = html_print_checkbox(
+ 'all_validate_box',
+ 1,
+ false,
+ true
+ );
+
+ $columns = [
+ 'status',
+ [
+ 'text' => 'snmp_agent',
+ 'class' => 'snmp-td',
+ ],
+ [
+ 'text' => 'enterprise_string',
+ 'class' => 'snmp-td',
+ ],
+ [
+ 'text' => 'count',
+ 'class' => 'snmp-td',
+ ],
+ [
+ 'text' => 'trap_subtype',
+ 'class' => 'snmp-td',
+ ],
+ [
+ 'text' => 'user_id',
+ 'class' => 'snmp-td',
+ ],
+ [
+ 'text' => 'timestamp',
+ 'class' => 'snmp-td',
+ ],
+ 'alert',
+ 'action',
+ [
+ 'text' => 'm',
+ 'class' => 'mw60px pdd_0px',
+ ],
+ ];
+
+ $column_names = [
+ __('Status'),
+ __('SNMP Agent'),
+ __('Enterprise String'),
+ __('Count'),
+ __('Trap subtype'),
+ __('User ID'),
+ __('Timestamp'),
+ __('Alert'),
+ __('Actions'),
+ [
+ 'text' => 'm',
+ 'extra' => $checkbox_all,
+ 'class' => 'w20px no-text-imp',
+ ],
+ ];
+
+ $show_alerts = [
+ -1 => __('All'),
+ 0 => __('Not triggered'),
+ 1 => __('Triggered'),
+ ];
+
+ $severities = get_priorities();
+ $severities[-1] = __('All');
+
+ $paginations = [
+ $config['block_size'] => __('Default'),
+ 25 => '25',
+ 50 => '50',
+ 100 => '100',
+ 200 => '200',
+ 500 => '500',
+ ];
+
+ $status_array = [
+ -1 => __('All'),
+ 0 => __('Not validated'),
+ 1 => __('Validated'),
+ ];
+
+ $trap_types = [
+ -1 => __('None'),
+ 0 => __('Cold start (0)'),
+ 1 => __('Warm start (1)'),
+ 2 => __('Link down (2)'),
+ 3 => __('Link up (3)'),
+ 4 => __('Authentication failure (4)'),
+ 5 => __('Other'),
+ ];
+
+ $this->tableId = 'snmp_console';
+
+ // Load datatables user interface.
+ ui_print_datatable(
+ [
+ 'id' => $this->tableId,
+ 'class' => 'info_table',
+ 'style' => 'width: 100%',
+ 'columns' => $columns,
+ 'column_names' => $column_names,
+ 'ajax_url' => $this->ajaxController,
+ 'ajax_data' => ['method' => 'draw'],
+ 'ajax_postprocces' => 'process_datatables_item(item)',
+ 'search_button_class' => 'sub filter float-right',
+ 'no_sortable_columns' => [
+ 0,
+ 7,
+ 8,
+ 9,
+ ],
+ 'form' => [
+ 'class' => 'flex-row',
+ 'inputs' => [
+ [
+ 'label' => __('Alert'),
+ 'type' => 'select',
+ 'id' => 'filter_alert',
+ 'name' => 'filter_alert',
+ 'class' => 'w200px',
+ 'fields' => $show_alerts,
+ 'return' => true,
+ 'selected' => -1,
+ ],
+ [
+ 'label' => __('Severity'),
+ 'type' => 'select',
+ 'id' => 'filter_severity',
+ 'name' => 'filter_severity',
+ 'class' => 'w200px',
+ 'fields' => $severities,
+ 'return' => true,
+ 'selected' => -1,
+ ],
+ [
+ 'label' => __('Free search'),
+ 'type' => 'text',
+ 'class' => 'w400px',
+ 'id' => 'filter_free_search',
+ 'name' => 'filter_free_search',
+ ],
+ [
+ 'label' => __('Status'),
+ 'type' => 'select',
+ 'id' => 'filter_status',
+ 'name' => 'filter_status',
+ 'class' => 'w200px',
+ 'fields' => $status_array,
+ 'return' => true,
+ 'selected' => -1,
+ ],
+ [
+ 'label' => __('Group by Enterprise String/IP'),
+ 'type' => 'select',
+ 'name' => 'filter_group_by',
+ 'selected' => 0,
+ 'disabled' => false,
+ 'return' => true,
+ 'id' => 'filter_group_by',
+ 'fields' => [
+ 0 => __('No'),
+ 1 => __('Yes'),
+ ],
+ ],
+ [
+ 'label' => __('Max. hours old'),
+ 'type' => 'text',
+ 'class' => 'w200px',
+ 'id' => 'filter_hours_ago',
+ 'name' => 'filter_hours_ago',
+ 'value' => '8',
+ ],
+ [
+ 'label' => __('Trap type'),
+ 'type' => 'select',
+ 'id' => 'filter_trap_type',
+ 'name' => 'filter_trap_type',
+ 'class' => 'w200px',
+ 'fields' => $trap_types,
+ 'return' => true,
+ 'selected' => -1,
+ ],
+ ],
+ ],
+ ]
+ );
+ } catch (Exception $e) {
+ echo $e->getMessage();
+ }
+
+ echo '
';
+ html_print_submit_button(__('Validate'), 'updatebt', false, 'class="sub ok"');
+ echo ' ';
+ html_print_submit_button(__('Delete'), 'deletebt', false, 'class="sub delete" onClick="javascript:return confirm(\''.__('Are you sure?').'\')"');
+ echo '
';
+
+ echo '';
+ echo '
'.__('Status').'
';
+ echo html_print_image(
+ 'images/pixel_green.png',
+ true,
+ [
+ 'width' => '20',
+ 'height' => '20',
+ ]
+ ).' - '.__('Validated');
+ echo '
';
+ echo html_print_image(
+ 'images/pixel_red.png',
+ true,
+ [
+ 'width' => '20',
+ 'height' => '20',
+ ]
+ ).' - '.__('Not validated');
+ echo '';
+ echo '';
+ echo '
'.__('Alert').'
';
+ echo html_print_image(
+ 'images/pixel_yellow.png',
+ true,
+ [
+ 'width' => '20',
+ 'height' => '20',
+ ]
+ ).' - '.__('Fired');
+ echo '
';
+ echo html_print_image(
+ 'images/pixel_gray.png',
+ true,
+ [
+ 'width' => '20',
+ 'height' => '20',
+ ]
+ ).' - '.__('Not fired');
+ echo '';
+ echo '';
+ echo '
'.__('Action').'
';
+ echo html_print_image('images/ok.png', true).' - '.__('Validate');
+ echo '
';
+ echo html_print_image('images/cross.png', true, ['class' => 'invert_filter']).' - '.__('Delete');
+ echo '';
+ echo '';
+ echo '
'.__('Severity').'
';
+ foreach (get_priorities() as $num => $name) {
+ echo ''.$name.'';
+ echo '
';
+ }
+
+ echo '';
+
+ // Load own javascript file.
+ echo $this->loadJS();
+ }
+
+
+ /**
+ * Get the data for draw the table.
+ *
+ * @return void.
+ */
+ public function draw()
+ {
+ global $config;
+
+ // Init data.
+ $data = [];
+ // Count of total records.
+ $count = 0;
+ // Catch post parameters.
+ $start = get_parameter('start', 0);
+ $length = get_parameter('length', $config['block_size']);
+
+ $order = get_datatable_order(true);
+ $filters = get_parameter('filter', []);
+
+ // Build ranges.
+ $now = new DateTime();
+ $ago = new DateTime();
+ $interval = new DateInterval(sprintf('PT%dH', $filters['filter_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');
+
+ try {
+ ob_start();
+ $data = [];
+
+ $user_groups = users_get_groups($config['id_user'], 'AR', false);
+ $prea = array_keys($user_groups);
+ $ids = join(',', $prea);
+
+ $user_in_group_wo_agents = db_get_value_sql('select count(DISTINCT(id_usuario)) from tusuario_perfil where id_usuario ="'.$config['id_user'].'" and id_perfil = 1 and id_grupo in (select id_grupo from tgrupo where id_grupo in ('.$ids.') and id_grupo not in (select id_grupo from tagente))');
+ if ($user_in_group_wo_agents == 0) {
+ $rows = db_get_all_rows_filter(
+ 'tagente',
+ ['id_grupo' => array_keys($user_groups)],
+ ['id_agente']
+ );
+ $id_agents = [];
+ foreach ($rows as $row) {
+ $id_agents[] = $row['id_agente'];
+ }
+
+ if (!empty($id_agents)) {
+ $address_by_user_groups = agents_get_addresses($id_agents);
+ foreach ($address_by_user_groups as $i => $a) {
+ $address_by_user_groups[$i] = '"'.$a.'"';
+ }
+ }
+ } else {
+ $rows = db_get_all_rows_filter(
+ 'tagente',
+ [],
+ ['id_agente']
+ );
+ $id_agents = [];
+ foreach ($rows as $row) {
+ $id_agents[] = $row['id_agente'];
+ }
+
+ $all_address_agents = agents_get_addresses($id_agents);
+ foreach ($all_address_agents as $i => $a) {
+ $all_address_agents[$i] = '"'.$a.'"';
+ }
+ }
+
+ if (empty($address_by_user_groups)) {
+ $address_by_user_groups = [];
+ array_unshift($address_by_user_groups, '""');
+ }
+
+ if (empty($all_address_agents)) {
+ $all_address_agents = [];
+ array_unshift($all_address_agents, '""');
+ }
+
+ $sql = 'SELECT * FROM ttrap
+ WHERE (
+ `source` IN ('.implode(',', $address_by_user_groups).") OR
+ `source`='' OR
+ `source` NOT IN (".implode(',', $all_address_agents).')
+ )
+ %s
+ ORDER BY timestamp DESC
+ LIMIT %d,%d';
+
+ $whereSubquery = '';
+ if ($filters['filter_alert'] != -1) {
+ $whereSubquery .= ' AND alerted = '.$filters['filter_alert'];
+ }
+
+ if ($filters['filter_severity'] != -1) {
+ // There are two special severity values aimed to match two different trap standard severities
+ // in database: warning/critical and critical/normal.
+ if ($filters['filter_severity'] != EVENT_CRIT_OR_NORMAL
+ && $filters['filter_severity'] != EVENT_CRIT_WARNING_OR_CRITICAL
+ ) {
+ // Test if enterprise is installed to search oid in text or oid field in ttrap.
+ if ($config['enterprise_installed']) {
+ $whereSubquery .= ' AND (
+ (alerted = 0 AND severity = '.$filters['filter_severity'].') OR
+ (alerted = 1 AND priority = '.$filters['filter_severity'].'))';
+ } else {
+ $whereSubquery .= ' AND (
+ (alerted = 0 AND 1 = '.$filters['filter_severity'].') OR
+ (alerted = 1 AND priority = '.$filters['filter_severity'].'))';
+ }
+ } else if ($filters['filter_severity'] === EVENT_CRIT_WARNING_OR_CRITICAL) {
+ // Test if enterprise is installed to search oid in text or oid field in ttrap.
+ if ($config['enterprise_installed']) {
+ $whereSubquery .= ' AND (
+ (alerted = 0 AND (severity = '.EVENT_CRIT_WARNING.' OR severity = '.EVENT_CRIT_CRITICAL.')) OR
+ (alerted = 1 AND (priority = '.EVENT_CRIT_WARNING.' OR priority = '.EVENT_CRIT_CRITICAL.')))';
+ } else {
+ $whereSubquery .= ' AND (
+ (alerted = 1 AND (priority = '.EVENT_CRIT_WARNING.' OR priority = '.EVENT_CRIT_CRITICAL.')))';
+ }
+ } else if ($filters['filter_severity'] === EVENT_CRIT_OR_NORMAL) {
+ // Test if enterprise is installed to search oid in text or oid field in ttrap.
+ if ($config['enterprise_installed']) {
+ $whereSubquery .= ' AND (
+ (alerted = 0 AND (severity = '.EVENT_CRIT_NORMAL.' OR severity = '.EVENT_CRIT_CRITICAL.')) OR
+ (alerted = 1 AND (priority = '.EVENT_CRIT_NORMAL.' OR priority = '.EVENT_CRIT_CRITICAL.')))';
+ } else {
+ $whereSubquery .= ' AND (
+ (alerted = 1 AND (priority = '.EVENT_CRIT_NORMAL.' OR priority = '.EVENT_CRIT_CRITICAL.')))';
+ }
+ }
+ }
+
+ if ($filters['filter_status'] != -1) {
+ $whereSubquery .= ' AND status = '.$filters['filter_status'];
+ }
+
+ if ($date_from_trap != '') {
+ if ($time_from_trap != '') {
+ $whereSubquery .= '
+ AND (UNIX_TIMESTAMP(timestamp) > UNIX_TIMESTAMP("'.$date_from_trap.' '.$time_from_trap.'"))
+ ';
+ } else {
+ $whereSubquery .= '
+ AND (UNIX_TIMESTAMP(timestamp) > UNIX_TIMESTAMP("'.$date_from_trap.' 23:59:59"))
+ ';
+ }
+ }
+
+ if ($date_to_trap != '') {
+ if ($time_to_trap) {
+ $whereSubquery .= '
+ AND (UNIX_TIMESTAMP(timestamp) < UNIX_TIMESTAMP("'.$date_to_trap.' '.$time_to_trap.'"))
+ ';
+ } else {
+ $whereSubquery .= '
+ AND (UNIX_TIMESTAMP(timestamp) < UNIX_TIMESTAMP("'.$date_to_trap.' 23:59:59"))
+ ';
+ }
+ }
+
+ if ($filters['filter_trap_type'] == 5) {
+ $whereSubquery .= ' AND type NOT IN (0, 1, 2, 3, 4)';
+ } else if ($filters['filter_trap_type'] != -1) {
+ $whereSubquery .= ' AND type = '.$filters['filter_trap_type'];
+ }
+
+ if ($filters['filter_group_by']) {
+ $where_without_group = $whereSubquery;
+ $whereSubquery .= ' GROUP BY source,oid';
+ }
+
+ $sql = sprintf($sql, $whereSubquery, $start, $length);
+ $sql_count = 'SELECT COUNT(id_trap) FROM ttrap
+ WHERE (
+ source IN ('.implode(',', $address_by_user_groups).") OR
+ source='' OR
+ source NOT IN (".implode(',', $all_address_agents).')
+ )
+ %s';
+
+ $sql_count = sprintf($sql_count, $whereSubquery);
+
+ $traps = db_get_all_rows_sql($sql, true);
+ $total = (int) db_get_value_sql($sql_count, false, true);
+
+ if (empty($traps) === false) {
+ $data = $traps;
+ $data = array_reduce(
+ $data,
+ function ($carry, $item) use ($filters, $where_without_group) {
+ global $config;
+ // Transforms array of arrays $data into an array
+ // of objects, making a post-process of certain fields.
+ $tmp = (object) $item;
+
+ $severity_class = get_priority_class($tmp->severity);
+
+ $status = $tmp->status;
+
+ // Status.
+ if ($status == 0) {
+ $tmp->status = html_print_image(
+ 'images/pixel_red.png',
+ true,
+ [
+ 'title' => __('Not validated'),
+ 'width' => '20',
+ 'height' => '20',
+ ]
+ );
+ } else {
+ $tmp->status = html_print_image(
+ 'images/pixel_green.png',
+ true,
+ [
+ 'title' => __('Validated'),
+ 'width' => '20',
+ 'height' => '20',
+ ]
+ );
+ }
+
+ // SNMP Agent.
+ $agent = agents_get_agent_with_ip($tmp->source);
+ if ($agent === false) {
+ $tmp->snmp_agent .= ''.$tmp->source.'';
+ } else {
+ $tmp->snmp_agent .= '';
+ }
+
+ // Enterprise string.
+ if (empty($tmp->text) === false) {
+ $enterprise_string = $tmp->text;
+ } else if (empty($tmp->oid) === false) {
+ $enterprise_string = $tmp->oid;
+ } else {
+ $enterprise_string = __('N/A');
+ }
+
+ $tmp->enterprise_string = '';
+
+ // Count.
+ if ($filters['filter_group_by']) {
+ $sql = "SELECT count(*) FROM ttrap WHERE 1=1
+ $where_without_group
+ AND oid='".$tmp->oid."'
+ AND source='".$tmp->source."'";
+ $group_traps = db_get_value_sql($sql);
+ $tmp->count = ''.$group_traps.'
';
+ }
+
+ // Trap subtype.
+ $tmp->trap_subtype = '';
+ if (empty($tmp->value) === true) {
+ $tmp->trap_subtype .= __('N/A');
+ } else {
+ $tmp->trap_subtype .= ui_print_truncate_text($tmp->value, GENERIC_SIZE_TEXT, false);
+ }
+
+ $tmp->trap_subtype .= '
';
+
+ // User ID.
+ $tmp->user_id = '';
+ if (empty($status) === false) {
+ $tmp->user_id .= '
'.substr($tmp->id_usuario, 0, 8).'';
+ if (!empty($tmp->id_usuario)) {
+ $tmp->user_id .= ui_print_help_tip(get_user_fullname($tmp->id_usuario), true);
+ }
+ } else {
+ $tmp->user_id .= '--';
+ }
+
+ $tmp->user_id .= '
';
+
+ // Timestamp.
+ $timestamp = $tmp->timestamp;
+ $tmp->timestamp = '';
+ $tmp->timestamp .= '';
+ $tmp->timestamp .= ui_print_timestamp($timestamp, true);
+ $tmp->timestamp .= '
';
+
+ // Use alert severity if fired.
+ if (empty($tmp->alerted) === false) {
+ $tmp->alert = html_print_image('images/pixel_yellow.png', true, ['width' => '20', 'height' => '20', 'border' => '0', 'title' => __('Alert fired')]);
+ } else {
+ $tmp->alert = html_print_image('images/pixel_gray.png', true, ['width' => '20', 'height' => '20', 'border' => '0', 'title' => __('Alert not fired')]);
+ }
+
+ // Actions.
+ $tmp->action = '';
+ if ($status != 1) {
+ $tmp->action .= ''.html_print_image(
+ 'images/ok.png',
+ true,
+ [
+ 'border' => '0',
+ 'title' => __('Validate'),
+ 'onclick' => 'validate_trap(\''.$tmp->id_trap.'\')',
+ ]
+ ).' ';
+ }
+
+ if ($tmp->source == '') {
+ if (\user_is_admin()) {
+ $tmp->action .= ''.html_print_image(
+ 'images/cross.png',
+ true,
+ [
+ 'border' => '0',
+ 'title' => __('Delete'),
+ 'class' => 'invert_filter',
+ 'onclick' => 'delete_trap(\''.$tmp->id_trap.'\')',
+ ]
+ ).' ';
+ }
+ } else {
+ $tmp->action .= ''.html_print_image(
+ 'images/cross.png',
+ true,
+ [
+ 'border' => '0',
+ 'title' => __('Delete'),
+ 'class' => 'invert_filter',
+ 'onclick' => 'delete_trap(\''.$tmp->id_trap.'\')',
+ ]
+ ).' ';
+ }
+
+ $tmp->action .= ''.html_print_image(
+ 'images/eye.png',
+ true,
+ [
+ 'alt' => __('Show more'),
+ 'title' => __('Show more'),
+ 'class' => 'invert_filter',
+ ]
+ ).'';
+ $tmp->action .= ''.html_print_image('images/edit.png', true, ['alt' => __('SNMP trap editor'), 'title' => __('SNMP trap editor')]).'';
+
+ $tmp->m = html_print_checkbox_extended('snmptrapid[]', $tmp->id_trap, false, false, '', 'class="chk"', true);
+
+ $carry[] = $tmp;
+ return $carry;
+ },
+ );
+ }
+
+ if (empty($data) === true) {
+ $total = 0;
+ $data = [];
+ }
+
+ echo json_encode(
+ [
+ 'data' => $data,
+ 'recordsTotal' => $total,
+ 'recordsFiltered' => $total,
+ ]
+ );
+ // Capture output.
+ $response = ob_get_clean();
+ } catch (Exception $e) {
+ echo json_encode(['error' => $e->getMessage()]);
+ exit;
+ }
+
+ // If not valid, show error with issue.
+ json_decode($response);
+ if (json_last_error() === JSON_ERROR_NONE) {
+ // If valid dump.
+ echo $response;
+ } else {
+ echo json_encode(
+ ['error' => $response]
+ );
+ }
+
+ exit;
+ }
+
+
+ /**
+ * Checks if target method is available to be called using AJAX.
+ *
+ * @param string $method Target method.
+ *
+ * @return boolean True allowed, false not.
+ */
+ public function ajaxMethod(string $method)
+ {
+ return in_array($method, $this->AJAXMethods);
+ }
+
+
+ /**
+ * Delete snmp trap.
+ *
+ * @return void
+ */
+ public function deleteTrap()
+ {
+ $id_trap = get_parameter('id', 0);
+ $group_by = (bool) get_parameter('group_by', 0);
+
+ if ($id_trap > 0) {
+ if ($group_by === true) {
+ $sql_ids_traps = 'SELECT id_trap, source FROM ttrap WHERE oid IN (SELECT oid FROM ttrap WHERE id_trap = '.$id_trap.')
+ AND source IN (SELECT source FROM ttrap WHERE id_trap = '.$id_trap.')';
+ $ids_traps = db_get_all_rows_sql($sql_ids_traps);
+
+ foreach ($ids_traps as $key => $value) {
+ $result = db_process_sql_delete('ttrap', ['id_trap' => $value['id_trap']]);
+ enterprise_hook('snmp_update_forwarded_modules', [$value]);
+ }
+ } else {
+ $forward_info = db_get_row('ttrap', 'id_trap', $id_trap);
+ $result = db_process_sql_delete('ttrap', ['id_trap' => $id_trap]);
+ enterprise_hook('snmp_update_forwarded_modules', [$forward_info]);
+ }
+ }
+ }
+
+
+ /**
+ * Delete snmp traps.
+ *
+ * @return void
+ */
+ public function deleteTraps()
+ {
+ $ids = get_parameter('ids', []);
+ $group_by = (bool) get_parameter('group_by', false);
+
+ if (empty($ids) === false) {
+ $string_ids = implode(',', $ids);
+ if ($group_by === true) {
+ $sql_ids_traps = 'SELECT id_trap, source FROM ttrap WHERE oid IN (SELECT oid FROM ttrap WHERE id_trap IN ('.$string_ids.'))
+ AND source IN (SELECT source FROM ttrap WHERE id_trap IN ('.$string_ids.'))';
+ $ids_traps = db_get_all_rows_sql($sql_ids_traps);
+
+ $array = array_column($ids_traps, 'id_trap');
+
+ $delete = sprintf(
+ 'DELETE FROM `ttrap` WHERE id_trap IN (%s)',
+ implode(',', $array),
+ );
+ db_process_sql($delete);
+
+ foreach ($ids_traps as $key => $value) {
+ enterprise_hook('snmp_update_forwarded_modules', [$value]);
+ }
+ } else {
+ $delete = sprintf(
+ 'DELETE FROM `ttrap` WHERE id_trap IN (%s)',
+ $string_ids,
+ );
+ db_process_sql($delete);
+ foreach ($ids as $id_trap) {
+ enterprise_hook('snmp_update_forwarded_modules', [$id_trap]);
+ }
+ }
+ }
+ }
+
+
+ /**
+ * Validate snmp trap.
+ *
+ * @return void
+ */
+ public function validateTrap()
+ {
+ global $config;
+
+ $id_trap = get_parameter('id', 0);
+
+ $values = [
+ 'status' => 1,
+ 'id_usuario' => $config['id_user'],
+ ];
+
+ $result = db_process_sql_update('ttrap', $values, ['id_trap' => $id_trap]);
+ enterprise_hook('snmp_update_forwarded_modules', [$id_trap]);
+ }
+
+
+ /**
+ * Validate snmp traps.
+ *
+ * @return void
+ */
+ public function validateTraps()
+ {
+ global $config;
+
+ $ids = get_parameter('ids', []);
+
+ if (empty($ids) === false) {
+ $update = sprintf(
+ 'UPDATE ttrap SET `status` = 1, `id_usuario` = "%s" WHERE id_trap IN (%s)',
+ $config['id_user'],
+ implode(',', $ids)
+ );
+ db_process_sql($update);
+
+ foreach ($ids as $id_trap) {
+ enterprise_hook('snmp_update_forwarded_modules', [$id_trap]);
+ }
+ }
+ }
+
+
+ /**
+ * Load Javascript code.
+ *
+ * @return string.
+ */
+ public function loadJS()
+ {
+ // Nothing for this moment.
+ ob_start();
+
+ // Javascript content.
+ ?>
+
+ 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);
-
-$str_user_groups = '';
-$i = 0;
-foreach ($user_groups as $id => $name) {
- if ($i == 0) {
- $str_user_groups .= $id;
+// Control call flow.
+try {
+ // User access and validation is being processed on class constructor.
+ $controller = new SnmpConsole($ajaxPage);
+} catch (Exception $e) {
+ if ((bool) is_ajax() === true) {
+ echo json_encode(['error' => '[SnmpConsole]'.$e->getMessage() ]);
+ exit;
} else {
- $str_user_groups .= ','.$id;
- }
-
- $i++;
-}
-
-$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'),
- 'class' => 'invert_filter',
- ]
-).'';
-$list['text'] = ''.html_print_image(
- 'images/op_snmp.png',
- true,
- [
- 'title' => __('List'),
- 'class' => 'invert_filter',
- ]
-).'';
-$list['active'] = true;
-
-if ($config['pure']) {
- $fullscreen['text'] = ''.html_print_image(
- 'images/normal_screen.png',
- true,
- [
- 'title' => __('Normal screen'),
- 'class' => 'invert_filter',
- ]
- ).'';
-} else {
- // Fullscreen.
- $fullscreen['text'] = ''.html_print_image(
- 'images/full_screen.png',
- true,
- [
- 'title' => __('Full screen'),
- 'class' => 'invert_filter',
- ]
- ).'';
-}
-
-
-// OPERATIONS
-// Delete SNMP Trap entry Event.
-if (isset($_GET['delete'])) {
- $id_trap = (int) get_parameter_get('delete', 0);
- if ($id_trap > 0) {
- if ($group_by) {
- $sql_ids_traps = 'SELECT id_trap, source FROM ttrap WHERE oid IN (SELECT oid FROM ttrap WHERE id_trap = '.$id_trap.')
- AND source IN (SELECT source FROM ttrap WHERE id_trap = '.$id_trap.')';
- $ids_traps = db_get_all_rows_sql($sql_ids_traps);
-
- foreach ($ids_traps as $key => $value) {
- $result = db_process_sql_delete('ttrap', ['id_trap' => $value['id_trap']]);
- enterprise_hook('snmp_update_forwarded_modules', [$value]);
- }
- } else {
- $forward_info = db_get_row('ttrap', 'id_trap', $id_trap);
- $result = db_process_sql_delete('ttrap', ['id_trap' => $id_trap]);
- enterprise_hook('snmp_update_forwarded_modules', [$forward_info]);
- ui_print_result_message(
- $result,
- __('Successfully deleted'),
- __('Could not be deleted')
- );
- }
- }
-}
-
-// Check Event.
-if (isset($_GET['check'])) {
- $id_trap = (int) get_parameter_get('check', 0);
- $values = [
- 'status' => 1,
- 'id_usuario' => $config['id_user'],
- ];
- $result = db_process_sql_update('ttrap', $values, ['id_trap' => $id_trap]);
- enterprise_hook('snmp_update_forwarded_modules', [$id_trap]);
-
- ui_print_result_message(
- $result,
- __('Successfully updated'),
- __('Could not be updated')
- );
-}
-
-// Mass-process DELETE.
-if (isset($_POST['deletebt'])) {
- $trap_ids = get_parameter_post('snmptrapid', []);
- if (is_array($trap_ids)) {
- if ($group_by) {
- foreach ($trap_ids as $key => $value) {
- $sql_ids_traps = 'SELECT id_trap, source FROM ttrap WHERE oid IN (SELECT oid FROM ttrap WHERE id_trap = '.$value.')
- AND source IN (SELECT source FROM ttrap WHERE id_trap = '.$value.')';
- $ids_traps = db_get_all_rows_sql($sql_ids_traps);
-
- foreach ($ids_traps as $key2 => $value2) {
- $result = db_process_sql_delete('ttrap', ['id_trap' => $value2['id_trap']]);
- enterprise_hook('snmp_update_forwarded_modules', [$value2]);
- }
- }
- } else {
- foreach ($trap_ids as $id_trap) {
- $forward_info = db_get_row('ttrap', 'id_trap', $id_trap);
- db_process_sql_delete('ttrap', ['id_trap' => $id_trap]);
- enterprise_hook('snmp_update_forwarded_modules', [$forward_info]);
- }
- }
- }
-}
-
-// Mass-process UPDATE.
-if (isset($_POST['updatebt'])) {
- $trap_ids = get_parameter_post('snmptrapid', []);
- if (is_array($trap_ids)) {
- foreach ($trap_ids as $id_trap) {
- $sql = sprintf("UPDATE ttrap SET status = 1, id_usuario = '%s' WHERE id_trap = %d", $config['id_user'], $id_trap);
- db_process_sql($sql);
- enterprise_hook('snmp_update_forwarded_modules', [$id_trap]);
- }
- }
-}
-
-// All traps.
-$all_traps = db_get_all_rows_sql('SELECT DISTINCT source FROM ttrap');
-
-if (empty($all_traps)) {
- $all_traps = [];
-}
-
-// Set filters.
-$agents = [];
-$oids = [];
-$severities = get_priorities();
-$alerted = [
- __('Not fired'),
- __('Fired'),
-];
-foreach ($all_traps as $trap) {
- $agent = agents_get_agent_with_ip($trap['source']);
- $agents[$trap['source']] = $agent !== false ? ($agent['alias'] ? $agent['alias'] : $agent['nombre']) : $trap['source'];
- $oid = enterprise_hook('get_oid', [$trap]);
- if ($oid === ENTERPRISE_NOT_HOOK) {
- $oid = $trap['oid'];
- }
-
- $oids[$oid] = $oid;
-}
-
-$prea = array_keys($user_groups);
-$ids = join(',', $prea);
-// Cuantos usuarios hay operadores con un grupo que exista y no lo tenga ningun usuario.
-$user_in_group_wo_agents = db_get_value_sql('select count(DISTINCT(id_usuario)) from tusuario_perfil where id_usuario ="'.$config['id_user'].'" and id_perfil = 1 and id_grupo in (select id_grupo from tgrupo where id_grupo in ('.$ids.') and id_grupo not in (select id_grupo from tagente))');
-
-switch ($config['dbtype']) {
- case 'mysql':
- case 'postgresql':
- if ($user_in_group_wo_agents == 0) {
- $rows = db_get_all_rows_filter(
- 'tagente',
- ['id_grupo' => array_keys($user_groups)],
- ['id_agente']
- );
- $id_agents = [];
- foreach ($rows as $row) {
- $id_agents[] = $row['id_agente'];
- }
-
- if (!empty($id_agents)) {
- $address_by_user_groups = agents_get_addresses($id_agents);
- foreach ($address_by_user_groups as $i => $a) {
- $address_by_user_groups[$i] = '"'.$a.'"';
- }
- }
- } else {
- $rows = db_get_all_rows_filter(
- 'tagente',
- [],
- ['id_agente']
- );
- $id_agents = [];
- foreach ($rows as $row) {
- $id_agents[] = $row['id_agente'];
- }
-
- $all_address_agents = agents_get_addresses($id_agents);
- foreach ($all_address_agents as $i => $a) {
- $all_address_agents[$i] = '"'.$a.'"';
- }
- }
- break;
-
- default:
- // Default.
- break;
-}
-
-if (empty($address_by_user_groups)) {
- $address_by_user_groups = [];
- array_unshift($address_by_user_groups, '""');
-}
-
-if (empty($all_address_agents)) {
- $all_address_agents = [];
- array_unshift($all_address_agents, '""');
-}
-
-
-// Make query to extract traps of DB.
-switch ($config['dbtype']) {
- case 'mysql':
- $sql = 'SELECT *
- FROM ttrap
- WHERE (
- `source` IN ('.implode(',', $address_by_user_groups).") OR
- `source`='' OR
- `source` NOT IN (".implode(',', $all_address_agents).')
- )
- %s
- ORDER BY timestamp DESC
- LIMIT %d,%d';
- break;
-
- case 'postgresql':
- $sql = 'SELECT *
- FROM ttrap
- WHERE (
- source IN ('.implode(',', $address_by_user_groups).") OR
- source='' OR
- source NOT IN (".implode(',', $all_address_agents).')
- )
- %s
- ORDER BY timestamp DESC
- LIMIT %d OFFSET %d';
- break;
-
- case 'oracle':
- $sql = "SELECT *
- FROM ttrap
- WHERE (source IN (
- SELECT direccion FROM tagente
- WHERE id_grupo IN ($str_user_groups)
- ) OR source='' OR source NOT IN (SELECT direccion FROM tagente WHERE direccion IS NOT NULL)) %s
- ORDER BY timestamp DESC";
- break;
-
- default:
- // Default.
- break;
-}
-
-switch ($config['dbtype']) {
- case 'mysql':
- case 'postgresql':
- $sql_all = 'SELECT *
- FROM ttrap
- WHERE (
- source IN ('.implode(',', $address_by_user_groups).") OR
- source='' OR
- source NOT IN (".implode(',', $all_address_agents).')
- )
- %s
- ORDER BY timestamp DESC';
- $sql_count = 'SELECT COUNT(id_trap)
- FROM ttrap
- WHERE (
- source IN ('.implode(',', $address_by_user_groups).") OR
- source='' OR
- source NOT IN (".implode(',', $all_address_agents).')
- )
- %s';
- break;
-
- case 'oracle':
- $sql_all = "SELECT *
- FROM ttrap
- WHERE (source IN (
- SELECT direccion FROM tagente
- WHERE id_grupo IN ($str_user_groups)
- ) OR source='' OR source NOT IN (SELECT direccion FROM tagente WHERE direccion IS NOT NULL))
- %s
- ORDER BY timestamp DESC";
- $sql_count = "SELECT COUNT(id_trap)
- FROM ttrap
- WHERE (
- source IN (
- SELECT direccion FROM tagente
- WHERE id_grupo IN ($str_user_groups)
- ) OR source='' OR source NOT IN (SELECT direccion FROM tagente WHERE direccion IS NOT NULL))
- %s";
- break;
-
- default:
- // Default.
- break;
-}
-
-// $whereSubquery = 'WHERE 1=1';
-$whereSubquery = '';
-
-if ($filter_fired != -1) {
- $whereSubquery .= ' AND alerted = '.$filter_fired;
-}
-
-if ($free_search_string != '') {
- switch ($config['dbtype']) {
- case 'mysql':
- $whereSubquery .= '
- AND (source LIKE "%'.$free_search_string.'%" OR
- oid LIKE "%'.$free_search_string.'%" OR
- oid_custom LIKE "%'.$free_search_string.'%" OR
- type_custom LIKE "%'.$free_search_string.'%" OR
- value LIKE "%'.$free_search_string.'%" OR
- value_custom LIKE "%'.$free_search_string.'%" OR
- id_usuario LIKE "%'.$free_search_string.'%" OR
- text LIKE "%'.$free_search_string.'%" OR
- description LIKE "%'.$free_search_string.'%")';
- break;
-
- case 'postgresql':
- case 'oracle':
- $whereSubquery .= '
- AND (source LIKE \'%'.$free_search_string.'%\' OR
- oid LIKE \'%'.$free_search_string.'%\' OR
- oid_custom LIKE \'%'.$free_search_string.'%\' OR
- type_custom LIKE \'%'.$free_search_string.'%\' OR
- value LIKE \'%'.$free_search_string.'%\' OR
- value_custom LIKE \'%'.$free_search_string.'%\' OR
- id_usuario LIKE \'%'.$free_search_string.'%\' OR
- text LIKE \'%'.$free_search_string.'%\' OR
- description LIKE \'%'.$free_search_string.'%\')';
- break;
-
- default:
- // Default.
- break;
- }
-}
-
-if ($date_from_trap != '') {
- if ($time_from_trap != '') {
- $whereSubquery .= '
- AND (UNIX_TIMESTAMP(timestamp) > UNIX_TIMESTAMP("'.$date_from_trap.' '.$time_from_trap.'"))
- ';
- } else {
- $whereSubquery .= '
- AND (UNIX_TIMESTAMP(timestamp) > UNIX_TIMESTAMP("'.$date_from_trap.' 23:59:59"))
- ';
- }
-}
-
-if ($date_to_trap != '') {
- if ($time_to_trap) {
- $whereSubquery .= '
- AND (UNIX_TIMESTAMP(timestamp) < UNIX_TIMESTAMP("'.$date_to_trap.' '.$time_to_trap.'"))
- ';
- } else {
- $whereSubquery .= '
- AND (UNIX_TIMESTAMP(timestamp) < UNIX_TIMESTAMP("'.$date_to_trap.' 23:59:59"))
- ';
- }
-}
-
-if ($filter_severity != -1) {
- // There are two special severity values aimed to match two different trap standard severities in database: warning/critical and critical/normal.
- if ($filter_severity != EVENT_CRIT_OR_NORMAL && $filter_severity != EVENT_CRIT_WARNING_OR_CRITICAL) {
- // Test if enterprise is installed to search oid in text or oid field in ttrap.
- if ($config['enterprise_installed']) {
- $whereSubquery .= ' AND (
- (alerted = 0 AND severity = '.$filter_severity.') OR
- (alerted = 1 AND priority = '.$filter_severity.'))';
- } else {
- $whereSubquery .= ' AND (
- (alerted = 0 AND 1 = '.$filter_severity.') OR
- (alerted = 1 AND priority = '.$filter_severity.'))';
- }
- } else if ($filter_severity === EVENT_CRIT_WARNING_OR_CRITICAL) {
- // Test if enterprise is installed to search oid in text or oid field in ttrap.
- if ($config['enterprise_installed']) {
- $whereSubquery .= ' AND (
- (alerted = 0 AND (severity = '.EVENT_CRIT_WARNING.' OR severity = '.EVENT_CRIT_CRITICAL.')) OR
- (alerted = 1 AND (priority = '.EVENT_CRIT_WARNING.' OR priority = '.EVENT_CRIT_CRITICAL.')))';
- } else {
- $whereSubquery .= ' AND (
- (alerted = 1 AND (priority = '.EVENT_CRIT_WARNING.' OR priority = '.EVENT_CRIT_CRITICAL.')))';
- }
- } else if ($filter_severity === EVENT_CRIT_OR_NORMAL) {
- // Test if enterprise is installed to search oid in text or oid field in ttrap.
- if ($config['enterprise_installed']) {
- $whereSubquery .= ' AND (
- (alerted = 0 AND (severity = '.EVENT_CRIT_NORMAL.' OR severity = '.EVENT_CRIT_CRITICAL.')) OR
- (alerted = 1 AND (priority = '.EVENT_CRIT_NORMAL.' OR priority = '.EVENT_CRIT_CRITICAL.')))';
- } else {
- $whereSubquery .= ' AND (
- (alerted = 1 AND (priority = '.EVENT_CRIT_NORMAL.' OR priority = '.EVENT_CRIT_CRITICAL.')))';
- }
- }
-}
-
-if ($filter_status != -1) {
- $whereSubquery .= ' AND status = '.$filter_status;
-}
-
-if ($trap_type == 5) {
- $whereSubquery .= ' AND type NOT IN (0, 1, 2, 3, 4)';
-} else if ($trap_type != -1) {
- $whereSubquery .= ' AND type = '.$trap_type;
-}
-
-// Disable this feature (time will decide if temporarily) in Oracle cause the group by is very confictive.
-if ($group_by && $config['dbtype'] != 'oracle') {
- $where_without_group = $whereSubquery;
- $whereSubquery .= ' GROUP BY source,oid';
-}
-
-switch ($config['dbtype']) {
- case 'mysql':
- $sql = sprintf($sql, $whereSubquery, $offset, $pagination);
- break;
-
- case 'postgresql':
- $sql = sprintf($sql, $whereSubquery, $pagination, $offset);
- break;
-
- case 'oracle':
- $set = [];
- $set['limit'] = $pagination;
- $set['offset'] = $offset;
- $sql = sprintf($sql, $whereSubquery);
- $sql = oracle_recode_query($sql, $set);
- break;
-
- default:
- // Default.
- break;
-}
-
-$sql_all = sprintf($sql_all, $whereSubquery);
-$sql_count = sprintf($sql_count, $whereSubquery);
-
-$table = new stdClass();
-$table->width = '100%';
-$table->cellpadding = 0;
-$table->cellspacing = 0;
-$table->class = 'databox filters';
-$table->size = [];
-$table->size[0] = '120px';
-$table->data = [];
-
-// Alert status select.
-$table->data[1][0] = ''.__('Alert').'';
-$table->data[1][1] = html_print_select(
- $alerted,
- 'filter_fired',
- $filter_fired,
- '',
- __('All'),
- '-1',
- true
-);
-
-// Block size for pagination select.
-$table->data[2][0] = ''.__('Block size for pagination').'';
-$paginations[25] = 25;
-$paginations[50] = 50;
-$paginations[100] = 100;
-$paginations[200] = 200;
-$paginations[500] = 500;
-$table->data[2][1] = html_print_select(
- $paginations,
- 'pagination',
- $pagination,
- '',
- __('Default'),
- $config['block_size'],
- true
-);
-
-// Severity select.
-$table->data[1][2] = ''.__('Severity').'';
-$table->data[1][3] = html_print_select(
- $severities,
- 'filter_severity',
- $filter_severity,
- '',
- __('All'),
- -1,
- true
-);
-
-// Status.
-$table->data[3][0] = ''.__('Status').'';
-
-$status_array[-1] = __('All');
-$status_array[0] = __('Not validated');
-$status_array[1] = __('Validated');
-$table->data[3][1] = html_print_select(
- $status_array,
- 'filter_status',
- $filter_status,
- '',
- '',
- '',
- true
-);
-
-// Free search (search by all alphanumeric fields).
-$table->data[2][3] = ''.__('Free search').''.ui_print_help_tip(
- __(
- 'Search by any alphanumeric field in the trap.
- REMEMBER trap sources need to be searched by IP Address'
- ),
- true
-);
-$table->data[2][4] = html_print_input_text(
- 'free_search_string',
- $free_search_string,
- '',
- 40,
- 0,
- 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[4][3] = ''.__('Trap type').''.ui_print_help_tip(__('Search by trap type'), true);
-$trap_types = [
- -1 => __('None'),
- 0 => __('Cold start (0)'),
- 1 => __('Warm start (1)'),
- 2 => __('Link down (2)'),
- 3 => __('Link up (3)'),
- 4 => __('Authentication failure (4)'),
- 5 => __('Other'),
-];
-$table->data[4][4] = html_print_select(
- $trap_types,
- 'trap_type',
- $trap_type,
- '',
- '',
- '',
- true,
- false,
- false
-);
-
-// Disable this feature (time will decide if temporarily) in Oracle cause the group by is very confictive.
-if ($config['dbtype'] != 'oracle') {
- $table->data[3][3] = ''.__('Group by Enterprise String/IP').'';
- $table->data[3][4] = __('Yes').' '.html_print_radio_button('group_by', 1, '', $group_by, true).' ';
- $table->data[3][4] .= __('No').' '.html_print_radio_button('group_by', 0, '', $group_by, true);
-}
-
-$filter = '';
-
-$filter_resume = [];
-$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['hours_ago'] = $hours_ago;
-$filter_resume['trap_type'] = $trap_types[$trap_type];
-
-$traps = db_get_all_rows_sql($sql, true);
-$trapcount = (int) db_get_value_sql($sql_count, false, true);
-
-// Re-sort traps by timestamp if history db is enabled.
-if ($config['history_db_enabled'] == 1) {
- usort(
- $traps,
- function ($a, $b) {
- return strtotime($a['timestamp']) < strtotime($b['timestamp']);
- }
- );
-}
-
-// No traps.
-if (empty($traps)) {
- // Header
- ui_print_standard_header(
- __('SNMP Console'),
- 'images/op_snmp.png',
- false,
- 'snmp_console',
- false,
- [
- $list,
- $statistics,
- ],
- [
- [
- 'link' => '',
- 'label' => __('Monitoring'),
- ],
- [
- 'link' => '',
- 'label' => __('SNMP'),
- ],
- ]
- );
-
- $sql2 = 'SELECT *
- FROM ttrap
- WHERE (
- `source` IN ('.implode(',', $address_by_user_groups).") OR
- `source`='' OR
- `source` NOT IN (".implode(',', $all_address_agents).')
- )
- AND status = 0
- ORDER BY timestamp DESC';
- $traps2 = db_get_all_rows_sql($sql2);
-
- if (!empty($traps2)) {
- ui_toggle($filter, __('Toggle filter(s)'));
-
- print_snmp_tags_active_filters($filter_resume);
-
- ui_print_info_message(['no_close' => true, 'message' => __('There are no SNMP traps in database that contains this filter') ]);
- } else {
- ui_print_info_message(['no_close' => true, 'message' => __('There are no SNMP traps in database') ]);
+ echo '[SnmpConsole]'.$e->getMessage();
}
+ // Stop this execution, but continue 'globally'.
return;
-} else {
- if ($config['pure']) {
- echo '';
+}
- echo '';
-
- ui_require_css_file('pandora_enterprise', ENTERPRISE_DIR.'/include/styles/');
- ui_require_css_file('pandora_dashboard', ENTERPRISE_DIR.'/include/styles/');
- ui_require_css_file('cluetip', 'include/styles/js/');
-
- ui_require_jquery_file('countdown');
- ui_require_javascript_file('pandora_dashboard', ENTERPRISE_DIR.'/include/javascript/');
- ui_require_javascript_file('wz_jsgraphics');
- ui_require_javascript_file('pandora_visual_console');
+ if (method_exists($controller, $method) === true) {
+ if ($controller->ajaxMethod($method) === true) {
+ $controller->{$method}();
+ } else {
+ $controller->error('Unavailable method.');
+ }
} else {
- // Header
- ui_print_standard_header(
- __('SNMP Console'),
- 'images/op_snmp.png',
- false,
- '',
- false,
- [
- $fullscreen,
- $list,
- $statistics,
- ],
- [
- [
- 'link' => '',
- 'label' => __('Monitoring'),
- ],
- [
- 'link' => '',
- 'label' => __('SNMP'),
- ],
- ]
- );
+ $controller->error('Method not found. ['.$method.']');
}
-}
-ui_toggle($filter, __('Toggle filter(s)'));
-unset($table);
-
-print_snmp_tags_active_filters($filter_resume);
-
-if (($config['dbtype'] == 'oracle') && ($traps !== false)) {
- $traps_size = count($traps);
- for ($i = 0; $i < $traps_size; $i++) {
- unset($traps[$i]['rnum']);
- }
-}
-
-$url_snmp = 'index.php?sec=snmpconsole&sec2=operation/snmpconsole/snmp_view';
-$url_snmp .= '&filter_severity='.$filter_severity.'&filter_fired='.$filter_fired;
-$url_snmp .= '&filter_status='.$filter_status.'&refresh='.((int) get_parameter('refresh', 0));
-$url_snmp .= '&pure='.$config['pure'].'&trap_type='.$trap_type;
-$url_snmp .= '&group_by='.$group_by.'&free_search_string='.$free_search_string;
-$url_snmp .= '&hours_ago='.$hours_ago;
-
-$urlPagination = $url_snmp.'&pagination='.$pagination.'&offset='.$offset;
-
-ui_pagination($trapcount, $urlPagination, $offset, $pagination);
-
-echo '
';
-
-
-echo '
';
-echo '
'.__('Status').'
';
-echo html_print_image(
- 'images/pixel_green.png',
- true,
- [
- 'width' => '20',
- 'height' => '20',
- ]
-).' - '.__('Validated');
-echo '
';
-echo html_print_image(
- 'images/pixel_red.png',
- true,
- [
- 'width' => '20',
- 'height' => '20',
- ]
-).' - '.__('Not validated');
-echo '';
-echo '
';
-echo '
'.__('Alert').'
';
-echo html_print_image(
- 'images/pixel_yellow.png',
- true,
- [
- 'width' => '20',
- 'height' => '20',
- ]
-).' - '.__('Fired');
-echo '
';
-echo html_print_image(
- 'images/pixel_gray.png',
- true,
- [
- 'width' => '20',
- 'height' => '20',
- ]
-).' - '.__('Not fired');
-echo '';
-echo '
';
-echo '
'.__('Action').'
';
-echo html_print_image('images/ok.png', true).' - '.__('Validate');
-echo '
';
-echo html_print_image('images/cross.png', true, ['class' => 'invert_filter']).' - '.__('Delete');
-echo '';
-echo '
';
-echo '
'.__('Legend').'
';
-foreach (get_priorities() as $num => $name) {
- echo ''.$name.'';
- echo '
';
-}
-
-echo '';
-echo '
';
-
-ui_include_time_picker();
-?>
-
-
\ No newline at end of file