2013-07-19 Ramon Novoa <rnovoa@artica.es>
* godmode/agentes/module_manager_editor_network.php, include/javascript/pandora_snmp_browser.js, include/functions_snmp_browser.php, operation/snmpconsole/snmp_browser.php: Added SNMP version support to the SNMP browser. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8556 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
6b009c469d
commit
4b397a5238
|
@ -1,3 +1,11 @@
|
|||
2013-07-19 Ramon Novoa <rnovoa@artica.es>
|
||||
|
||||
* godmode/agentes/module_manager_editor_network.php,
|
||||
include/javascript/pandora_snmp_browser.js,
|
||||
include/functions_snmp_browser.php,
|
||||
operation/snmpconsole/snmp_browser.php: Added SNMP version support to
|
||||
the SNMP browser.
|
||||
|
||||
2013-07-22 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* include/functions_graph.php, include/functions_reports.php,
|
||||
|
|
|
@ -243,6 +243,67 @@ $(document).ready (function () {
|
|||
$('#text-snmp_community').keyup(function() {
|
||||
$('#text-community').val($(this).val());
|
||||
});
|
||||
$('#snmp_version').change(function() {
|
||||
$('#snmp_browser_version').val($(this).val());
|
||||
|
||||
// Display or collapse the SNMP browser's v3 options
|
||||
checkSNMPVersion ();
|
||||
});
|
||||
$('#snmp_browser_version').change(function() {
|
||||
$('#snmp_version').val($(this).val());
|
||||
|
||||
// Display or collapse the SNMP v3 options in the main window
|
||||
if ($(this).val() == "3") {
|
||||
$("#simple-field_snmpv3_row1").attr("style", "");
|
||||
$("#simple-field_snmpv3_row2").attr("style", "");
|
||||
$("#simple-field_snmpv3_row3").attr("style", "");
|
||||
$("input[name=active_snmp_v3]").val(1);
|
||||
$("input[name=snmp_community]").attr("disabled", true);
|
||||
}
|
||||
else {
|
||||
$("#simple-field_snmpv3_row1").css("display", "none");
|
||||
$("#simple-field_snmpv3_row2").css("display", "none");
|
||||
$("#simple-field_snmpv3_row3").css("display", "none");
|
||||
$("input[name=active_snmp_v3]").val(0);
|
||||
$("input[name=snmp_community]").removeAttr('disabled');
|
||||
}
|
||||
});
|
||||
$('#snmp3_auth_user').keyup(function() {
|
||||
$('#snmp3_browser_auth_user').val($(this).val());
|
||||
});
|
||||
$('#snmp3_browser_auth_user').keyup(function() {
|
||||
$('#snmp3_auth_user').val($(this).val());
|
||||
});
|
||||
$('#snmp3_security_level').change(function() {
|
||||
$('#snmp3_browser_security_level').val($(this).val());
|
||||
});
|
||||
$('#snmp3_browser_security_level').change(function() {
|
||||
$('#snmp3_security_level').val($(this).val());
|
||||
});
|
||||
$('#snmp3_auth_method').change(function() {
|
||||
$('#snmp3_browser_auth_method').val($(this).val());
|
||||
});
|
||||
$('#snmp3_browser_auth_method').change(function() {
|
||||
$('#snmp3_auth_method').val($(this).val());
|
||||
});
|
||||
$('#snmp3_auth_pass').keyup(function() {
|
||||
$('#snmp3_browser_auth_pass').val($(this).val());
|
||||
});
|
||||
$('#snmp3_browser_auth_pass').keyup(function() {
|
||||
$('#snmp3_auth_pass').val($(this).val());
|
||||
});
|
||||
$('#snmp3_privacy_method').change(function() {
|
||||
$('#snmp3_browser_privacy_method').val($(this).val());
|
||||
});
|
||||
$('#snmp3_browser_privacy_method').change(function() {
|
||||
$('#snmp3_privacy_method').val($(this).val());
|
||||
});
|
||||
$('#snmp3_privacy_pass').keyup(function() {
|
||||
$('#snmp3_browser_privacy_pass').val($(this).val());
|
||||
});
|
||||
$('#snmp3_browser_privacy_pass').keyup(function() {
|
||||
$('#snmp3_privacy_pass').val($(this).val());
|
||||
});
|
||||
});
|
||||
|
||||
// Show the SNMP browser window
|
||||
|
@ -251,7 +312,14 @@ function snmpBrowserWindow () {
|
|||
// Keep elements in the form and the SNMP browser synced
|
||||
$('#text-target_ip').val($('#text-ip_target').val());
|
||||
$('#text-community').val($('#text-snmp_community').val());
|
||||
|
||||
$('#snmp_browser_version').val($('#snmp_version').val());
|
||||
$('#snmp3_browser_auth_user').val($('#snmp3_auth_user').val());
|
||||
$('#snmp3_browser_security_level').val($('#snmp3_security_level').val());
|
||||
$('#snmp3_browser_auth_method').val($('#snmp3_auth_method').val());
|
||||
$('#snmp3_browser_auth_pass').val($('#snmp3_auth_pass').val());
|
||||
$('#snmp3_browser_privacy_method').val($('#snmp3_privacy_method').val());
|
||||
$('#snmp3_browser_privacy_pass').val($('#snmp3_privacy_pass').val());
|
||||
|
||||
$("#snmp_browser_container").show().dialog ({
|
||||
title: '',
|
||||
resizable: true,
|
||||
|
|
|
@ -138,7 +138,7 @@ function snmp_browser_print_tree ($tree, $id = 0, $depth = 0, $last = 0, $last_a
|
|||
*
|
||||
* @return array The SNMP tree.
|
||||
*/
|
||||
function snmp_browser_get_tree ($target_ip, $community, $starting_oid = '.') {
|
||||
function snmp_browser_get_tree ($target_ip, $community, $starting_oid = '.', $version = '2c', $snmp3_auth_user = '', $snmp3_security_level = '', $snmp3_auth_method = '', $snmp3_auth_pass = '', $snmp3_privacy_method = '', $snmp3_privacy_pass = '') {
|
||||
global $config;
|
||||
|
||||
if ($target_ip == '') {
|
||||
|
@ -163,8 +163,11 @@ function snmp_browser_get_tree ($target_ip, $community, $starting_oid = '.') {
|
|||
$snmpwalk_bin = $config['snmpwalk'];
|
||||
}
|
||||
$oid_tree = array('__LEAVES__' => array());
|
||||
exec ($snmpwalk_bin . ' -m ALL -M +' . escapeshellarg($config['homedir'] . '/attachment/mibs') . ' -Cc -c ' . escapeshellarg($community) . ' -v 2c ' . escapeshellarg($target_ip) . ' ' . escapeshellarg($starting_oid), $output, $rc);
|
||||
|
||||
if ($version == "3") {
|
||||
exec ($snmpwalk_bin . ' -m ALL -v 3 -u ' . escapeshellarg($snmp3_auth_user) . ' -A ' . escapeshellarg($snmp3_auth_pass) . ' -l ' . escapeshellarg($snmp3_security_level) . ' -a ' . escapeshellarg($snmp3_auth_method) . ' -x ' . escapeshellarg($snmp3_privacy_method) . ' -X ' . escapeshellarg($snmp3_privacy_pass) . ' ' . escapeshellarg($target_ip) . ' ' . escapeshellarg($starting_oid) . ' 2>/dev/null', $output, $rc);
|
||||
} else {
|
||||
exec ($snmpwalk_bin . ' -m ALL -M +' . escapeshellarg($config['homedir'] . '/attachment/mibs') . ' -Cc -c ' . escapeshellarg($community) . ' -v ' . escapeshellarg($version) . ' ' . escapeshellarg($target_ip) . ' ' . escapeshellarg($starting_oid) . ' 2>/dev/null', $output, $rc);
|
||||
}
|
||||
//if ($rc != 0) {
|
||||
// return __('No data');
|
||||
//}
|
||||
|
@ -236,7 +239,7 @@ function snmp_browser_get_tree ($target_ip, $community, $starting_oid = '.') {
|
|||
* @return array OID data.
|
||||
*
|
||||
*/
|
||||
function snmp_browser_get_oid ($target_ip, $community, $target_oid) {
|
||||
function snmp_browser_get_oid ($target_ip, $community, $target_oid, $version = '2c', $snmp3_auth_user = '', $snmp3_security_level = '', $snmp3_auth_method = '', $snmp3_auth_pass = '', $snmp3_privacy_method = '', $snmp3_privacy_pass = '') {
|
||||
global $config;
|
||||
|
||||
if ($target_oid == '') {
|
||||
|
@ -260,7 +263,12 @@ function snmp_browser_get_oid ($target_ip, $community, $target_oid) {
|
|||
else {
|
||||
$snmpget_bin = $config['snmpget'];
|
||||
}
|
||||
exec ($snmpget_bin . ' -m ALL -M +' . escapeshellarg($config['homedir'] . '/attachment/mibs') . ' -On -v 2c -c ' . escapeshellarg($community) . " " . escapeshellarg($target_ip) . ' ' . escapeshellarg($target_oid), $output, $rc);
|
||||
if ($version == "3") {
|
||||
exec ($snmpget_bin . ' -m ALL -v 3 -u ' . escapeshellarg($snmp3_auth_user) . ' -A ' . escapeshellarg($snmp3_auth_pass) . ' -l ' . escapeshellarg($snmp3_security_level) . ' -a ' . escapeshellarg($snmp3_auth_method) . ' -x ' . escapeshellarg($snmp3_privacy_method) . ' -X ' . escapeshellarg($snmp3_privacy_pass) . ' ' . escapeshellarg($target_ip) . ' ' . escapeshellarg($target_oid) . ' 2>/dev/null', $output, $rc);
|
||||
} else {
|
||||
exec ($snmpget_bin . ' -m ALL -M +' . escapeshellarg($config['homedir'] . '/attachment/mibs') . ' -On -c ' . escapeshellarg($community) . ' -v ' . escapeshellarg($version) . ' ' . escapeshellarg($target_ip) . ' ' . escapeshellarg($target_oid) . ' 2>/dev/null', $output, $rc);
|
||||
}
|
||||
|
||||
if ($rc != 0) {
|
||||
return $oid_data;
|
||||
}
|
||||
|
@ -433,9 +441,37 @@ function snmp_browser_print_container ($return = false, $width = '95%', $height
|
|||
$table->data[0][1] .= html_print_input_text ('community', '', '', 25, 0, true);
|
||||
$table->data[0][2] = '<strong>'.__('Starting OID').'</strong><br>';
|
||||
$table->data[0][2] .= html_print_input_text ('starting_oid', '.1.3.6.1.2', '', 25, 0, true);
|
||||
$table->data[0][3] = html_print_button(__('Browse'), 'browse', false, 'snmpBrowse()', 'class="sub search"', true);
|
||||
$table->cellstyle[0][3] = 'vertical-align: bottom;';
|
||||
|
||||
$table->data[0][3] = '<strong>' . __('Version') . '</strong>';
|
||||
$table->data[0][3] .= html_print_select (array ('1' => 'v. 1', '2' => 'v. 2', '2c' => 'v. 2c', '3' => 'v. 3'), 'snmp_browser_version', '', 'checkSNMPVersion();', '', '', true, false, false, '');
|
||||
$table->cellstyle[0][3] = 'width: 15px;';
|
||||
|
||||
$table->data[0][4] = html_print_button(__('Browse'), 'browse', false, 'snmpBrowse()', 'class="sub search"', true);
|
||||
$table->cellstyle[0][4] = 'vertical-align: bottom;';
|
||||
|
||||
// SNMP v3 options
|
||||
$table3->width = '98%';
|
||||
|
||||
$table3->valign[0] = 'top';
|
||||
$table3->valign[1] = 'top';
|
||||
|
||||
$table3->data[2][1] = '<b>'.__('Auth user').'</b>';
|
||||
$table3->data[2][2] = html_print_input_text ('snmp3_browser_auth_user', '', '', 15, 60, true);
|
||||
$table3->data[2][3] = '<b>'.__('Auth password').'</b>';
|
||||
$table3->data[2][4] = html_print_input_text ('snmp3_browser_auth_pass', '', '', 15, 60, true);
|
||||
$table3->data[2][4] .= html_print_input_hidden('active_snmp_v3', 0, true);
|
||||
|
||||
$table3->data[5][0] = '<b>'.__('Privacy method').'</b>';
|
||||
$table3->data[5][1] = html_print_select(array('DES' => __('DES'), 'AES' => __('AES')), 'snmp3_browser_privacy_method', '', '', '', '', true);
|
||||
$table3->data[5][2] = '<b>'.__('privacy pass').'</b>';
|
||||
$table3->data[5][3] = html_print_input_text ('snmp3_browser_privacy_pass', '', '', 15, 60, true);
|
||||
|
||||
$table3->data[6][0] = '<b>'.__('Auth method').'</b>';
|
||||
$table3->data[6][1] = html_print_select(array('MD5' => __('MD5'), 'SHA' => __('SHA')), 'snmp3_browser_auth_method', '', '', '', '', true);
|
||||
$table3->data[6][2] = '<b>'.__('Security level').'</b>';
|
||||
$table3->data[6][3] = html_print_select(array('noAuthNoPriv' => __('Not auth and not privacy method'),
|
||||
'authNoPriv' => __('Auth and not privacy method'), 'authPriv' => __('Auth and privacy method')), 'snmp3_browser_security_level', '', '', '', '', true);
|
||||
|
||||
// Search tools
|
||||
$table2->width = '100%';
|
||||
$table2->size = array ();
|
||||
|
@ -467,13 +503,19 @@ function snmp_browser_print_container ($return = false, $width = '95%', $height
|
|||
$output .= '<div style="width: 100%">';
|
||||
$output .= html_print_table($table, true);
|
||||
$output .= '</div>';
|
||||
if ($snmp_version == 3) {
|
||||
$output .= '<div id="snmp3_browser_options">';
|
||||
}
|
||||
else {
|
||||
$output .= '<div id="snmp3_browser_options" style="display: none;">';
|
||||
}
|
||||
|
||||
$output .= ui_toggle(html_print_table($table3, true), __('SNMP v3 options'), '', true, true);
|
||||
$output .= '</div>';
|
||||
$output .= '<div style="width: 100%; padding-top: 10px;">';
|
||||
$output .= ui_toggle(html_print_table($table2, true), __('Search options'), '', true, true);
|
||||
$output .= '</div>';
|
||||
$output .= '<div>';
|
||||
$output .= '';
|
||||
$output .= '</div>';
|
||||
|
||||
|
||||
// SNMP tree container
|
||||
$output .= '<div style="width: 100%; height: 100%; margin-top: 5px; position: relative;">';
|
||||
$output .= html_print_input_hidden ('search_count', 0, true);
|
||||
|
|
|
@ -18,7 +18,13 @@ function snmpBrowse () {
|
|||
var target_ip = $('#text-target_ip').val();
|
||||
var community = $('#text-community').val();
|
||||
var starting_oid = $('#text-starting_oid').val();
|
||||
var starting_oid = $('#text-starting_oid').val();
|
||||
var snmp_version = $('#snmp_browser_version').val();
|
||||
var snmp3_auth_user = $('#text-snmp3_browser_auth_user').val();
|
||||
var snmp3_security_level = $('#snmp3_browser_security_level').val();
|
||||
var snmp3_auth_method = $('#snmp3_browser_auth_method').val();
|
||||
var snmp3_auth_pass = $('#text-snmp3_browser_auth_pass').val();
|
||||
var snmp3_privacy_method = $('#snmp3_browser_privacy_method').val();
|
||||
var snmp3_privacy_pass = $('#text-snmp3_browser_privacy_pass').val();
|
||||
var ajax_url = $('#hidden-ajax_url').val();
|
||||
|
||||
// Prepare the AJAX call
|
||||
|
@ -26,6 +32,13 @@ function snmpBrowse () {
|
|||
"target_ip=" + target_ip,
|
||||
"community=" + community,
|
||||
"starting_oid=" + starting_oid,
|
||||
"snmp_browser_version=" + snmp_version,
|
||||
"snmp3_browser_auth_user=" + snmp3_auth_user,
|
||||
"snmp3_browser_security_level=" + snmp3_security_level,
|
||||
"snmp3_browser_auth_method=" + snmp3_auth_method,
|
||||
"snmp3_browser_auth_pass=" + snmp3_auth_pass,
|
||||
"snmp3_browser_privacy_method=" + snmp3_privacy_method,
|
||||
"snmp3_browser_privacy_pass=" + snmp3_privacy_pass,
|
||||
"action=" + "snmptree",
|
||||
"page=operation/snmpconsole/snmp_browser"
|
||||
];
|
||||
|
@ -129,6 +142,13 @@ function snmpGet (oid) {
|
|||
// Read the target IP and community
|
||||
var target_ip = $('#text-target_ip').val();
|
||||
var community = $('#text-community').val();
|
||||
var snmp_version = $('#snmp_browser_version').val();
|
||||
var snmp3_auth_user = $('#text-snmp3_browser_auth_user').val();
|
||||
var snmp3_security_level = $('#snmp3_browser_security_level').val();
|
||||
var snmp3_auth_method = $('#snmp3_browser_auth_method').val();
|
||||
var snmp3_auth_pass = $('#text-snmp3_browser_auth_pass').val();
|
||||
var snmp3_privacy_method = $('#snmp3_browser_privacy_method').val();
|
||||
var snmp3_privacy_pass = $('#text-snmp3_browser_privacy_pass').val();
|
||||
var ajax_url = $('#hidden-ajax_url').val();
|
||||
|
||||
// Check for a custom action
|
||||
|
@ -142,6 +162,13 @@ function snmpGet (oid) {
|
|||
"target_ip=" + target_ip,
|
||||
"community=" + community,
|
||||
"oid=" + oid,
|
||||
"snmp_browser_version=" + snmp_version,
|
||||
"snmp3_browser_auth_user=" + snmp3_auth_user,
|
||||
"snmp3_browser_security_level=" + snmp3_security_level,
|
||||
"snmp3_browser_auth_method=" + snmp3_auth_method,
|
||||
"snmp3_browser_auth_pass=" + snmp3_auth_pass,
|
||||
"snmp3_browser_privacy_method=" + snmp3_privacy_method,
|
||||
"snmp3_browser_privacy_pass=" + snmp3_privacy_pass,
|
||||
"action=" + "snmpget",
|
||||
"custom_action=" + custom_action,
|
||||
"page=operation/snmpconsole/snmp_browser"
|
||||
|
@ -344,3 +371,13 @@ function searchLastMatch () {
|
|||
// Focus the last match
|
||||
searchPrevMatch();
|
||||
}
|
||||
|
||||
// Hide or show SNMP v3 options
|
||||
function checkSNMPVersion () {
|
||||
if ($("#snmp_browser_version").val() == "3") {
|
||||
$("#snmp3_browser_options").css("display", "");
|
||||
}
|
||||
else {
|
||||
$("#snmp3_browser_options").css("display", "none");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,12 +26,20 @@ if (is_ajax()) {
|
|||
$action = (string) get_parameter ("action", "");
|
||||
$target_ip = (string) get_parameter ("target_ip", '');
|
||||
$community = (string) get_parameter ("community", '');
|
||||
$snmp_version = (string) get_parameter ("snmp_browser_version", '');
|
||||
$snmp3_auth_user = get_parameter('snmp3_browser_auth_user');
|
||||
$snmp3_security_level = get_parameter('snmp3_browser_security_level');
|
||||
$snmp3_auth_method = get_parameter('snmp3_browser_auth_method');
|
||||
$snmp3_auth_pass = get_parameter('snmp3_browser_auth_pass');
|
||||
$snmp3_privacy_method = get_parameter('snmp3_browser_privacy_method');
|
||||
$snmp3_privacy_pass = get_parameter('snmp3_browser_privacy_pass');
|
||||
|
||||
// SNMP browser
|
||||
if ($action == "snmptree") {
|
||||
$starting_oid = (string) get_parameter ("starting_oid", '.');
|
||||
|
||||
$snmp_tree = snmp_browser_get_tree ($target_ip, $community, $starting_oid);
|
||||
$snmp_tree = snmp_browser_get_tree ($target_ip, $community, $starting_oid, $snmp_version,
|
||||
$snmp3_auth_user, $snmp3_security_level, $snmp3_auth_method, $snmp3_auth_pass, $snmp3_privacy_method, $snmp3_privacy_pass);
|
||||
if (! is_array ($snmp_tree)) {
|
||||
echo $snmp_tree;
|
||||
}
|
||||
|
@ -48,7 +56,8 @@ if (is_ajax()) {
|
|||
$custom_action = urldecode (base64_decode ($custom_action));
|
||||
}
|
||||
|
||||
$oid = snmp_browser_get_oid ($target_ip, $community, $target_oid);
|
||||
$oid = snmp_browser_get_oid ($target_ip, $community, $target_oid, $snmp_version,
|
||||
$snmp3_auth_user, $snmp3_security_level, $snmp3_auth_method, $snmp3_auth_pass, $snmp3_privacy_method, $snmp3_privacy_pass);
|
||||
snmp_browser_print_oid ($oid, $custom_action);
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue