mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 16:24:54 +02:00
2014-07-23 Miguel de Dios <miguel.dedios@artica.es>
* 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
This commit is contained in:
parent
807faa6992
commit
f0d2ccf98d
@ -1,3 +1,10 @@
|
|||||||
|
2014-07-23 Miguel de Dios <miguel.dedios@artica.es>
|
||||||
|
|
||||||
|
* 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 <miguel.dedios@artica.es>
|
2014-07-23 Miguel de Dios <miguel.dedios@artica.es>
|
||||||
|
|
||||||
* include/functions_servers.php, include/functions_reporting.php:
|
* include/functions_servers.php, include/functions_reporting.php:
|
||||||
|
@ -247,4 +247,24 @@ if (defined('METACONSOLE')) {
|
|||||||
// cases (reverse proxy, others ports...).
|
// cases (reverse proxy, others ports...).
|
||||||
//======================================================================
|
//======================================================================
|
||||||
$config["homeurl"] = ui_get_full_url(false);
|
$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;
|
||||||
|
}
|
||||||
|
//======================================================================
|
||||||
?>
|
?>
|
||||||
|
@ -223,18 +223,31 @@ $selectLastContactUp = '';
|
|||||||
$selectLastContactDown = '';
|
$selectLastContactDown = '';
|
||||||
$order = null;
|
$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) {
|
switch ($sortField) {
|
||||||
case 'name':
|
case 'name':
|
||||||
switch ($sort) {
|
switch ($sort) {
|
||||||
case 'up':
|
case 'up':
|
||||||
$selectNameUp = $selected;
|
$selectNameUp = $selected;
|
||||||
$order = array('field' => 'nombre COLLATE utf8_general_ci',
|
$order = array('field' => 'nombre' . $order_collation,
|
||||||
'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'ASC');
|
'field2' => 'nombre' . $order_collation, 'order' => 'ASC');
|
||||||
break;
|
break;
|
||||||
case 'down':
|
case 'down':
|
||||||
$selectNameDown = $selected;
|
$selectNameDown = $selected;
|
||||||
$order = array('field' => 'nombre COLLATE utf8_general_ci',
|
$order = array('field' => 'nombre' . $order_collation,
|
||||||
'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'DESC');
|
'field2' => 'nombre' . $order_collation, 'order' => 'DESC');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -243,12 +256,12 @@ switch ($sortField) {
|
|||||||
case 'up':
|
case 'up':
|
||||||
$selectOsUp = $selected;
|
$selectOsUp = $selected;
|
||||||
$order = array('field' => 'id_os',
|
$order = array('field' => 'id_os',
|
||||||
'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'ASC');
|
'field2' => 'nombre' . $order_collation, 'order' => 'ASC');
|
||||||
break;
|
break;
|
||||||
case 'down':
|
case 'down':
|
||||||
$selectOsDown = $selected;
|
$selectOsDown = $selected;
|
||||||
$order = array('field' => 'id_os',
|
$order = array('field' => 'id_os',
|
||||||
'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'DESC');
|
'field2' => 'nombre' . $order_collation, 'order' => 'DESC');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -257,12 +270,12 @@ switch ($sortField) {
|
|||||||
case 'up':
|
case 'up':
|
||||||
$selectIntervalUp = $selected;
|
$selectIntervalUp = $selected;
|
||||||
$order = array('field' => 'intervalo',
|
$order = array('field' => 'intervalo',
|
||||||
'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'ASC');
|
'field2' => 'nombre' . $order_collation, 'order' => 'ASC');
|
||||||
break;
|
break;
|
||||||
case 'down':
|
case 'down':
|
||||||
$selectIntervalDown = $selected;
|
$selectIntervalDown = $selected;
|
||||||
$order = array('field' => 'intervalo',
|
$order = array('field' => 'intervalo',
|
||||||
'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'DESC');
|
'field2' => 'nombre' . $order_collation, 'order' => 'DESC');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -271,12 +284,12 @@ switch ($sortField) {
|
|||||||
case 'up':
|
case 'up':
|
||||||
$selectGroupUp = $selected;
|
$selectGroupUp = $selected;
|
||||||
$order = array('field' => 'id_grupo',
|
$order = array('field' => 'id_grupo',
|
||||||
'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'ASC');
|
'field2' => 'nombre' . $order_collation, 'order' => 'ASC');
|
||||||
break;
|
break;
|
||||||
case 'down':
|
case 'down':
|
||||||
$selectGroupDown = $selected;
|
$selectGroupDown = $selected;
|
||||||
$order = array('field' => 'id_grupo',
|
$order = array('field' => 'id_grupo',
|
||||||
'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'DESC');
|
'field2' => 'nombre' . $order_collation, 'order' => 'DESC');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -285,12 +298,12 @@ switch ($sortField) {
|
|||||||
case 'up':
|
case 'up':
|
||||||
$selectLastContactUp = $selected;
|
$selectLastContactUp = $selected;
|
||||||
$order = array('field' => 'ultimo_contacto',
|
$order = array('field' => 'ultimo_contacto',
|
||||||
'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'DESC');
|
'field2' => 'nombre' . $order_collation, 'order' => 'DESC');
|
||||||
break;
|
break;
|
||||||
case 'down':
|
case 'down':
|
||||||
$selectLastContactDown = $selected;
|
$selectLastContactDown = $selected;
|
||||||
$order = array('field' => 'ultimo_contacto',
|
$order = array('field' => 'ultimo_contacto',
|
||||||
'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'ASC');
|
'field2' => 'nombre' . $order_collation, 'order' => 'ASC');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -305,15 +318,15 @@ switch ($sortField) {
|
|||||||
$selectGroupDown = '';
|
$selectGroupDown = '';
|
||||||
$selectLastContactUp = '';
|
$selectLastContactUp = '';
|
||||||
$selectLastContactDown = '';
|
$selectLastContactDown = '';
|
||||||
$order = array('field' => 'nombre COLLATE utf8_general_ci',
|
$order = array('field' => 'nombre' . $order_collation,
|
||||||
'field2' => 'nombre COLLATE utf8_general_ci',
|
'field2' => 'nombre' . $order_collation,
|
||||||
'order' => 'ASC');
|
'order' => 'ASC');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$search_sql = '';
|
$search_sql = '';
|
||||||
if ($search != "") {
|
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
|
// Show only selected groups
|
||||||
@ -340,8 +353,9 @@ $total_agents = agents_get_agents(array (
|
|||||||
array ('COUNT(*) as total'), 'AR', false);
|
array ('COUNT(*) as total'), 'AR', false);
|
||||||
$total_agents = isset ($total_agents[0]['total']) ? $total_agents[0]['total'] : 0;
|
$total_agents = isset ($total_agents[0]['total']) ? $total_agents[0]['total'] : 0;
|
||||||
|
|
||||||
|
|
||||||
$agents = agents_get_agents(array (
|
$agents = agents_get_agents(array (
|
||||||
'order' => 'nombre COLLATE utf8_general_ci ASC',
|
'order' => 'nombre ' . $order_collation . ' ASC',
|
||||||
'id_grupo' => $groups,
|
'id_grupo' => $groups,
|
||||||
'disabled' => 0,
|
'disabled' => 0,
|
||||||
'status' => $status,
|
'status' => $status,
|
||||||
|
@ -14,8 +14,6 @@
|
|||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Load global vars
|
// Load global vars
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
@ -45,6 +43,8 @@ else {
|
|||||||
ui_meta_print_header(__("Monitor view"));
|
ui_meta_print_header(__("Monitor view"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$ag_freestring = get_parameter ('ag_freestring');
|
$ag_freestring = get_parameter ('ag_freestring');
|
||||||
$ag_modulename = (string) get_parameter ('ag_modulename');
|
$ag_modulename = (string) get_parameter ('ag_modulename');
|
||||||
if (!defined('METACONSOLE')) {
|
if (!defined('METACONSOLE')) {
|
||||||
@ -101,8 +101,12 @@ $sql_conditions_base = " WHERE tagente.id_agente = tagente_modulo.id_agente
|
|||||||
|
|
||||||
$sql_conditions = " AND tagente_modulo.disabled = 0 AND tagente.disabled = 0";
|
$sql_conditions = " AND tagente_modulo.disabled = 0 AND tagente.disabled = 0";
|
||||||
|
|
||||||
|
if (is_numeric($ag_group)) {
|
||||||
|
$id_ag_group = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
$id_ag_group = db_get_value('id_grupo', 'tgrupo', 'nombre', $ag_group);
|
$id_ag_group = db_get_value('id_grupo', 'tgrupo', 'nombre', $ag_group);
|
||||||
|
}
|
||||||
|
|
||||||
// Agent group selector
|
// Agent group selector
|
||||||
if (!defined('METACONSOLE')) {
|
if (!defined('METACONSOLE')) {
|
||||||
@ -123,6 +127,7 @@ else {
|
|||||||
$sql_conditions_group = " AND tagente.id_grupo IN (".$user_groups.")";
|
$sql_conditions_group = " AND tagente.id_grupo IN (".$user_groups.")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Module group
|
// Module group
|
||||||
if (defined('METACONSOLE')) {
|
if (defined('METACONSOLE')) {
|
||||||
if ($modulegroup != '-1')
|
if ($modulegroup != '-1')
|
||||||
@ -310,7 +315,9 @@ if ($flag_is_admin)
|
|||||||
if (defined('METACONSOLE')) {
|
if (defined('METACONSOLE')) {
|
||||||
|
|
||||||
// For each server defined and not disabled:
|
// For each server defined and not disabled:
|
||||||
$servers = db_get_all_rows_sql ("SELECT * FROM tmetaconsole_setup WHERE disabled = 0");
|
$servers = db_get_all_rows_sql ("SELECT *
|
||||||
|
FROM tmetaconsole_setup
|
||||||
|
WHERE disabled = 0");
|
||||||
|
|
||||||
if ($servers === false)
|
if ($servers === false)
|
||||||
$servers = array();
|
$servers = array();
|
||||||
@ -727,8 +734,15 @@ switch ($config["dbtype"]) {
|
|||||||
LIMIT ".$offset.",".$limit_sql;
|
LIMIT ".$offset.",".$limit_sql;
|
||||||
break;
|
break;
|
||||||
case "postgresql":
|
case "postgresql":
|
||||||
|
if (strstr($config['dbversion'], "8.4") !== false) {
|
||||||
|
$string_agg = "array_to_string(array_agg(ttag.name), ',')";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$string_agg = "STRING_AGG(ttag.name, ',')";
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "SELECT
|
$sql = "SELECT
|
||||||
(SELECT STRING_AGG(ttag.name, ',')
|
(SELECT " . $string_agg . "
|
||||||
FROM ttag
|
FROM ttag
|
||||||
WHERE ttag.id_tag IN (
|
WHERE ttag.id_tag IN (
|
||||||
SELECT ttag_module.id_tag
|
SELECT ttag_module.id_tag
|
||||||
@ -760,7 +774,10 @@ switch ($config["dbtype"]) {
|
|||||||
tagente_modulo.critical_instructions,
|
tagente_modulo.critical_instructions,
|
||||||
tagente_modulo.warning_instructions,
|
tagente_modulo.warning_instructions,
|
||||||
tagente_modulo.unknown_instructions,
|
tagente_modulo.unknown_instructions,
|
||||||
tagente_estado.utimestamp AS utimestamp".$sql_form . $sql_conditions_all." LIMIT " . $limit_sql . " OFFSET " . $offset;
|
tagente_estado.utimestamp AS utimestamp" .
|
||||||
|
$sql_from .
|
||||||
|
$sql_conditions_all .
|
||||||
|
" LIMIT " . $limit_sql . " OFFSET " . $offset;
|
||||||
break;
|
break;
|
||||||
case "oracle":
|
case "oracle":
|
||||||
$set = array();
|
$set = array();
|
||||||
@ -799,7 +816,9 @@ switch ($config["dbtype"]) {
|
|||||||
tagente_modulo.critical_instructions,
|
tagente_modulo.critical_instructions,
|
||||||
tagente_modulo.warning_instructions,
|
tagente_modulo.warning_instructions,
|
||||||
tagente_modulo.unknown_instructions,
|
tagente_modulo.unknown_instructions,
|
||||||
tagente_estado.utimestamp AS utimestamp" . $sql_form . $sql_conditions_all;
|
tagente_estado.utimestamp AS utimestamp" .
|
||||||
|
$sql_from .
|
||||||
|
$sql_conditions_all;
|
||||||
$sql = oracle_recode_query ($sql, $set);
|
$sql = oracle_recode_query ($sql, $set);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user