From a80f62003c60c2a0071468e4d25756703cda0273 Mon Sep 17 00:00:00 2001 From: Arturo Gonzalez Date: Fri, 1 Sep 2017 10:44:26 +0200 Subject: [PATCH] Added details to agent wizard and secundary servers --- .../agentes/agent_wizard.snmp_explorer.php | 2 +- .../agent_wizard.snmp_interfaces_explorer.php | 45 ++++++++++++++++ .../agentes/agent_wizard.wmi_explorer.php | 15 +++--- .../godmode/servers/modificar_server.php | 2 +- pandora_console/include/functions_wmi.php | 54 ++++++++++++++++++- 5 files changed, 107 insertions(+), 11 deletions(-) diff --git a/pandora_console/godmode/agentes/agent_wizard.snmp_explorer.php b/pandora_console/godmode/agentes/agent_wizard.snmp_explorer.php index 14c026e2d2..1eebe0c075 100644 --- a/pandora_console/godmode/agentes/agent_wizard.snmp_explorer.php +++ b/pandora_console/godmode/agentes/agent_wizard.snmp_explorer.php @@ -716,7 +716,7 @@ $servers_to_exec[0] = __('Local console'); if (enterprise_installed()) { enterprise_include_once ('include/functions_satellite.php'); - $rows = get_proxy_servers(); + $rows = get_proxy_servers(true); foreach ($rows as $row) { $servers_to_exec[$row['id_server']] = $row['name']; } diff --git a/pandora_console/godmode/agentes/agent_wizard.snmp_interfaces_explorer.php b/pandora_console/godmode/agentes/agent_wizard.snmp_interfaces_explorer.php index 80c5a3a84f..13dfd94ad2 100644 --- a/pandora_console/godmode/agentes/agent_wizard.snmp_interfaces_explorer.php +++ b/pandora_console/godmode/agentes/agent_wizard.snmp_interfaces_explorer.php @@ -254,6 +254,30 @@ if ($create_modules) { $values['unit'] = "Bytes"; } + if ($server_to_exec != 0) { + $sql = sprintf("SELECT server_type FROM tserver WHERE id_server = %d", $server_to_exec); + $row = db_get_row_sql ($sql); + + if ($row['server_type'] = 13) { + if (preg_match ("/Status/", $name_array[1])) { + $module_type = 2; + } + elseif (preg_match ("/Present/", $name_array[1])) { + $module_type = 2; + } + elseif (preg_match("/PromiscuousMode/", $name_array[1])) { + $module_type = 2; + } + // Specific counters (ends in s) + elseif (preg_match("/s$/", $name_array[1])) { + $module_type = 4; + } + else { + $module_type = 4; + } + } + } + $values['id_tipo_modulo'] = $module_type; if (!empty($ifPhysAddress) && isset($interfaces_ip[$id])) { @@ -281,6 +305,26 @@ if ($create_modules) { $errors[$result]++; } else { + if ($server_to_exec != 0) { + $sql = sprintf("SELECT server_type FROM tserver WHERE id_server = %d", $server_to_exec); + $row = db_get_row_sql ($sql); + + if ($row['server_type'] = 13) { + $module_type_name = db_get_value_filter("nombre", "ttipo_modulo", array("id_tipo" => $values['id_tipo_modulo'])); + + $new_module_configuration_data = " + module_begin + module_name " . io_safe_input($name) . " + module_description " . $values['descripcion'] . " + module_type " . $module_type_name . " + module_snmp + module_oid " . $values['snmp_oid'] . " + module_community " . $values['snmp_community'] . " + module_end"; + + config_agents_add_module_in_conf($id_agent, $new_module_configuration_data); + } + } $done++; } } @@ -445,6 +489,7 @@ if (!empty($interfaces_list)) { html_print_input_hidden('snmp3_privacy_method', $snmp3_privacy_method); html_print_input_hidden('snmp3_privacy_pass', $snmp3_privacy_pass); html_print_input_hidden('snmp3_security_level', $snmp3_security_level); + html_print_input_hidden('server_to_exec', $server_to_exec); $table->width = '100%'; diff --git a/pandora_console/godmode/agentes/agent_wizard.wmi_explorer.php b/pandora_console/godmode/agentes/agent_wizard.wmi_explorer.php index abdcbbecaa..135709c17b 100644 --- a/pandora_console/godmode/agentes/agent_wizard.wmi_explorer.php +++ b/pandora_console/godmode/agentes/agent_wizard.wmi_explorer.php @@ -29,7 +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); +$server_to_exec = get_parameter('server_to_exec', 0); //See if id_agente is set (either POST or GET, otherwise -1 $id_agent = $idAgent; @@ -202,16 +202,16 @@ if ($create_modules) { $services_values['snmp_community'] = 'Running'; // Key string $services_values['tcp_port'] = 1; // Field number (Running/Stopped) $services_values['id_tipo_modulo'] = 2; // Generic boolean - - $services_result = wmi_create_wizard_modules($id_agent, $services, 'services', $services_values); - + + $services_result = wmi_create_wizard_modules($id_agent, $services, 'services', $services_values, 0, 0, $server_to_exec); + // Create Process modules $processes_values = $values; $processes_values['tcp_port'] = 0; // Field number (OID) $processes_values['id_tipo_modulo'] = 2; // Generic boolean - $processes_result = wmi_create_wizard_modules($id_agent, $processes, 'processes', $processes_values); + $processes_result = wmi_create_wizard_modules($id_agent, $processes, 'processes', $processes_values, 0, 0, $server_to_exec); // Create Space on disk modules $disks_values = $values; @@ -220,14 +220,14 @@ if ($create_modules) { $disks_values['id_tipo_modulo'] = 1; // Generic numeric $disks_values['unit'] = 'Bytes'; // Unit - $disks_result = wmi_create_wizard_modules($id_agent, $disks, 'disks', $disks_values); + $disks_result = wmi_create_wizard_modules($id_agent, $disks, 'disks', $disks_values, 0, 0, $server_to_exec); // Create modules from component $components_values = $values; $components_values['id_agente'] = $id_agent; - $components_result = wmi_create_module_from_components($components, $components_values); + $components_result = wmi_create_module_from_components($components, $components_values, 0, 0, $server_to_exec); // Errors/Success messages @@ -339,6 +339,7 @@ if ($wmiexplore && !$fail) { html_print_input_hidden('plugin_user', $plugin_user); // User html_print_input_hidden('plugin_pass', $plugin_pass); // Password html_print_input_hidden('tcp_send', $tcp_send); // Namespace + html_print_input_hidden('server_to_exec', $server_to_exec); $table->width = '98%'; diff --git a/pandora_console/godmode/servers/modificar_server.php b/pandora_console/godmode/servers/modificar_server.php index e412acbb9c..2a45ce650e 100644 --- a/pandora_console/godmode/servers/modificar_server.php +++ b/pandora_console/godmode/servers/modificar_server.php @@ -58,7 +58,7 @@ if (isset($_GET["server"])) { if (enterprise_installed()) { $table->data[] = array (__('Type'), $server_type); - if ($row["server_type"] == 13) { + if ($row["server_type"] == 13 || $row["server_type"] == 1) { $table->data[] = array (__('Exec Server'), html_print_checkbox ("exec_proxy", 1, $row["exec_proxy"], true)); if ($row["exec_proxy"]) { $table->data[] = array (__('Check Exec Server'), '' . html_print_image ("images/dot_red.disabled.png", true) . '' . '
'); diff --git a/pandora_console/include/functions_wmi.php b/pandora_console/include/functions_wmi.php index 0c7929e715..685c81b17d 100644 --- a/pandora_console/include/functions_wmi.php +++ b/pandora_console/include/functions_wmi.php @@ -50,7 +50,7 @@ function wmi_compose_query($wmi_client, $user, $password, $host, $namespace = '' } -function wmi_create_wizard_modules($id_agent, $names, $wizard_mode, $values, $id_police=0, $module_id=0) { +function wmi_create_wizard_modules($id_agent, $names, $wizard_mode, $values, $id_police=0, $module_id=0, $server_to_exec = 0) { $results = array(ERR_GENERIC => array(), NOERR => array()); if (empty($names)) { @@ -84,6 +84,32 @@ function wmi_create_wizard_modules($id_agent, $names, $wizard_mode, $values, $id $results[ERR_GENERIC][] = $name; } else { + if ($id_police == 0) { + if ($server_to_exec != 0) { + $sql = sprintf("SELECT server_type FROM tserver WHERE id_server = %d", $server_to_exec); + $row = db_get_row_sql ($sql); + + if ($row['server_type'] = 13) { + $new_module_configuration_data = " + module_begin + module_name " . $name . " + module_description + module_type generic_proc + module_snmp + module_oid " . $values['snmp_oid'] . " + module_community " . $values['snmp_community'] . " + ip_target " . $nc['ip_target'] ." + tcp_send " . $nc['tcp_send'] ." + plugin_user " . $nc['plugin_user'] ." + plugin_pass " . $nc['plugin_pass'] ." + tcp_port " . $nc['tcp_port'] . " + module_end"; + + config_agents_add_module_in_conf($id_agent, $new_module_configuration_data); + } + } + } + $results[NOERR][] = $name; } } @@ -91,7 +117,7 @@ function wmi_create_wizard_modules($id_agent, $names, $wizard_mode, $values, $id return $results; } -function wmi_create_module_from_components($components, $values, $id_police=0, $module_id=0) { +function wmi_create_module_from_components($components, $values, $id_police=0, $module_id=0, $server_to_exec = 0) { $results = array(ERR_GENERIC => array(), NOERR => array(), ERR_EXIST => array()); if (empty($components)) { @@ -155,6 +181,30 @@ function wmi_create_module_from_components($components, $values, $id_police=0, $ $results[ERR_GENERIC][] = $nc["nombre"]; } else { + if ($id_police == 0) { + if ($server_to_exec != 0) { + $sql = sprintf("SELECT server_type FROM tserver WHERE id_server = %d", $server_to_exec); + $row = db_get_row_sql ($sql); + + if ($row['server_type'] = 13) { + $new_module_configuration_data = " + module_begin + module_name " . $nc["nombre"] . " + module_description " . $nc['descripcion'] . " + module_type generic_data + ip_target " . $nc['ip_target'] ." + tcp_send " . $nc['tcp_send'] ." + plugin_user " . $nc['plugin_user'] ." + plugin_pass " . $nc['plugin_pass'] ." + unit Bytes + tcp_port 1 + module_end"; + + config_agents_add_module_in_conf($nc["id_agente"], $new_module_configuration_data); + } + } + } + if(!empty($tags)) { // Creating tags $tag_ids = array();