From 1001240cf460375f22dd1adb92729bda3626a485 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Thu, 15 Mar 2018 16:03:46 +0100 Subject: [PATCH] [SNMP] Fixed translation of custom mibs, added custom description data and change style of OID details --- .../extensions/realtime_graphs.php | 2 +- .../agentes/module_manager_editor_network.php | 2 +- .../include/functions_snmp_browser.php | 41 +++++++++++-------- .../javascript/pandora_snmp_browser.js | 3 +- pandora_console/include/styles/pandora.css | 9 +++- 5 files changed, 35 insertions(+), 22 deletions(-) diff --git a/pandora_console/extensions/realtime_graphs.php b/pandora_console/extensions/realtime_graphs.php index b4fade177d..a218d59710 100644 --- a/pandora_console/extensions/realtime_graphs.php +++ b/pandora_console/extensions/realtime_graphs.php @@ -122,7 +122,7 @@ function pandora_realtime_graphs () { echo ''; // Define a custom action to save the OID selected in the SNMP browser to the form - html_print_input_hidden ('custom_action', urlencode (base64_encode(' ')), false); + html_print_input_hidden ('custom_action', urlencode (base64_encode(' ')), false); html_print_input_hidden ('incremental_base', '0'); echo ''; diff --git a/pandora_console/godmode/agentes/module_manager_editor_network.php b/pandora_console/godmode/agentes/module_manager_editor_network.php index 915d1b542a..557b17f388 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_network.php +++ b/pandora_console/godmode/agentes/module_manager_editor_network.php @@ -27,7 +27,7 @@ html_print_input_hidden ('ajax_url', ui_get_full_url("ajax.php"), false); html_print_input_hidden ('search_matches_translation', __("Search matches"), false); // Define a custom action to save the OID selected in the SNMP browser to the form -html_print_input_hidden ('custom_action', urlencode (base64_encode(' ')), false); +html_print_input_hidden ('custom_action', urlencode (base64_encode(' ')), false); $isFunctionPolicies = enterprise_include_once('include/functions_policies.php'); diff --git a/pandora_console/include/functions_snmp_browser.php b/pandora_console/include/functions_snmp_browser.php index 390d6ec151..f101faee0f 100644 --- a/pandora_console/include/functions_snmp_browser.php +++ b/pandora_console/include/functions_snmp_browser.php @@ -383,7 +383,7 @@ function snmp_browser_get_oid ($target_ip, $community, $target_oid, $version = ' else { $snmptranslate_bin = $config['snmptranslate']; } - exec ($snmptranslate_bin . " -Td " . escapeshellarg($oid), + exec ($snmptranslate_bin . ' -m ALL -M +' . escapeshellarg($config['homedir'] . '/attachment/mibs') . " -Td " . escapeshellarg($oid), $translate_output); foreach ($translate_output as $line) { if (preg_match ('/SYNTAX\s+(.*)/', $line, $matches) == 1) { @@ -399,13 +399,18 @@ function snmp_browser_get_oid ($target_ip, $community, $target_oid, $version = ' $oid_data['display_hint'] = $matches[1]; } } - - // Parse the description - $translate_output = implode ('', $translate_output); - if (preg_match ('/DESCRIPTION\s+\"(.*)\"/', $translate_output, $matches) == 1) { - $oid_data['description'] = $matches[1]; + + // Parse the description. First search for it in custom values + $custom_data = db_get_row('ttrap_custom_values', 'oid', $oid); + if ($custom_data === false) { + $translate_output = implode ('', $translate_output); + if (preg_match ('/DESCRIPTION\s+\"(.*)\"/', $translate_output, $matches) == 1) { + $oid_data['description'] = $matches[1]; + } + } else { + $oid_data['description'] = $custom_data['description']; } - + $full_value = explode (':', trim ($full_oid[1])); if (! isset ($full_value[1])) { $oid_data['value'] = trim ($full_oid[1]); @@ -482,26 +487,26 @@ function snmp_browser_print_oid ($oid = array(), $custom_action = '', $table->data[$i][1] = $oid['status']; $i++; } - + $closer = ''; $closer .= html_print_image ("images/blade.png", true, array ("title" => __('Close'), "style" => 'vertical-align: middle;'), false); $closer .= ''; - - $table->head[0] = $closer; - $table->head[1] = __('OID Information'); - + // Add a span for custom actions if ($custom_action != '') { - $output .= '' . $closer . $custom_action . ''; + $table->head[0] = '' . $closer . $custom_action . ''; + } else { + $table->head[0] = $closer; } - + + $table->head[1] = __('OID Information'); $output .= html_print_table($table, true); - + $url = "index.php?" . "sec=gmodules&" . "sec2=godmode/modules/manage_network_components"; - $output .= '
'; + $output .= ''; $output .= html_print_input_hidden('create_network_from_snmp_browser', 1, true); $output .= html_print_input_hidden('id_component_type', 2, true); $output .= html_print_input_hidden('type', 17, true); @@ -519,7 +524,7 @@ function snmp_browser_print_oid ($oid = array(), $custom_action = '', $output .= html_print_input_hidden('snmp_community', $community, true); $output .= html_print_input_hidden('snmp_version', $snmp_version, true); $output .= html_print_submit_button(__('Create network component'), - '', false, '', true); + '', false, 'class="sub add"', true); $output .= '
'; if ($return) { @@ -672,7 +677,7 @@ function snmp_browser_print_container ($return = false, $width = '100%', $height $output .= ''; $output .= ''; $output .= '
'; - $output .= '
'; + $output .= '
'; $output .= ''; $output .= ''; $output .= ''; diff --git a/pandora_console/include/javascript/pandora_snmp_browser.js b/pandora_console/include/javascript/pandora_snmp_browser.js index fd202ad4dc..60f914c9e9 100644 --- a/pandora_console/include/javascript/pandora_snmp_browser.js +++ b/pandora_console/include/javascript/pandora_snmp_browser.js @@ -203,8 +203,9 @@ function hideOIDData() { // Empty previous OID data $("#snmp_data").empty(); - + $("#snmp_data").css('display', 'none'); + $(".forced_title_layer").css('display', 'none'); } // Search the SNMP tree for a matching string diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 28c6e3691d..6601807581 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -4619,4 +4619,11 @@ form ul.form_flex li ul li{ .events_bar { margin:0 auto; -} \ No newline at end of file +} + +#snmp_data { + background: #f9faf9; +} +#snmp_data .databox { + border: 0px; +}