From f0d2ccf98d6916781ac36ae3ab6b95ad50b524d9 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Wed, 23 Jul 2014 16:59:05 +0000 Subject: [PATCH] 2014-07-23 Miguel de Dios * include/config_process.php, operation/agentes/status_monitor.php, operation/agentes/estado_generalagente.php, operation/agentes/estado_agente.php: tiny fixes for the improve the support of postgreSQL databases. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@10352 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 7 +++ pandora_console/include/config_process.php | 20 ++++++++ .../operation/agentes/estado_agente.php | 48 ++++++++++++------- .../agentes/estado_generalagente.php | 20 ++++---- .../operation/agentes/status_monitor.php | 35 ++++++++++---- 5 files changed, 95 insertions(+), 35 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index a62e7fc3ac..e4e6c42edb 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,10 @@ +2014-07-23 Miguel de Dios + + * include/config_process.php, operation/agentes/status_monitor.php, + operation/agentes/estado_generalagente.php, + operation/agentes/estado_agente.php: tiny fixes for the improve the + support of postgreSQL databases. + 2014-07-23 Miguel de Dios * include/functions_servers.php, include/functions_reporting.php: diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 8cec92dc30..d446ba21a8 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -247,4 +247,24 @@ if (defined('METACONSOLE')) { // cases (reverse proxy, others ports...). //====================================================================== $config["homeurl"] = ui_get_full_url(false); + + +//====================================================================== +// Get the version of DB manager +//====================================================================== +switch ($config["dbtype"]) { + case "mysql": + break; + case "postgresql": + if (!isset($config['dbversion'])) { + $result = db_get_sql("select version();"); + $result_chunks = explode(" ", $result); + + $config['dbversion'] = $result_chunks[1]; + } + break; + case "oracle": + break; +} +//====================================================================== ?> diff --git a/pandora_console/operation/agentes/estado_agente.php b/pandora_console/operation/agentes/estado_agente.php index 6a8d28cc4e..9047c87d4b 100644 --- a/pandora_console/operation/agentes/estado_agente.php +++ b/pandora_console/operation/agentes/estado_agente.php @@ -223,18 +223,31 @@ $selectLastContactUp = ''; $selectLastContactDown = ''; $order = null; + +$order_collation = ""; +switch ($config["dbtype"]) { + case "mysql": + $order_collation = "COLLATE utf8_general_ci"; + break; + case "postgresql": + case "oracle": + $order_collation = ""; + break; +} + + switch ($sortField) { case 'name': switch ($sort) { case 'up': $selectNameUp = $selected; - $order = array('field' => 'nombre COLLATE utf8_general_ci', - 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'ASC'); + $order = array('field' => 'nombre' . $order_collation, + 'field2' => 'nombre' . $order_collation, 'order' => 'ASC'); break; case 'down': $selectNameDown = $selected; - $order = array('field' => 'nombre COLLATE utf8_general_ci', - 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'DESC'); + $order = array('field' => 'nombre' . $order_collation, + 'field2' => 'nombre' . $order_collation, 'order' => 'DESC'); break; } break; @@ -243,12 +256,12 @@ switch ($sortField) { case 'up': $selectOsUp = $selected; $order = array('field' => 'id_os', - 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'ASC'); + 'field2' => 'nombre' . $order_collation, 'order' => 'ASC'); break; case 'down': $selectOsDown = $selected; $order = array('field' => 'id_os', - 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'DESC'); + 'field2' => 'nombre' . $order_collation, 'order' => 'DESC'); break; } break; @@ -257,12 +270,12 @@ switch ($sortField) { case 'up': $selectIntervalUp = $selected; $order = array('field' => 'intervalo', - 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'ASC'); + 'field2' => 'nombre' . $order_collation, 'order' => 'ASC'); break; case 'down': $selectIntervalDown = $selected; $order = array('field' => 'intervalo', - 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'DESC'); + 'field2' => 'nombre' . $order_collation, 'order' => 'DESC'); break; } break; @@ -271,12 +284,12 @@ switch ($sortField) { case 'up': $selectGroupUp = $selected; $order = array('field' => 'id_grupo', - 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'ASC'); + 'field2' => 'nombre' . $order_collation, 'order' => 'ASC'); break; case 'down': $selectGroupDown = $selected; $order = array('field' => 'id_grupo', - 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'DESC'); + 'field2' => 'nombre' . $order_collation, 'order' => 'DESC'); break; } break; @@ -285,12 +298,12 @@ switch ($sortField) { case 'up': $selectLastContactUp = $selected; $order = array('field' => 'ultimo_contacto', - 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'DESC'); + 'field2' => 'nombre' . $order_collation, 'order' => 'DESC'); break; case 'down': $selectLastContactDown = $selected; $order = array('field' => 'ultimo_contacto', - 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'ASC'); + 'field2' => 'nombre' . $order_collation, 'order' => 'ASC'); break; } break; @@ -305,15 +318,15 @@ switch ($sortField) { $selectGroupDown = ''; $selectLastContactUp = ''; $selectLastContactDown = ''; - $order = array('field' => 'nombre COLLATE utf8_general_ci', - 'field2' => 'nombre COLLATE utf8_general_ci', + $order = array('field' => 'nombre' . $order_collation, + 'field2' => 'nombre' . $order_collation, 'order' => 'ASC'); break; } $search_sql = ''; if ($search != "") { - $search_sql = " AND ( nombre COLLATE utf8_general_ci LIKE '%$search%' OR direccion LIKE '%$search%' OR comentarios LIKE '%$search%') "; + $search_sql = " AND ( nombre " . $order_collation . " LIKE '%$search%' OR direccion LIKE '%$search%' OR comentarios LIKE '%$search%') "; } // Show only selected groups @@ -340,8 +353,9 @@ $total_agents = agents_get_agents(array ( array ('COUNT(*) as total'), 'AR', false); $total_agents = isset ($total_agents[0]['total']) ? $total_agents[0]['total'] : 0; + $agents = agents_get_agents(array ( - 'order' => 'nombre COLLATE utf8_general_ci ASC', + 'order' => 'nombre ' . $order_collation . ' ASC', 'id_grupo' => $groups, 'disabled' => 0, 'status' => $status, @@ -354,7 +368,7 @@ $agents = agents_get_agents(array ( 'id_os', 'ultimo_contacto', 'intervalo', - 'comentarios description', + 'comentarios description', 'quiet', 'normal_count', 'warning_count', diff --git a/pandora_console/operation/agentes/estado_generalagente.php b/pandora_console/operation/agentes/estado_generalagente.php index 0c3f792dee..ab4aeea8a2 100644 --- a/pandora_console/operation/agentes/estado_generalagente.php +++ b/pandora_console/operation/agentes/estado_generalagente.php @@ -255,7 +255,7 @@ if(enterprise_installed()) { else { $data[1] = __('Enabled'); } - + $table_data->data[] = $data; } @@ -323,7 +323,7 @@ $last_incident = db_get_row_sql("SELECT * FROM tincidencia WHERE estado IN (0,1) AND id_agent=$id_agente ORDER BY actualizacion DESC"); - + if ($last_incident != false) { $table_incident->id = 'agent_incident_main'; @@ -333,10 +333,10 @@ if ($last_incident != false) { $table_incident->class = 'databox'; $table_incident->style[0] = 'width: 30%;'; $table_incident->style[1] = 'width: 70%;'; - + $table_incident->head[0] = ' ' . '' .__('Active incident on this agent') .''. ''; $table_incident->head_colspan[0] = 2; - + $data = array(); $data[0] = '' . __('Author') . ''; $data[1] = $last_incident["id_creator"]; @@ -391,20 +391,20 @@ if (! empty($modules)) { $table_interface->head_colspan = array(); $table_interface->head_colspan[0] = 4; $table_interface->data = array(); - + foreach ($modules as $key => $module) { - + // Trying to get the interface name from the module name if (preg_match ("/_(.+)$/", (string)$module['nombre'], $matches)) { if ($matches[1]) { $interface_name = $matches[1]; - + $module_id = $module['id_agente_modulo']; $db_status = modules_get_agentmodule_status($module_id); $module_value = modules_get_last_value ($module_id); modules_get_status($module_id, $db_status, $module_value, $status, $title); $status = ui_print_status_image($status, $title, true); - + $ip_target = "--"; // Trying to get something like an IP from the description if (preg_match ("/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/", (string)$module['descripcion'], $matches) || @@ -421,7 +421,7 @@ if (! empty($modules)) { $description = $matches[0]; } } - + $data = array(); $data[0] = "" . $interface_name . ""; $data[1] = $status; @@ -432,7 +432,7 @@ if (! empty($modules)) { } } unset($modules); - + // This javascript piece of code is used to make expandible the body of the table ?>