diff --git a/pandora_console/include/functions_snmp_browser.php b/pandora_console/include/functions_snmp_browser.php
index 4920816c89..fd68b77e54 100644
--- a/pandora_console/include/functions_snmp_browser.php
+++ b/pandora_console/include/functions_snmp_browser.php
@@ -1,21 +1,41 @@
'.$error_redir_dir, $output, $rc);
+ if ($server_to_exec != 0) {
+ $sql = sprintf(
+ 'SELECT ip_address FROM tserver WHERE id_server = %d',
+ $server_to_exec
+ );
+ $server_data = db_get_row_sql($sql);
+
+ if ($version == '3') {
+ $command = $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> '.$error_redir_dir;
+ } else {
+ $command = $snmpget_bin.' -m ALL -M +'.escapeshellarg($config['homedir'].'/attachment/mibs').' -On -c '.escapeshellarg(io_safe_output($community)).' -v '.escapeshellarg($version).' '.escapeshellarg($target_ip).' '.escapeshellarg($target_oid).' 2> '.$error_redir_dir;
+ }
+
+ exec(
+ 'ssh pandora_exec_proxy@'.$server_data['ip_address'].' "'.$command.'"',
+ $output,
+ $rc
+ );
} else {
- exec($snmpget_bin.' -m ALL -M +'.escapeshellarg($config['homedir'].'/attachment/mibs').' -On -c '.escapeshellarg(io_safe_output($community)).' -v '.escapeshellarg($version).' '.escapeshellarg($target_ip).' '.escapeshellarg($target_oid).' 2> '.$error_redir_dir, $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> '.$error_redir_dir,
+ $output,
+ $rc
+ );
+ } else {
+ exec(
+ $snmpget_bin.' -m ALL -M +'.escapeshellarg($config['homedir'].'/attachment/mibs').' -On -c '.escapeshellarg(io_safe_output($community)).' -v '.escapeshellarg($version).' '.escapeshellarg($target_ip).' '.escapeshellarg($target_oid).' 2> '.$error_redir_dir,
+ $output,
+ $rc
+ );
+ }
}
if ($rc != 0) {
@@ -359,7 +444,7 @@ function snmp_browser_get_oid($target_ip, $community, $target_oid, $version='2c'
}
foreach ($output as $line) {
- // Separate the OID from the value
+ // Separate the OID from the value.
$full_oid = explode('=', $line);
if (! isset($full_oid[1])) {
break;
@@ -368,7 +453,7 @@ function snmp_browser_get_oid($target_ip, $community, $target_oid, $version='2c'
$oid = trim($full_oid[0]);
$oid_data['numeric_oid'] = $oid;
- // Translate the OID
+ // Translate the OID.
if (empty($config['snmptranslate'])) {
switch (PHP_OS) {
case 'FreeBSD':
@@ -387,10 +472,20 @@ function snmp_browser_get_oid($target_ip, $community, $target_oid, $version='2c'
$snmptranslate_bin = $config['snmptranslate'];
}
- exec(
- $snmptranslate_bin.' -m ALL -M +'.escapeshellarg($config['homedir'].'/attachment/mibs').' -Td '.escapeshellarg($oid),
- $translate_output
- );
+ if ($server_to_exec != 0) {
+ $command_output = $snmptranslate_bin.' -m ALL -M +'.escapeshellarg($config['homedir'].'/attachment/mibs').' -Td '.escapeshellarg($oid);
+ exec(
+ 'ssh pandora_exec_proxy@'.$server_data['ip_address'].' "'.$command_output.'"',
+ $translate_output,
+ $rc
+ );
+ } else {
+ 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) {
$oid_data['syntax'] = $matches[1];
@@ -403,7 +498,7 @@ function snmp_browser_get_oid($target_ip, $community, $target_oid, $version='2c'
}
}
- // Parse the description. First search for it in custom values
+ // 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);
diff --git a/pandora_console/include/javascript/pandora_snmp_browser.js b/pandora_console/include/javascript/pandora_snmp_browser.js
index eb4cc80f2e..ee75eac71f 100644
--- a/pandora_console/include/javascript/pandora_snmp_browser.js
+++ b/pandora_console/include/javascript/pandora_snmp_browser.js
@@ -164,6 +164,7 @@ function snmpGet(oid) {
var snmp3_privacy_method = $("#snmp3_browser_privacy_method").val();
var snmp3_privacy_pass = $("#password-snmp3_browser_privacy_pass").val();
var ajax_url = $("#hidden-ajax_url").val();
+ var server_to_exec = $("#server_to_exec").val();
// Check for a custom action
var custom_action = $("#hidden-custom_action").val();
@@ -183,6 +184,7 @@ function snmpGet(oid) {
"snmp3_browser_auth_pass=" + snmp3_auth_pass,
"snmp3_browser_privacy_method=" + snmp3_privacy_method,
"snmp3_browser_privacy_pass=" + snmp3_privacy_pass,
+ "server_to_exec=" + server_to_exec,
"action=" + "snmpget",
"custom_action=" + custom_action,
"page=operation/snmpconsole/snmp_browser"
diff --git a/pandora_console/operation/snmpconsole/snmp_browser.php b/pandora_console/operation/snmpconsole/snmp_browser.php
index 9cc50e1fc3..bae4f9e06f 100644
--- a/pandora_console/operation/snmpconsole/snmp_browser.php
+++ b/pandora_console/operation/snmpconsole/snmp_browser.php
@@ -1,24 +1,39 @@
'.html_print_image('images/normal_screen.png', true, ['title' => __('Normal screen')]).'';
+ // Windowed.
+ $link['text'] = '';
+ $link['text'] .= html_print_image(
+ 'images/normal_screen.png',
+ true,
+ ['title' => __('Normal screen')]
+ );
+ $link['text'] .= '';
} else {
- // Fullscreen
- $link['text'] = ''.html_print_image('images/full_screen.png', true, ['title' => __('Full screen')]).'';
+ // Fullscreen.
+ $link['text'] = '';
+ $link['text'] .= html_print_image(
+ 'images/full_screen.png',
+ true,
+ ['title' => __('Full screen')]
+ );
+ $link['text'] .= '';
}
-ui_print_page_header(__('SNMP Browser'), 'images/op_snmp.png', false, '', false, [$link]);
+ui_print_page_header(
+ __('SNMP Browser'),
+ 'images/op_snmp.png',
+ false,
+ '',
+ false,
+ [$link]
+);
-// SNMP tree container
+// SNMP tree container.
snmp_browser_print_container();