Added remote server to snmp browser
This commit is contained in:
parent
88834d6ea1
commit
6b4dfe9885
|
@ -130,15 +130,29 @@ if ($perform_event_response) {
|
|||
if ($event_response['server_to_exec'] != 0 && $event_response['type'] == 'command') {
|
||||
$commandExclusions = array ('vi', 'vim', 'nano');
|
||||
|
||||
$server_data = db_get_row('tserver','id_server', $event_response['server_to_exec']);
|
||||
|
||||
if (in_array(strtolower($command),$commandExclusions)) {
|
||||
echo "Only stdin/stdout commands are supported";
|
||||
}
|
||||
else {
|
||||
enterprise_include_once ('include/functions_satellite.php');
|
||||
$return_val = array();
|
||||
$return_val['correct'] = false;
|
||||
|
||||
$connection = connect_to_proxy_server('192.168.70.165');
|
||||
$exec_val = system("ssh root@" . $server_data['ip_address'] . " '" . $command . " 2>&1'", $ret_val);
|
||||
|
||||
$exec_val = proxy_execute_command($connection, io_safe_output($command));
|
||||
if ($ret_val != 0) {
|
||||
$return_val['message'] = "Conection error";
|
||||
}
|
||||
else {
|
||||
if ($exec_val == "root") {
|
||||
$return_val['correct'] = true;
|
||||
}
|
||||
else {
|
||||
$return_val['message'] = "User must be pandora_exec_proxy";
|
||||
}
|
||||
}
|
||||
ob_clean();
|
||||
|
||||
echo $exec_val;
|
||||
}
|
||||
|
|
|
@ -175,10 +175,9 @@ function snmp_browser_get_tree ($target_ip, $community, $starting_oid = '.', $ve
|
|||
}
|
||||
|
||||
if ($server_to_exec != 0) {
|
||||
$sql = sprintf("SELECT exec_proxy: FROM tserver WHERE id_server = %d", $server_to_exec);
|
||||
$server = db_get_row_sql($sql);
|
||||
$sql = sprintf("SELECT ip_address FROM tserver WHERE id_server = %d", $server_to_exec);
|
||||
$server_data = db_get_row_sql($sql);
|
||||
|
||||
if ($server) {
|
||||
if (enterprise_installed()) {
|
||||
enterprise_include_once ('include/functions_satellite.php');
|
||||
|
||||
|
@ -186,24 +185,20 @@ function snmp_browser_get_tree ($target_ip, $community, $starting_oid = '.', $ve
|
|||
if ($version == "3") {
|
||||
switch ($snmp3_security_level) {
|
||||
case "authPriv":
|
||||
$command = $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> ' . $error_redir_dir;
|
||||
$command = $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> " . $error_redir_dir;
|
||||
break;
|
||||
case "authNoPriv":
|
||||
$command = $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) . ' ' . escapeshellarg($target_ip) . ' ' . escapeshellarg($starting_oid) . ' 2> ' . $error_redir_dir;
|
||||
$command = $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) . " " . escapeshellarg($target_ip) . " " . escapeshellarg($starting_oid) . " 2> " . $error_redir_dir;
|
||||
break;
|
||||
case "noAuthNoPriv":
|
||||
$command = $snmpwalk_bin . ' -m ALL -v 3 -u ' . escapeshellarg($snmp3_auth_user) . ' -l ' . escapeshellarg($snmp3_security_level) . ' ' . escapeshellarg($target_ip) . ' ' . escapeshellarg($starting_oid) . ' 2> ' . $error_redir_dir;
|
||||
$command = $snmpwalk_bin . " -m ALL -v 3 -u " . escapeshellarg($snmp3_auth_user) . " -l " . escapeshellarg($snmp3_security_level) . " " . escapeshellarg($target_ip) . ' ' . escapeshellarg($starting_oid) . " 2> " . $error_redir_dir;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$command = $snmpwalk_bin . ' -m ALL -M +' . escapeshellarg($config['homedir'] . '/attachment/mibs') . ' -Cc -c ' . escapeshellarg($community) . ' -v ' . escapeshellarg($version) . ' ' . escapeshellarg($target_ip) . ' ' . escapeshellarg($starting_oid) . ' 2> ' . $error_redir_dir;
|
||||
}
|
||||
|
||||
$connection = connect_to_proxy_server('192.168.70.165');
|
||||
|
||||
$output = proxy_execute_command($connection, io_safe_output($command));
|
||||
$command = $snmpwalk_bin . " -m ALL -M +" . escapeshellarg($config['homedir'] . "/attachment/mibs") . " -Cc -c " . escapeshellarg($community) . " -v " . escapeshellarg($version) . " " . escapeshellarg($target_ip) . " " . escapeshellarg($starting_oid) . " 2> " . $error_redir_dir;
|
||||
}
|
||||
exec("ssh root@" . $server_data['ip_address'] . " \"" . $command . "\"", $output, $rc);
|
||||
}
|
||||
else {
|
||||
$oid_tree = array('__LEAVES__' => array());
|
||||
|
@ -225,7 +220,26 @@ function snmp_browser_get_tree ($target_ip, $community, $starting_oid = '.', $ve
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
$oid_tree = array('__LEAVES__' => array());
|
||||
if ($version == "3") {
|
||||
switch ($snmp3_security_level) {
|
||||
case "authPriv":
|
||||
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> ' . $error_redir_dir, $output, $rc);
|
||||
break;
|
||||
case "authNoPriv":
|
||||
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) . ' ' . escapeshellarg($target_ip) . ' ' . escapeshellarg($starting_oid) . ' 2> ' . $error_redir_dir, $output, $rc);
|
||||
break;
|
||||
case "noAuthNoPriv":
|
||||
exec ($snmpwalk_bin . ' -m ALL -v 3 -u ' . escapeshellarg($snmp3_auth_user) . ' -l ' . escapeshellarg($snmp3_security_level) . ' ' . escapeshellarg($target_ip) . ' ' . escapeshellarg($starting_oid) . ' 2> ' . $error_redir_dir, $output, $rc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
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> ' . $error_redir_dir, $output, $rc);
|
||||
}
|
||||
}
|
||||
html_debug($output, true);
|
||||
foreach ($output as $line) {
|
||||
|
||||
// Separate the OID from the value
|
||||
|
|
Loading…
Reference in New Issue