diff --git a/pandora_console/include/ajax/snmp_browser.ajax.php b/pandora_console/include/ajax/snmp_browser.ajax.php index aa110f78ec..d057a8434c 100644 --- a/pandora_console/include/ajax/snmp_browser.ajax.php +++ b/pandora_console/include/ajax/snmp_browser.ajax.php @@ -25,6 +25,7 @@ if (is_ajax()) { $method = (string) get_parameter('method', ''); $action = (string) get_parameter('action', ''); $target_ip = (string) get_parameter('target_ip', ''); + $target_port = (string) get_parameter('target_port', ''); $community = (string) io_safe_output((get_parameter('community', ''))); $snmp_version = (string) get_parameter('snmp_browser_version', ''); $snmp3_auth_user = io_safe_output(get_parameter('snmp3_browser_auth_user')); @@ -63,7 +64,8 @@ if (is_ajax()) { $snmp3_privacy_method, $snmp3_privacy_pass, 'null', - $server_to_exec + $server_to_exec, + $target_port ); if (! is_array($snmp_tree)) { echo $snmp_tree; diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index b67374d27a..b9fe13dcec 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -2001,6 +2001,10 @@ function get_snmpwalk( ) { global $config; + if (empty($ip_target) === true) { + return []; + } + // Note: quick_print is ignored // Fix for snmp port if (!empty($snmp_port)) { diff --git a/pandora_console/include/functions_snmp_browser.php b/pandora_console/include/functions_snmp_browser.php index 6bb0a980aa..962bd9be4c 100644 --- a/pandora_console/include/functions_snmp_browser.php +++ b/pandora_console/include/functions_snmp_browser.php @@ -265,94 +265,43 @@ function snmp_browser_get_tree( $snmp3_privacy_method='', $snmp3_privacy_pass='', $snmp3_context_engine_id=null, - $server_to_exec=0 + $server_to_exec=0, + $target_port='' ) { global $config; - if ($server_to_exec != 0) { - $output = get_snmpwalk( - $target_ip, - $version, - $community, - $snmp3_auth_user, - $snmp3_security_level, - $snmp3_auth_method, - $snmp3_auth_pass, - $snmp3_privacy_method, - $snmp3_privacy_pass, - 0, - $starting_oid, - '', - $server_to_exec, - '', - '' - ); - } else { - switch ($version) { - case '1': - $snmp_version = SNMP::VERSION_1; - break; - - case '2': - $snmp_version = SNMP::VERSION_2C; - break; - - case '2c': - $snmp_version = SNMP::VERSION_2C; - break; - - case '3': - $snmp_version = SNMP::VERSION_3; - $community = $snmp3_auth_user; - break; - - default: - $snmp_version = SNMP::VERSION_2C; - break; - } - - $snmp_session = new SNMP($snmp_version, $target_ip, $community); - $snmp_session->oid_output_format = SNMP_OID_OUTPUT_MODULE; - - // Set security if SNMP Version is 3. - if ($snmp_version == SNMP::VERSION_3) { - $snmp_session->setSecurity( - $snmp3_security_level, - $snmp3_auth_method, - $snmp3_auth_pass, - $snmp3_privacy_method, - $snmp3_privacy_pass, - '', - $snmp3_context_engine_id - ); - } - - $mibs_dir = $config['homedir'].'/attachment/mibs'; - $_dir = opendir($mibs_dir); - - // Future. Recomemended: Use a global config limit of MIBs loaded. - while (($mib_file = readdir($_dir)) !== false) { - if ($mib_file == '..' || $mib_file == '.') { - continue; - } - - $rs = snmp_read_mib($mibs_dir.'/'.$mib_file); - if ($rs !== true) { - error_log('Failed while reading MIB file: '.$mib_file); - } - } - - closedir($_dir); - - $output = $snmp_session->walk($starting_oid); - if ($output == false) { - $output = $snmp_session->getError(); - $snmp_session->close(); - return $output; - } - - $snmp_session->close(); - } + $output = get_snmpwalk( + // Ip_target. + $target_ip, + // Snmp_version. + $version, + // Snmp_community. + $community, + // Snmp3_auth_user. + $snmp3_auth_user, + // Snmp3_security_level. + $snmp3_security_level, + // Snmp3_auth_method. + $snmp3_auth_method, + // Snmp3_auth_pass. + $snmp3_auth_pass, + // Snmp3_privacy_method. + $snmp3_privacy_method, + // Snmp3_privacy_pass. + $snmp3_privacy_pass, + // Quick_print. + 0, + // Base_oid. + $starting_oid, + // Snmp_port. + $target_port, + // Server_to_exec. + $server_to_exec, + // Extra_arguments. + '', + // Format. + '' + ); // Build the tree if output comes filled. if (empty($output) === false) { @@ -575,6 +524,7 @@ function snmp_browser_print_oid( $output = ''; // OID information table + $table = new StdClass(); $table->width = '100%'; $table->size = []; $table->data = []; @@ -725,15 +675,33 @@ function snmp_browser_print_container( $table->size = []; $table->data = []; - $table->data[0][0] = ''.__('Target IP').' '; - $table->data[0][0] .= html_print_input_text( - 'target_ip', - get_parameter('target_ip', ''), - '', - 25, - 0, - true + $table->size[0] = '30%'; + + $table->data[0][0] = '