] array
if (!empty($snmp_int_ip)) {
@@ -345,6 +349,19 @@ $table->data[0][3] = html_print_input_text ('tcp_port', $tcp_port, '', 5, 20, tr
$table->data[1][0] = '' . __('Use agent ip') . '';
$table->data[1][1] = html_print_checkbox ('use_agent', 1, $use_agent, true);
+$servers_to_exec = array();
+$servers_to_exec[0] = __('Local console');
+if (enterprise_installed()) {
+ enterprise_include_once ('include/functions_satellite.php');
+
+ $rows = get_proxy_servers();
+ foreach ($rows as $row) {
+ $servers_to_exec[$row['id_server']] = $row['name'];
+ }
+}
+$table->data[1][2] = '' . __('Server to execute command') . '';
+$table->data[1][3] = html_print_select ($servers_to_exec, 'server_to_exec', $server_to_exec, '', '', '', true);
+
$snmp_versions['1'] = 'v. 1';
$snmp_versions['2'] = 'v. 2';
$snmp_versions['2c'] = 'v. 2c';
diff --git a/pandora_console/godmode/agentes/agent_wizard.wmi_explorer.php b/pandora_console/godmode/agentes/agent_wizard.wmi_explorer.php
index 5a5ee589ef..99fb1e5c54 100644
--- a/pandora_console/godmode/agentes/agent_wizard.wmi_explorer.php
+++ b/pandora_console/godmode/agentes/agent_wizard.wmi_explorer.php
@@ -29,6 +29,7 @@ $ip_target = (string) get_parameter ('ip_target', $ipAgent); // Host
$plugin_user = (string) get_parameter ('plugin_user', 'Administrator'); // Username
$plugin_pass = io_safe_output(get_parameter('plugin_pass', '')); // Password
$tcp_send = (string) get_parameter ('tcp_send'); // Namespace
+$server_to_exec = get_parameter('server_to_exec', true);
//See if id_agente is set (either POST or GET, otherwise -1
$id_agent = $idAgent;
@@ -53,7 +54,18 @@ if ($wmiexplore) {
$wmi_processes = $wmi_command . ' "select Name from Win32_Process"';
$processes_name_field = 1;
- exec($wmi_processes, $output);
+ if (enterprise_installed()) {
+ if ($server_to_exec != 0) {
+ $server_data = db_get_row('tserver','id_server', $server_to_exec);
+ exec("ssh root@" . $server_data['ip_address'] . " '" . $wmi_processes . "'", $output, $rc);
+ }
+ else {
+ exec($wmi_processes, $output);
+ }
+ }
+ else {
+ exec($wmi_processes, $output);
+ }
$fail = false;
if (preg_match('/^Failed/', $output[0])) {
@@ -79,7 +91,18 @@ if ($wmiexplore) {
$services_name_field = 0;
$services_check_field = 1;
- exec($wmi_services, $output);
+ if (enterprise_installed()) {
+ if ($server_to_exec != 0) {
+ $server_data = db_get_row('tserver','id_server', $server_to_exec);
+ exec("ssh root@" . $server_data['ip_address'] . " '" . $wmi_services . "'", $output, $rc);
+ }
+ else {
+ exec($wmi_services, $output);
+ }
+ }
+ else {
+ exec($wmi_services, $output);
+ }
foreach ($output as $index => $row) {
// First and second rows are Class and column names, ignore it
@@ -98,7 +121,18 @@ if ($wmiexplore) {
$wmi_disks = $wmi_command . ' "Select DeviceID from Win32_LogicalDisk"';
$disks_name_field = 0;
- exec($wmi_disks, $output);
+ if (enterprise_installed()) {
+ if ($server_to_exec != 0) {
+ $server_data = db_get_row('tserver','id_server', $server_to_exec);
+ exec("ssh root@" . $server_data['ip_address'] . " '" . $wmi_disks . "'", $output, $rc);
+ }
+ else {
+ exec($wmi_disks, $output);
+ }
+ }
+ else {
+ exec($wmi_disks, $output);
+ }
foreach ($output as $index => $row) {
// First and second rows are Class and column names, ignore it
@@ -267,6 +301,19 @@ $table->data[1][3] = html_print_input_password ('plugin_pass', $plugin_pass, '',
$table->data[1][3] .= '' . html_print_image("images/spinner.gif", true) . '
';
html_print_input_hidden('wmiexplore', 1);
+$servers_to_exec = array();
+$servers_to_exec[0] = __('Local console');
+if (enterprise_installed()) {
+ enterprise_include_once ('include/functions_satellite.php');
+
+ $rows = get_proxy_servers();
+ foreach ($rows as $row) {
+ $servers_to_exec[$row['id_server']] = $row['name'];
+ }
+}
+$table->data[2][0] = '' . __('Server to execute command') . '';
+$table->data[2][1] = html_print_select ($servers_to_exec, 'server_to_exec', $server_to_exec, '', '', '', true);
+
html_print_table($table);
echo "";
diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php
index 20cd0c4a80..d29289ecb3 100644
--- a/pandora_console/include/ajax/events.php
+++ b/pandora_console/include/ajax/events.php
@@ -139,7 +139,7 @@ if ($perform_event_response) {
$return_val = array();
$return_val['correct'] = false;
- $exec_val = system("ssh root@" . $server_data['ip_address'] . " '" . $command . " 2>&1'", $ret_val);
+ $exec_val = system("ssh root@" . $server_data['ip_address'] . " \"" . $command . " 2>&1\"", $ret_val);
if ($ret_val != 0) {
$return_val['message'] = "Conection error";
diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php
index 06081117f4..3472b0f567 100644
--- a/pandora_console/include/functions.php
+++ b/pandora_console/include/functions.php
@@ -1506,7 +1506,7 @@ function get_snmpwalk($ip_target, $snmp_version, $snmp_community = '',
$snmp3_auth_user = '', $snmp3_security_level = '',
$snmp3_auth_method = '', $snmp3_auth_pass = '',
$snmp3_privacy_method = '', $snmp3_privacy_pass = '',
- $quick_print = 0, $base_oid = "", $snmp_port = '') {
+ $quick_print = 0, $base_oid = "", $snmp_port = '', $server_to_exec = 0) {
global $config;
@@ -1598,7 +1598,18 @@ function get_snmpwalk($ip_target, $snmp_version, $snmp_community = '',
break;
}
- exec($command_str, $output, $rc);
+ if (enterprise_installed()) {
+ if ($server_to_exec != 0) {
+ $server_data = db_get_row('tserver','id_server', $server_to_exec);
+ exec("ssh root@" . $server_data['ip_address'] . " \"" . $command_str . "\"", $output, $rc);
+ }
+ else {
+ exec($command_str, $output, $rc);
+ }
+ }
+ else {
+ exec($command_str, $output, $rc);
+ }
// Parse the output of snmpwalk
$snmpwalk = array();