Merge branch 'ent-2045-5325-Bug-Descripcion-MIBS' into 'develop'

[SNMP] Fixed translation of custom mibs, added custom description data and…

See merge request artica/pandorafms!1375
This commit is contained in:
vgilc 2018-03-22 10:03:16 +01:00
commit 7f30b63e98
5 changed files with 35 additions and 22 deletions

View File

@ -122,7 +122,7 @@ function pandora_realtime_graphs () {
echo '</form>'; echo '</form>';
// Define a custom action to save the OID selected in the SNMP browser to the form // 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('&nbsp;<a href="javascript:setOID()"><img src="' . ui_get_full_url("images") . '/hand_point.png" title="' . __("Use this OID") . '" style="vertical-align: middle;"></img></a>')), false); html_print_input_hidden ('custom_action', urlencode (base64_encode('&nbsp;<a href="javascript:setOID()"><img src="' . ui_get_full_url("images") . '/input_filter.disabled.png" title="' . __("Use this OID") . '" style="vertical-align: middle;"></img></a>')), false);
html_print_input_hidden ('incremental_base', '0'); html_print_input_hidden ('incremental_base', '0');
echo '<script type="text/javascript" src="extensions/realtime_graphs/realtime_graphs.js"></script>'; echo '<script type="text/javascript" src="extensions/realtime_graphs/realtime_graphs.js"></script>';

View File

@ -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); 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 // 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('&nbsp;<a href="javascript:setOID()"><img src="' . ui_get_full_url("images") . '/hand_point.png" title="' . __("Use this OID") . '" style="vertical-align: middle;"></img></a>')), false); html_print_input_hidden ('custom_action', urlencode (base64_encode('&nbsp;<a href="javascript:setOID()"><img src="' . ui_get_full_url("images") . '/input_filter.disabled.png" title="' . __("Use this OID") . '" style="vertical-align: middle;"></img></a>')), false);
$isFunctionPolicies = enterprise_include_once('include/functions_policies.php'); $isFunctionPolicies = enterprise_include_once('include/functions_policies.php');

View File

@ -383,7 +383,7 @@ function snmp_browser_get_oid ($target_ip, $community, $target_oid, $version = '
else { else {
$snmptranslate_bin = $config['snmptranslate']; $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); $translate_output);
foreach ($translate_output as $line) { foreach ($translate_output as $line) {
if (preg_match ('/SYNTAX\s+(.*)/', $line, $matches) == 1) { if (preg_match ('/SYNTAX\s+(.*)/', $line, $matches) == 1) {
@ -400,11 +400,16 @@ function snmp_browser_get_oid ($target_ip, $community, $target_oid, $version = '
} }
} }
// Parse the description // 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); $translate_output = implode ('', $translate_output);
if (preg_match ('/DESCRIPTION\s+\"(.*)\"/', $translate_output, $matches) == 1) { if (preg_match ('/DESCRIPTION\s+\"(.*)\"/', $translate_output, $matches) == 1) {
$oid_data['description'] = $matches[1]; $oid_data['description'] = $matches[1];
} }
} else {
$oid_data['description'] = $custom_data['description'];
}
$full_value = explode (':', trim ($full_oid[1])); $full_value = explode (':', trim ($full_oid[1]));
if (! isset ($full_value[1])) { if (! isset ($full_value[1])) {
@ -487,21 +492,21 @@ function snmp_browser_print_oid ($oid = array(), $custom_action = '',
$closer .= html_print_image ("images/blade.png", true, array ("title" => __('Close'), "style" => 'vertical-align: middle;'), false); $closer .= html_print_image ("images/blade.png", true, array ("title" => __('Close'), "style" => 'vertical-align: middle;'), false);
$closer .= '</a>'; $closer .= '</a>';
$table->head[0] = $closer;
$table->head[1] = __('OID Information');
// Add a span for custom actions // Add a span for custom actions
if ($custom_action != '') { if ($custom_action != '') {
$output .= '<span id="snmp_custom_action">' . $closer . $custom_action . '</span>'; $table->head[0] = '<span id="snmp_custom_action">' . $closer . $custom_action . '</span>';
} else {
$table->head[0] = $closer;
} }
$table->head[1] = __('OID Information');
$output .= html_print_table($table, true); $output .= html_print_table($table, true);
$url = "index.php?" . $url = "index.php?" .
"sec=gmodules&" . "sec=gmodules&" .
"sec2=godmode/modules/manage_network_components"; "sec2=godmode/modules/manage_network_components";
$output .= '<form style="text-align: center;" method="post" action="' . $url . '">'; $output .= '<form style="text-align: center; margin: 10px" method="post" action="' . $url . '">';
$output .= html_print_input_hidden('create_network_from_snmp_browser', 1, true); $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('id_component_type', 2, true);
$output .= html_print_input_hidden('type', 17, 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_community', $community, true);
$output .= html_print_input_hidden('snmp_version', $snmp_version, true); $output .= html_print_input_hidden('snmp_version', $snmp_version, true);
$output .= html_print_submit_button(__('Create network component'), $output .= html_print_submit_button(__('Create network component'),
'', false, '', true); '', false, 'class="sub add"', true);
$output .= '</form>'; $output .= '</form>';
if ($return) { if ($return) {
@ -672,7 +677,7 @@ function snmp_browser_print_container ($return = false, $width = '100%', $height
$output .= '<div id="search_results" style="display: none; padding: 5px; background-color: #EAEAEA; border: 1px solid #E2E2E2; border-radius: 4px;"></div>'; $output .= '<div id="search_results" style="display: none; padding: 5px; background-color: #EAEAEA; border: 1px solid #E2E2E2; border-radius: 4px;"></div>';
$output .= '<div id="spinner" style="position: absolute; top:0; left:0px; display:none; padding: 5px;">' . html_print_image ("images/spinner.gif", true) . '</div>'; $output .= '<div id="spinner" style="position: absolute; top:0; left:0px; display:none; padding: 5px;">' . html_print_image ("images/spinner.gif", true) . '</div>';
$output .= '<div id="snmp_browser" style="height: 100%; overflow: auto; background-color: #F4F5F4; border: 1px solid #E2E2E2; border-radius: 4px; padding: 5px;"></div>'; $output .= '<div id="snmp_browser" style="height: 100%; overflow: auto; background-color: #F4F5F4; border: 1px solid #E2E2E2; border-radius: 4px; padding: 5px;"></div>';
$output .= '<div id="snmp_data" style="margin: 5px;"></div>'; $output .= '<div class="databox" id="snmp_data" style="margin: 5px;"></div>';
$output .= '</div>'; $output .= '</div>';
$output .= '</div>'; $output .= '</div>';
$output .= '</div>'; $output .= '</div>';

View File

@ -205,6 +205,7 @@ function hideOIDData() {
$("#snmp_data").empty(); $("#snmp_data").empty();
$("#snmp_data").css('display', 'none'); $("#snmp_data").css('display', 'none');
$(".forced_title_layer").css('display', 'none');
} }
// Search the SNMP tree for a matching string // Search the SNMP tree for a matching string

View File

@ -4620,3 +4620,10 @@ form ul.form_flex li ul li{
.events_bar { .events_bar {
margin:0 auto; margin:0 auto;
} }
#snmp_data {
background: #f9faf9;
}
#snmp_data .databox {
border: 0px;
}