From 80108d54e6e7cd61402e279dc698a0256b3c1c66 Mon Sep 17 00:00:00 2001 From: Esteban Sanchez Date: Mon, 13 Apr 2009 15:05:21 +0000 Subject: [PATCH] 2009-04-13 Esteban Sanchez * godmode/agentes/agent_manager.php: Fixed an error when an agent was created without name. Added support for new server assignment via server name instead of lot of comboboxes. Added os preview. * godmode/agentes/configurar_agente.php: Added support for new server assignment via server name. Do not show tabs on creation mode. Some translatable strings replaced with common ones. * godmode/agentes/modificar_agente.php: Use Pandora agents. * godmode/modules/manage_nc_groups.php, godmode/setup/news.php, godmode/modules/manage_network_components.php, godmode/reporting/map_builder.php, godmode/agentes/planned_downtime.php: Some translatable strings replaced with common ones. * godmode/servers/modificar_server.php: Updated to changes in tserver. Use get_server_info() for that. * include/functions_db.php: Updated to changes in tserver about server_type field on get_server_info(). Style correction. * include/functions_servers.php: Added to repository. Servers API. * operation/servers/view_server.php: Style correction. * extras/pandoradb_migrate_v2.x_to_v3.0.sql, pandoradb.sql: Less space on server_name field on tagente. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1615 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 36 ++- .../extras/pandoradb_migrate_v2.x_to_v3.0.sql | 2 +- .../godmode/agentes/agent_manager.php | 113 +++++----- .../godmode/agentes/configurar_agente.php | 212 ++++++++++-------- .../godmode/agentes/planned_downtime.php | 4 +- .../godmode/modules/manage_nc_groups.php | 4 +- .../modules/manage_network_components.php | 4 +- .../godmode/reporting/map_builder.php | 8 +- .../godmode/servers/modificar_server.php | 78 +++---- pandora_console/godmode/setup/news.php | 4 +- pandora_console/include/functions_db.php | 140 +++++++----- pandora_console/include/functions_servers.php | 56 +++++ .../operation/servers/view_server.php | 12 +- pandora_console/pandoradb.sql | 2 +- 14 files changed, 400 insertions(+), 275 deletions(-) create mode 100644 pandora_console/include/functions_servers.php diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index a23455cac6..6f4427de83 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,8 +1,40 @@ -2009-04-13 Sancho Lerena +2009-04-13 Esteban Sanchez + + * godmode/agentes/agent_manager.php: Fixed an error when an agent was + created without name. Added support for new server assignment via server + name instead of lot of comboboxes. Added os preview. + + * godmode/agentes/configurar_agente.php: Added support for new server + assignment via server name. Do not show tabs on creation mode. Some + translatable strings replaced with common ones. + + * godmode/agentes/modificar_agente.php: Use Pandora agents. + + * godmode/modules/manage_nc_groups.php, + godmode/setup/news.php, + godmode/modules/manage_network_components.php, + godmode/reporting/map_builder.php, + godmode/agentes/planned_downtime.php: Some translatable strings replaced + with common ones. + + * godmode/servers/modificar_server.php: Updated to changes in tserver. Use + get_server_info() for that. + + * include/functions_db.php: Updated to changes in tserver about + server_type field on get_server_info(). Style correction. + + * include/functions_servers.php: Added to repository. Servers API. + + * operation/servers/view_server.php: Style correction. + + * extras/pandoradb_migrate_v2.x_to_v3.0.sql, pandoradb.sql: Less space on + server_name field on tagente. + +2009-04-13 Sancho Lerena * images/console/icons/server_warning.png: Added missing icon. -2009-04-13 +2009-04-13 Jorge Gonzalez * images/console/icons/smalldot.png: Modified icon for the maps. diff --git a/pandora_console/extras/pandoradb_migrate_v2.x_to_v3.0.sql b/pandora_console/extras/pandoradb_migrate_v2.x_to_v3.0.sql index 77b10e5fb6..91ffa6ad39 100644 --- a/pandora_console/extras/pandoradb_migrate_v2.x_to_v3.0.sql +++ b/pandora_console/extras/pandoradb_migrate_v2.x_to_v3.0.sql @@ -289,7 +289,7 @@ ALTER TABLE `tmensajes` CHANGE `timestamp` `timestamp` BIGINT( 20 ) UNSIGNED ALTER TABLE `tevento` CHANGE `event_type` `event_type` ENUM( 'unknown', 'alert_fired', 'alert_recovered', 'alert_ceased', 'alert_manual_validation', 'recon_host_detected', 'system', 'error', 'new_agent', 'going_up_warning', 'going_up_critical', 'going_down_warning', 'going_down_normal', 'going_down_critical', 'going_up_normal' ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT 'unknown'; -ALTER TABLE tagente ADD `server_name` varchar(255) default ''; +ALTER TABLE tagente ADD `server_name` varchar(100) default ''; ALTER TABLE tevento ADD `user_comment` varchar(255) NOT NULL default ''; ALTER TABLE tusuario ADD `language` varchar(10) default NULL; ALTER TABLE tserver ADD `server_type` tinyint(3) unsigned NOT NULL default '0'; diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index 6fd4123234..6bddf821ae 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -19,42 +19,45 @@ // Load global vars enterprise_include ('godmode/agentes/agent_manager.php'); -if (!isset ($id_agente)) { +require_once ('include/functions_servers.php'); + +$new_agent = (bool) get_parameter ('new_agent'); + +if (! isset ($id_agente) && ! $new_agent) { audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation", "Trying to access agent manager witout an agent"); require ("general/noaccess.php"); - exit; + return; } -// ======================== -// AGENT GENERAL DATA FORM -// ======================== +echo "

".__('Agent configuration')." » "; -echo "

".__('Agent configuration'); -$new_agent = (bool) get_parameter ('new_agent'); -if ($new_agent) { - echo " » ".__('Create agent'); +if ($id_agente) { + echo __('Update agent'); } else { - echo " » ".__('Update agent'); + echo __('Create agent'); } echo "

"; echo '
 
'; // Agent remote configuration editor $agent_md5 = md5 ($nombre_agente, false); -$filename['md5'] = $config["remote_config"] . "/" . $agent_md5 . ".md5"; -$filename['conf'] = $config["remote_config"] . "/" . $agent_md5 . ".conf"; +$filename['md5'] = $config["remote_config"]."/".$agent_md5.".md5"; +$filename['conf'] = $config["remote_config"]."/".$agent_md5.".conf"; -if (isset ($_GET["disk_conf"])) { +$disk_conf = (bool) get_parameter ('disk_conf'); + +if ($disk_conf) { require ("agent_disk_conf_editor.php"); - exit; + return; } +$disk_conf_delete = (bool) get_parameter ('disk_conf_delete'); // Agent remote configuration DELETE -if (isset($_GET["disk_conf_delete"])) { +if ($disk_conf_delete) { //TODO: Get this working on computers where the Pandora server(s) are not on the webserver //TODO: Get a remote_config editor working in the open version - unlink ($filename['md5']); - unlink ($filename['conf']); + @unlink ($filename['md5']); + @unlink ($filename['conf']); } echo '
'; @@ -70,7 +73,7 @@ $table->data = array (); $table->data[0][0] = __('Agent name').print_help_tip (__("The agent's name must be the same as the one defined at the console"), true); $table->data[0][1] = print_input_text ('agente', $nombre_agente, '', 30, 100,true); -if (isset ($id_agente) && $id_agente != "") { +if ($id_agente) { $table->data[0][1] .= ''; $table->data[0][1] .= print_image ("images/lupa.png", true, array ("border" => 0, "title" => __('Agent detail'))); $table->data[0][1] .= ''; @@ -86,7 +89,7 @@ if (file_exists ($filename['md5'])) { $table->data[1][0] = __('IP Address'); $table->data[1][1] = print_input_text ('direccion', $direccion_agente, '', 16, 100, true); -if (! $new_agent) { +if ($id_agente) { $table->data[1][1] .= '    '; $ip_all = get_agent_addresses ($id_agente); @@ -108,67 +111,67 @@ $table->data[4][0] = __('Interval'); $table->data[4][1] = print_input_text ('intervalo', $intervalo, '', 16, 100, true); $table->data[5][0] = __('OS'); -$table->data[5][1] = print_select_from_sql ('SELECT id_os, name FROM tconfig_os ORDER BY name', 'id_os', $id_os, '', '', '0', true); +$table->data[5][1] = print_select_from_sql ('SELECT id_os, name FROM tconfig_os', + 'id_os', $id_os, '', '', '0', true); +$table->data[5][1] .= ' '; +$table->data[5][1] .= print_os_icon ($id_os, false, true); +$table->data[5][1] .= ''; // Network server -$table->data[6][0] = __('Network Server').print_help_tip (__('You must select a Network Server for the Agent, so it can work properly with this kind of modules'), true); -$table->data[6][1] = print_select_from_sql ('SELECT id_server, name FROM tserver WHERE network_server = 1 ORDER BY name', 'network_server', $id_network_server, '', '', 0, true); -// Plugin server -$table->data[7][0] = __('Plugin Server').print_help_tip (__('You must select a Plugin Server for the Agent, so it can work properly with this kind of modules'), true); -$table->data[7][1] = print_select_from_sql ('SELECT id_server, name FROM tserver WHERE plugin_server = 1 ORDER BY name', 'plugin_server', $id_plugin_server, '', '', 0, true); - -// WMI Server -$table->data[8][0] = __('WMI Server').print_help_tip (__('You must select a WMI Server for the Agent, so it can work properly with this kind of modules'), true); -$table->data[8][1] = print_select_from_sql ('SELECT id_server, name FROM tserver WHERE wmi_server = 1 ORDER BY name', 'wmi_server', $id_wmi_server, '', '', 0, true); - -// Prediction Server -$table->data[9][0] = __('Prediction Server').print_help_tip (__('You must select a Prediction Server for the Agent, so it can work properly with this kind of modules'), true); -$table->data[9][1] = print_select_from_sql ('SELECT id_server, name FROM tserver WHERE prediction_server = 1 ORDER BY name', 'prediction_server', $id_prediction_server, '', '', 0, true); - -// 10 -enterprise_hook ('inventory_server'); +$table->data[6][0] = __('Server'); +$table->data[6][1] = print_select (get_server_names (), + 'server_name', $server_name, '', '', 0, true); // Custom ID -$table->data[11][0] = __('Custom ID'); -$table->data[11][1] = print_input_text ('custom_id', $custom_id, '', 16, 255, true); +$table->data[7][0] = __('Custom ID'); +$table->data[7][1] = print_input_text ('custom_id', $custom_id, '', 16, 255, true); // Description -$table->data[12][0] = __('Description'); -$table->data[12][1] = print_input_text ('comentarios', $comentarios, '', 45, 255, true); +$table->data[8][0] = __('Description'); +$table->data[8][1] = print_input_text ('comentarios', $comentarios, '', 45, 255, true); // Learn mode / Normal mode -$table->data[13][0] = __('Module definition').print_help_icon("module_definition", true); -$table->data[13][1] = __('Learning mode').' '.print_radio_button_extended ("modo", 1, '', $modo, false, '', 'style="margin-right: 40px;"', true); -$table->data[13][1] .= __('Normal mode').' '.print_radio_button_extended ("modo", 0, '', $modo, false, '', 'style="margin-right: 40px;"', true); +$table->data[9][0] = __('Module definition').print_help_icon("module_definition", true); +$table->data[9][1] = __('Learning mode').' '.print_radio_button_extended ("modo", 1, '', $modo, false, '', 'style="margin-right: 40px;"', true); +$table->data[9][1] .= __('Normal mode').' '.print_radio_button_extended ("modo", 0, '', $modo, false, '', 'style="margin-right: 40px;"', true); // Status (Disabled / Enabled) -$table->data[14][0] = __('Status'); -$table->data[14][1] = __('Disabled').' '.print_radio_button_extended ("disabled", 1, '', $disabled, false, '', 'style="margin-right: 40px;"', true); -$table->data[14][1] .= __('Active').' '.print_radio_button_extended ("disabled", 0, '', $disabled, false, '', 'style="margin-right: 40px;"', true); +$table->data[10][0] = __('Status'); +$table->data[10][1] = __('Disabled').' '.print_radio_button_extended ("disabled", 1, '', $disabled, false, '', 'style="margin-right: 40px;"', true); +$table->data[10][1] .= __('Active').' '.print_radio_button_extended ("disabled", 0, '', $disabled, false, '', 'style="margin-right: 40px;"', true); // Remote configuration -$table->data[15][0] = __('Remote configuration'); +$table->data[11][0] = __('Remote configuration'); if (file_exists ($filename['md5'])) { - $table->data[15][1] = date ("F d Y H:i:s.", fileatime ($filename['md5'])); + $table->data[11][1] = date ("F d Y H:i:s", fileatime ($filename['md5'])); // Delete remote configuration - $table->data[15][1] .= ''; - $table->data[15][1] .= print_image ("images/cross.png", true).''; + $table->data[11][1] .= ''; + $table->data[11][1] .= print_image ("images/cross.png", true).''; } else { - $table->data[15][1] = ''.__('Not available').''; + $table->data[11][1] = ''.__('Not available').''; } print_table ($table); echo '
'; -if ($new_agent) { - print_submit_button (__('Create'), 'crtbutton', false, 'class="sub wand"'); - print_input_hidden ('create_agent', 1); -} else { +if ($id_agente) { print_submit_button (__('Update'), 'updbutton', false, 'class="sub upd"'); print_input_hidden ('update_agent', 1); print_input_hidden ('id_agente', $id_agente); +} else { + print_submit_button (__('Create'), 'crtbutton', false, 'class="sub wand"'); + print_input_hidden ('create_agent', 1); } echo '
'; + +require_jquery_file ('pandora.controls'); ?> + diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index d000b06b3b..6d3bb92850 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -24,9 +24,10 @@ enterprise_include ('godmode/agentes/configurar_agente.php'); check_login (); //See if id_agente is set (either POST or GET, otherwise -1 -$id_agente = (int) get_parameter ("id_agente", -1); - -$group = get_agent_group ($id_agente); +$id_agente = (int) get_parameter ("id_agente"); +$group = 0; +if ($id_agente) + $group = get_agent_group ($id_agente); if (! give_acl ($config["id_user"], $group, "AW")) { audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation", @@ -98,12 +99,9 @@ $alert_d6 = 1; $alert_d7 = 1; $alert_recovery = 0; $alert_priority = 0; -$id_network_server = 0; -$id_plugin_server = 0; -$id_prediction_server = 0; -$id_wmi_server = 0; +$server_name = ''; $grupo = 0; -$id_os = 0; +$id_os = 9; // Windows $custom_id = ""; $create_agent = (bool) get_parameter ('create_agent'); @@ -117,10 +115,7 @@ if ($create_agent) { $comentarios = (string)get_parameter_post ("comentarios"); $modo = (int) get_parameter_post ("modo"); $id_parent = (int) get_parameter_post ("id_parent"); - $id_network_server = (int) get_parameter_post ("network_server"); - $id_plugin_server = (int) get_parameter_post ("plugin_server"); - $id_prediction_server = (int) get_parameter_post ("prediction_server"); - $id_wmi_server = (int) get_parameter_post ("wmi_server"); + $server_name = (string) get_parameter_post ("server_name"); $id_os = (int) get_parameter_post ("id_os"); $disabled = (int) get_parameter_post ("disabled"); $custom_id = (string) get_parameter_post ("custom_id"); @@ -139,10 +134,7 @@ if ($create_agent) { 'id_grupo' => $grupo, 'intervalo' => $intervalo, 'comentarios' => $comentarios, 'modo' => $modo, 'id_os' => $id_os, 'disabled' => $disabled, - 'id_network_server' => $id_network_server, - 'id_plugin_server' => $id_plugin_server, - 'id_wmi_server' => $id_wmi_server, - 'id_prediction_server' => $id_prediction_server, + 'server_name' => $server_name, 'id_parent' => $id_parent, 'custom_id' => $custom_id)); enterprise_hook ('update_agent', array ($id_agente)); if ($id_agente !== false) { @@ -180,8 +172,8 @@ if ($create_agent) { $agent_created_ok = false; } } else { - $id_agente = -1; - $agent_creation_error = __("There was a problem creating the agent"); + $id_agente = 0; + $agent_creation_error = __('Could not be created'); } } } @@ -189,50 +181,52 @@ if ($create_agent) { // Show tabs $img_style = array ("class" => "top", "width" => 16); -echo '"; + + // Make some space between tabs and title + // IE might not always show an empty div, added space + echo '
 
'; +} // Show agent creation results if ($create_agent) { print_result_message ($agent_created_ok, - __('Agent successfully created'), - __('There was a problem creating the agent')); + __('Successfully created'), + __('Could not be created')); } // Fix / Normalize module data @@ -261,7 +255,7 @@ if (isset($_GET["fix_module"])){ // Update AGENT // ================ if (isset($_POST["update_agent"])) { // if modified some agent paramenter - $id_agente = (int) get_parameter_post ("id_agente", 0); + $id_agente = (int) get_parameter_post ("id_agente"); $nombre_agente = (string) get_parameter_post ("agente"); $direccion_agente = (string) get_parameter_post ("direccion"); $address_list = (string) get_parameter_post ("address_list"); @@ -278,10 +272,7 @@ if (isset($_POST["update_agent"])) { // if modified some agent paramenter $modo = (bool) get_parameter_post ("modo", 0); //Mode: Learning or Normal $id_os = (int) get_parameter_post ("id_os"); $disabled = (bool) get_parameter_post ("disabled"); - $id_network_server = (int) get_parameter_post ("network_server", 0); - $id_plugin_server = (int) get_parameter_post ("plugin_server", 0); - $id_wmi_server = (int) get_parameter_post ("wmi_server", 0); - $id_prediction_server = (int) get_parameter_post ("prediction_server", 0); + $server_name = (string) get_parameter_post ("server_name"); $id_parent = (int) get_parameter_post ("id_parent", 0); $custom_id = (string) get_parameter_post ("custom_id", ""); @@ -302,18 +293,19 @@ if (isset($_POST["update_agent"])) { // if modified some agent paramenter agent_delete_address ($id_agente, $delete_ip); } - //Now update the thing - $sql = sprintf ("UPDATE tagente - SET disabled = %d, id_parent = %d, id_os = %d, modo = %d, - nombre = '%s', direccion = '%s', id_grupo = %d, - intervalo = %d, comentarios = '%s', id_network_server = %d, - id_plugin_server = %d, id_wmi_server = %d, id_prediction_server = %d, - custom_id = '%s' WHERE id_agente = %d", - $disabled, $id_parent, $id_os, $modo, $nombre_agente, - $direccion_agente, $grupo, $intervalo, $comentarios, - $id_network_server, $id_plugin_server, $id_wmi_server, - $id_prediction_server, $custom_id, $id_agente); - $result = process_sql ($sql); + $result = process_sql_update ('tagente', + array ('disabled' => $disabled, + 'id_parent' => $id_parent, + 'id_os' => $id_os, + 'modo' => $modo, + 'nombre' => $nombre_agente, + 'direccion' => $direccion_agente, + 'id_grupo' => $grupo, + 'intervalo' => $intervalo, + 'comentarios' => $comentarios, + 'server_name' => $server_name, + 'custom_id' => $custom_id), + array ('id_agente' => $id_agente)); if ($result === false) { echo '

'.__('There was a problem updating agent').'

'; } else { @@ -325,7 +317,7 @@ if (isset($_POST["update_agent"])) { // if modified some agent paramenter // Read agent data // This should be at the end of all operation checks, to read the changes - $id_agente doesn't have to be retrieved -if ($id_agente > 0) { +if ($id_agente) { //This has been done in the beginning of the page, but if an agent was created, this id might change $id_grupo = get_agent_group ($id_agente); if (give_acl ($config["id_user"], $id_grupo, "AW") != 1) { @@ -347,10 +339,7 @@ if ($id_agente > 0) { $grupo = $agent["id_grupo"]; $ultima_act = $agent["ultimo_contacto"]; $comentarios = $agent["comentarios"]; - $id_plugin_server = $agent["id_plugin_server"]; - $id_network_server = $agent["id_network_server"]; - $id_prediction_server = $agent["id_prediction_server"]; - $id_wmi_server = $agent["id_wmi_server"]; + $server_name = $agent["server_name"]; $modo = $agent["modo"]; $id_os = $agent["id_os"]; $disabled = $agent["disabled"]; @@ -415,20 +404,33 @@ if ($update_module) { $result = process_sql_update ('tagente_modulo', array ('descripcion' => $description, - 'id_module_group' => $id_module_group, 'nombre' => $name, - 'max' => $maxvalue, 'min' => $minvalue, 'module_interval' => $interval, - 'tcp_port' => $tcp_port, 'tcp_send' => $tcp_send, - 'tcp_rcv' => $tcp_rcv, 'snmp_community' => $snmp_community, - 'snmp_oid' => $snmp_oid, 'ip_target' => $ip_target, - 'flag' => $flag, 'disabled' => $disabled, - 'id_export' => $id_export, 'plugin_user' => $plugin_user, - 'plugin_pass' => $plugin_pass, 'plugin_parameter' => $plugin_parameter, - 'id_plugin' => $id_plugin, 'post_process' => $post_process, + 'id_module_group' => $id_module_group, + 'nombre' => $name, + 'max' => $maxvalue, + 'min' => $minvalue, + 'module_interval' => $interval, + 'tcp_port' => $tcp_port, + 'tcp_send' => $tcp_send, + 'tcp_rcv' => $tcp_rcv, + 'snmp_community' => $snmp_community, + 'snmp_oid' => $snmp_oid, + 'ip_target' => $ip_target, + 'flag' => $flag, + 'disabled' => $disabled, + 'id_export' => $id_export, + 'plugin_user' => $plugin_user, + 'plugin_pass' => $plugin_pass, + 'plugin_parameter' => $plugin_parameter, + 'id_plugin' => $id_plugin, + 'post_process' => $post_process, 'prediction_module' => $prediction_module, - 'max_timeout' => $max_timeout, 'custom_id' => $custom_id, + 'max_timeout' => $max_timeout, + 'custom_id' => $custom_id, 'history_data' => $history_data, - 'min_warning' => $min_warning, 'max_warning' => $max_warning, - 'min_critical' => $min_critical, 'max_critical' => $max_critical, + 'min_warning' => $min_warning, + 'max_warning' => $max_warning, + 'min_critical' => $min_critical, + 'max_critical' => $max_critical, 'min_ff_event' => $ff_event ), 'id_agente_modulo = '.$id_agent_module); @@ -456,21 +458,35 @@ if ($create_module) { $id_agent_module = process_sql_insert ('tagente_modulo', array ('id_agente' => $id_agente, 'id_tipo_modulo' => $id_module_type, - 'nombre' => $name, 'descripcion' => $description, 'max' => $maxvalue, - 'min' => $minvalue, 'snmp_oid' => $snmp_oid, + 'nombre' => $name, + 'descripcion' => $description, + 'max' => $maxvalue, + 'min' => $minvalue, + 'snmp_oid' => $snmp_oid, 'snmp_community' => $snmp_community, - 'id_module_group' => $id_module_group, 'module_interval' => $interval, - 'ip_target' => $ip_target, 'tcp_port' => $tcp_port, - 'tcp_rcv' => $tcp_rcv, 'tcp_send' => $tcp_send, - 'id_export' => $id_export, 'plugin_user' => $plugin_user, - 'plugin_pass' => $plugin_pass, 'plugin_parameter' => $plugin_parameter, - 'id_plugin' => $id_plugin, 'post_process' => $post_process, + 'id_module_group' => $id_module_group, + 'module_interval' => $interval, + 'ip_target' => $ip_target, + 'tcp_port' => $tcp_port, + 'tcp_rcv' => $tcp_rcv, + 'tcp_send' => $tcp_send, + 'id_export' => $id_export, + 'plugin_user' => $plugin_user, + 'plugin_pass' => $plugin_pass, + 'plugin_parameter' => $plugin_parameter, + 'id_plugin' => $id_plugin, + 'post_process' => $post_process, 'prediction_module' => $id_prediction_module, - 'max_timeout' => $max_timeout, 'disabled' => $disabled, - 'id_modulo' => $id_module, 'custom_id' => $custom_id, - 'history_data' => $history_data, 'min_warning' => $min_warning, - 'max_warning' => $max_warning, 'min_critical' => $min_critical, - 'max_critical' => $max_critical, 'min_ff_event' => $ff_event + 'max_timeout' => $max_timeout, + 'disabled' => $disabled, + 'id_modulo' => $id_module, + 'custom_id' => $custom_id, + 'history_data' => $history_data, + 'min_warning' => $min_warning, + 'max_warning' => $max_warning, + 'min_critical' => $min_critical, + 'max_critical' => $max_critical, + 'min_ff_event' => $ff_event )); if ($id_agent_module === false) { diff --git a/pandora_console/godmode/agentes/planned_downtime.php b/pandora_console/godmode/agentes/planned_downtime.php index d02684c557..3af29beee5 100644 --- a/pandora_console/godmode/agentes/planned_downtime.php +++ b/pandora_console/godmode/agentes/planned_downtime.php @@ -113,9 +113,9 @@ if ($create_downtime || $update_downtime) { $result = process_sql ($sql); if ($result === false) { - echo '

'.__('Not created. Error inserting data').'

'; + echo '

'.__('Could not be created').'

'; } else { - echo '

'.__('Created successfully').'

'; + echo '

'.__('Successfully created').'

'; } } } diff --git a/pandora_console/godmode/modules/manage_nc_groups.php b/pandora_console/godmode/modules/manage_nc_groups.php index a58d2fc3d9..4e2e561ce6 100644 --- a/pandora_console/godmode/modules/manage_nc_groups.php +++ b/pandora_console/godmode/modules/manage_nc_groups.php @@ -42,8 +42,8 @@ if ($create) { array ('name' => $name, 'parent' => $parent)); print_result_message ($result, - __('Created successfully'), - __('Not created. Error inserting data')); + __('Successfully created'), + __('Could not be created')); } if ($update) { diff --git a/pandora_console/godmode/modules/manage_network_components.php b/pandora_console/godmode/modules/manage_network_components.php index bb79b286fa..ac3f4c40af 100644 --- a/pandora_console/godmode/modules/manage_network_components.php +++ b/pandora_console/godmode/modules/manage_network_components.php @@ -73,9 +73,9 @@ if (isset($_GET["create"])){ // Create module $id_module = process_sql ($sql, 'insert_id'); if ($id_module === false) - echo "

".__('Not created. Error inserting data')."

"; + echo "

".__('Could not be created')."

"; else { - echo "

".__('Created successfully')."

"; + echo "

".__('Successfully created')."

"; } } diff --git a/pandora_console/godmode/reporting/map_builder.php b/pandora_console/godmode/reporting/map_builder.php index 343e5d2d78..65f13596f4 100644 --- a/pandora_console/godmode/reporting/map_builder.php +++ b/pandora_console/godmode/reporting/map_builder.php @@ -66,9 +66,9 @@ if ($create_layout) { $id_layout = process_sql_insert ('tlayout', $values); if ($id_layout !== false) { - echo '

'.__('Created successfully').'

'; + echo '

'.__('Successfully ').'

'; } else { - echo '

'.__('Not created. Error inserting data').'

'; + echo '

'.__('Could not be created').'

'; } if (is_ajax ()) { exit; @@ -172,9 +172,9 @@ if ($create_layout_data) { $result = process_sql_insert ('tlayout_data', $values); if ($result !== false) { - echo '

'.__('Created successfully').'

'; + echo '

'.__('Successfully created').'

'; } else { - echo '

'.__('Not created. Error inserting data').'

'; + echo '

'.__('Could not be created').'

'; } if (is_ajax ()) { exit; diff --git a/pandora_console/godmode/servers/modificar_server.php b/pandora_console/godmode/servers/modificar_server.php index 55db2b3f33..5e92fa2073 100644 --- a/pandora_console/godmode/servers/modificar_server.php +++ b/pandora_console/godmode/servers/modificar_server.php @@ -75,52 +75,53 @@ if (isset($_GET["server"])) { echo ""; } else { - $result = get_db_all_rows_in_table ("tserver"); + $servers = get_server_info (); echo "

".__('Pandora servers')." » ".__('Manage servers')."

"; if ($result !== false) { - $table->cellpadding = 4; - $table->cellspacing = 4; $table->width = "90%"; $table->class = "databox"; - $table->align = array ('',"center","center","center","center","center","center","center"); - $table->head = array (__('Name'),__('Status'),__('Description'),__('Type'),__('Started'),__('Updated'),__('Delete')); + $table->data = array (); - foreach ($result as $row) { - $server = ""; - if($row["network_server"] == 1) { - $server .= ' '; - } - if ($row["data_server"] == 1) { - $server .= ' '; - } - if ($row["snmp_server"] == 1) { - $server .= ' '; - } - if ($row["master"] == 1) { - $server .= ' '; - } - if ($row["checksum"] == 1) { - $server .= ' '; - } - - - if ($row['status'] == 0) { - $server_status = print_status_image(STATUS_SERVER_DOWN, '', true); + $table->align = array (); + $table->align[1] = "center"; + $table->align[2] = "center"; + $table->align[3] = "center"; + $table->align[4] = "center"; + $table->align[5] = "center"; + $table->align[6] = "center"; + $table->align[7] = "center"; + $table->style = array (); + $table->style[0] = 'font-weight: bold'; + $table->head = array (); + $table->head[0] = __('Name'); + $table->head[1] = __('Status'); + $table->head[2] = __('Description'); + $table->head[3] = __('Type'); + $table->head[4] = __('Started'); + $table->head[5] = __('Updated'); + $table->head[6] = __('Delete'); + + foreach ($servers as $server) { + if ($server['status'] == 0) { + $server_status = print_status_image (STATUS_SERVER_DOWN, '', true); } else { - $server_status = print_status_image(STATUS_SERVER_OK, '', true); + $server_status = print_status_image (STATUS_SERVER_OK, '', true); } - - $table->data[] = array ( - ''.$row["name"].'', - $server_status, - substr($row["description"],0,25), - $server, - human_time_comparation ($row["laststart"]), - human_time_comparation ($row["keepalive"]), - '' - ); - + + $data = array (); + + $data[0] = ''.$server["name"].''; + $data[1] = $server_status; + $data[2] = substr ($server["description"], 0, 25); + $data[3] = $server['img']; + $data[4] = human_time_comparation ($server["laststart"]); + $data[5] = human_time_comparation ($server["keepalive"]); + $data[6] = ''; + $data[6] .= print_image ('images/cross.png', true, array ('title' => __('Delete'))); + $data[6] .= ''; + + array_push ($table->data, $data); } print_table ($table); @@ -133,7 +134,6 @@ if (isset($_GET["server"])) { echo ''.__('MD5 Check').''; echo ''.__('SNMP Console').''; echo ""; - } else { echo "
".__('There are no servers configured into the database')."
"; } diff --git a/pandora_console/godmode/setup/news.php b/pandora_console/godmode/setup/news.php index 63dd6f6c6d..c7addb3881 100644 --- a/pandora_console/godmode/setup/news.php +++ b/pandora_console/godmode/setup/news.php @@ -36,8 +36,8 @@ if (isset ($_POST["create"])) { // If create $id_link = process_sql ($sql, "insert_id"); print_result_message ($id_link, - __('Created successfully'), - __('Not created. Error inserting data')); + __('Successfully created'), + __('Could not be created')); } if (isset ($_POST["update"])) { // if update diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index e259541571..984c223355 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -1214,8 +1214,8 @@ function get_users_info ($order = "fullname", $info = "fullname") { * * @return array A list of the groups the user has certain privileges. */ -function get_user_groups ($id_user = 0, $privilege = "AR") { - if ($id_user == 0) { +function get_user_groups ($id_user = false, $privilege = "AR") { + if (empty ($id_user)) { global $config; $id_user = $config['id_user']; } @@ -2674,10 +2674,10 @@ function get_server_info ($id_server = -1) { $modules_info = array (); $modules_total = array (); $result = get_db_all_rows_sql ("SELECT DISTINCT(tagente_estado.running_by), COUNT(*) AS modules, id_modulo - FROM tagente_estado, tagente_modulo - WHERE tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo - AND tagente_modulo.disabled = 0 - AND tagente_modulo.delete_pending = 0 GROUP BY running_by"); + FROM tagente_estado, tagente_modulo + WHERE tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo + AND tagente_modulo.disabled = 0 + AND tagente_modulo.delete_pending = 0 GROUP BY running_by"); if (empty ($result)) { $result = array (); } @@ -2703,46 +2703,62 @@ function get_server_info ($id_server = -1) { $return = array (); foreach ($result as $server) { - if ($server['network_server'] == 1) { - $server["img"] = print_image ("images/network.png", true, array ("title" => __('Network Server'))); - $server["type"] = "network"; - $id_modulo = 2; - } elseif ($server['data_server'] == 1) { + switch ($server['server_type']) { + case 0: $server["img"] = print_image ("images/data.png", true, array ("title" => __('Data Server'))); $server["type"] = "data"; $id_modulo = 1; - } elseif ($server['snmp_server'] == 1) { + break; + case 1: + $server["img"] = print_image ("images/network.png", true, array ("title" => __('Network Server'))); + $server["type"] = "network"; + $id_modulo = 2; + break; + case 2: $server["img"] = print_image ("images/snmp.png", true, array ("title" => __('SNMP Server'))); $server["type"] = "snmp"; $id_modulo = 0; - } elseif ($server['recon_server'] == 1) { + break; + case 3: $server["img"] = print_image ("images/recon.png", true, array ("title" => __('Recon Server'))); $server["type"] = "recon"; $id_modulo = 0; - } elseif ($server['export_server'] == 1) { - $server["img"] = print_image ("images/database_refresh.png", true, array ("title" => __('Export Server'))); - $server["type"] = "export"; - $id_modulo = 0; - } elseif ($server['wmi_server'] == 1) { - $server["img"] = print_image ("images/wmi.png", true, array ("title" => __('WMI Server'))); - $server["type"] = "wmi"; - $id_modulo = 6; - } elseif ($server['prediction_server'] == 1) { - $server["img"] = print_image ("images/chart_bar.png", true, array ("title" => __('Prediction Server'))); - $server["type"] = "prediction"; - $id_modulo = 5; - } elseif ($server['plugin_server'] == 1) { + break; + case 4: $server["img"] = print_image ("images/plugin.png", true, array ("title" => __('Plugin Server'))); $server["type"] = "plugin"; $id_modulo = 4; - } elseif ($server['inventory_server'] == 1) { - $server["img"] = print_image ("images/page_white_text.png", true, array ("title" => __('Inventory Server'))); - $server["type"] = "inventory"; - $id_modulo = 0; - } else { + break; + case 5: + $server["img"] = print_image ("images/chart_bar.png", true, array ("title" => __('Prediction Server'))); + $server["type"] = "prediction"; + $id_modulo = 5; + break; + case 6: + $server["img"] = print_image ("images/wmi.png", true, array ("title" => __('WMI Server'))); + $server["type"] = "wmi"; + $id_modulo = 6; + break; + case 7: + $server["img"] = print_image ("images/bullet_go.png", true, array ("title" => __('Export Server'))); + $server["type"] = "export"; + $id_modulo = 0; + break; + case 8: + $server["img"] = print_image ("images/page_white_text.png", true, array ("title" => __('Inventory Server'))); + $server["type"] = "inventory"; + $id_modulo = 0; + break; + case 9: + $server["img"] = print_image ("images/world.png", true, array ("title" => __('Web Server'))); + $server["type"] = "web"; + $id_modulo = 0; + break; + default: $server["img"] = ''; $server["type"] = "unknown"; $id_modulo = 0; + break; } if ($server['master'] == 1) { @@ -2767,10 +2783,10 @@ function get_server_info ($id_server = -1) { if ($id_modulo > 0 && $server["modules"] > 0) { //If the server doesn't have modules, it doesn't have lag so nothing to calculate. If it's not a module server, don't go here either $result = get_db_row_sql ("SELECT COUNT(*) AS module_lag, MAX(last_execution_try - current_interval) AS lag FROM tagente_estado - WHERE last_execution_try > 0 - AND current_interval > 0 - AND running_by = ".$server["id_server"]." - AND (UNIX_TIMESTAMP() - last_execution_try - current_interval < current_interval * 2)"); + WHERE last_execution_try > 0 + AND current_interval > 0 + AND running_by = ".$server["id_server"]." + AND (UNIX_TIMESTAMP() - last_execution_try - current_interval < current_interval * 2)"); // Lag over current_interval * 2 is not lag, it's a timed out module // And we can't check current_interval = 0 (data modules) because they come as they want @@ -2783,35 +2799,35 @@ function get_server_info ($id_server = -1) { } } else { switch ($server["type"]) { - case "recon": - $server["name"] = ''.$server["name"].''; - - //Get recon taks info - $tasks = get_db_all_rows_sql ("SELECT status, utimestamp FROM trecon_task WHERE id_recon_server = ".$server["id_server"]); - if (empty ($tasks)) { - $tasks = array (); - } - //Total jobs running on this recon server - $server["modules"] = count ($tasks); - - //Total recon jobs (all servers) - $server["modules_total"] = $recon_total; - - //Lag (take average active time of all active tasks) - $server["module_lag"] = 0; - $lags = array (); - foreach ($tasks as $task) { - if ($task["status"] > 0 && $task["status"] <= 100) { - $lags[] = $time - $task["utimestamp"]; - //Module lag is actually the number of jobs that is currently running - $server["module_lag"]++; - } - } - if (count ($lags) > 0) { - $server["lag"] = (int) array_sum ($lags) / count ($lags); + case "recon": + $server["name"] = ''.$server["name"].''; + + //Get recon taks info + $tasks = get_db_all_rows_sql ("SELECT status, utimestamp FROM trecon_task WHERE id_recon_server = ".$server["id_server"]); + if (empty ($tasks)) { + $tasks = array (); + } + //Total jobs running on this recon server + $server["modules"] = count ($tasks); + + //Total recon jobs (all servers) + $server["modules_total"] = $recon_total; + + //Lag (take average active time of all active tasks) + $server["module_lag"] = 0; + $lags = array (); + foreach ($tasks as $task) { + if ($task["status"] > 0 && $task["status"] <= 100) { + $lags[] = $time - $task["utimestamp"]; + //Module lag is actually the number of jobs that is currently running + $server["module_lag"]++; } + } + if (count ($lags) > 0) { + $server["lag"] = (int) array_sum ($lags) / count ($lags); + } break; - default: + default: break; } } diff --git a/pandora_console/include/functions_servers.php b/pandora_console/include/functions_servers.php new file mode 100644 index 0000000000..925574fd56 --- /dev/null +++ b/pandora_console/include/functions_servers.php @@ -0,0 +1,56 @@ + diff --git a/pandora_console/operation/servers/view_server.php b/pandora_console/operation/servers/view_server.php index b50547e832..7d71f6ad3d 100644 --- a/pandora_console/operation/servers/view_server.php +++ b/pandora_console/operation/servers/view_server.php @@ -32,7 +32,6 @@ $modules_server = 0; $total_modules_network = 0; $total_modules_data = 0; - echo "

".__('Pandora servers')." » ".__('Configuration detail')."

"; $total_modules = (int) get_db_value ('COUNT(*)', 'tagente_modulo', 'disabled', 0); @@ -42,6 +41,9 @@ $table->width = '98%'; $table->size = array (); $table->size[6] = '60'; +$table->style = array (); +$table->style[0] = 'font-weight: bold'; + $table->align = array (); $table->align[1] = 'center'; $table->align[6] = 'center'; @@ -60,12 +62,12 @@ $table->data = array (); foreach ($servers as $server) { $data = array (); - $data[0] = "".$server['name'].""; + $data[0] = $server['name']; if ($server['status'] == 0) { - $data[1] = print_status_image(STATUS_SERVER_DOWN, '', true); + $data[1] = print_status_image (STATUS_SERVER_DOWN, '', true); } else { - $data[1] = print_status_image(STATUS_SERVER_OK, '', true); + $data[1] = print_status_image (STATUS_SERVER_OK, '', true); } // Load @@ -79,7 +81,7 @@ foreach ($servers as $server) { array_push ($table->data, $data); } -if (!empty ($table->data)) { +if (! empty ($table->data)) { print_table ($table); } else { echo "
".__('There are no servers configured into the database')."
"; diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 395fad4afd..c752e530a2 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -58,7 +58,7 @@ CREATE TABLE IF NOT EXISTS `tagente` ( `id_wmi_server` smallint(4) unsigned default '0', `id_parent` int(10) unsigned default '0', `custom_id` varchar(255) default '', - `server_name` varchar(255) default '', + `server_name` varchar(100) default '', PRIMARY KEY (`id_agente`), KEY `nombre` (`nombre`), KEY `direccion` (`direccion`),