Fixed some problems with oracle compatibility

This commit is contained in:
Alejandro Gallardo Escobar 2015-04-30 12:35:42 +02:00
parent 4008b12add
commit 3264c65ef8
6 changed files with 107 additions and 99 deletions

View File

@ -193,7 +193,16 @@ class Tree {
protected function getAgentCountersSql ($agent_table) { protected function getAgentCountersSql ($agent_table) {
$columns = $this->getAgentCounterColumnsSql($agent_table); $columns = $this->getAgentCounterColumnsSql($agent_table);
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$columns = "SELECT $columns FROM dual LIMIT 1"; $columns = "SELECT $columns FROM dual LIMIT 1";
break;
case "oracle":
$columns = "SELECT $columns FROM dual WHERE rownum <= 1";
break;
}
return $columns; return $columns;
} }
@ -237,7 +246,7 @@ class Tree {
// Agents join // Agents join
$agents_join = ""; $agents_join = "";
if (!empty($agent_search_filter) || !empty($agent_status_filter)) { if (!empty($agent_search_filter) || !empty($agent_status_filter)) {
$agents_join = "INNER JOIN tagente AS ta $agents_join = "INNER JOIN tagente ta
ON ta.disabled = 0 ON ta.disabled = 0
AND tam.id_agente = ta.id_agente AND tam.id_agente = ta.id_agente
$agent_search_filter $agent_search_filter
@ -288,13 +297,13 @@ class Tree {
if (!empty($module_search_filter) || !empty($module_status_filter)) { if (!empty($module_search_filter) || !empty($module_status_filter)) {
if (!empty($module_status_filter)) { if (!empty($module_status_filter)) {
$module_status_join = "INNER JOIN tagente_estado AS tae $module_status_join = "INNER JOIN tagente_estado tae
ON tam.id_agente_modulo IS NOT NULL ON tam.id_agente_modulo IS NOT NULL
AND tam.id_agente_modulo = tae.id_agente_modulo AND tam.id_agente_modulo = tae.id_agente_modulo
$module_status_filter"; $module_status_filter";
} }
$modules_join = "INNER JOIN tagente_modulo AS tam $modules_join = "INNER JOIN tagente_modulo tam
ON tam.disabled = 0 ON tam.disabled = 0
AND ta.id_agente = tam.id_agente AND ta.id_agente = tam.id_agente
$module_search_filter $module_search_filter
@ -302,7 +311,7 @@ class Tree {
} }
if (empty($module_status_join)) { if (empty($module_status_join)) {
$module_status_join = "LEFT JOIN tagente_estado AS tae $module_status_join = "LEFT JOIN tagente_estado tae
ON tam.id_agente_modulo = tae.id_agente_modulo"; ON tam.id_agente_modulo = tae.id_agente_modulo";
} }
@ -358,8 +367,8 @@ class Tree {
if (! defined('METACONSOLE')) { if (! defined('METACONSOLE')) {
// Add the agent counters to the columns // Add the agent counters to the columns
$agent_table = "SELECT COUNT(DISTINCT(ta.id_agente)) $agent_table = "SELECT COUNT(DISTINCT(ta.id_agente))
FROM tagente AS ta FROM tagente ta
LEFT JOIN tagente_modulo AS tam LEFT JOIN tagente_modulo tam
ON tam.disabled = 0 ON tam.disabled = 0
AND ta.id_agente = tam.id_agente AND ta.id_agente = tam.id_agente
$module_search_filter $module_search_filter
@ -374,9 +383,9 @@ class Tree {
$columns .= ", $counter_columns"; $columns .= ", $counter_columns";
$sql = "SELECT $columns $sql = "SELECT $columns
FROM tgrupo AS tg FROM tgrupo tg
LEFT JOIN tagente AS ta LEFT JOIN tagente ta
LEFT JOIN tagente_modulo AS tam LEFT JOIN tagente_modulo tam
ON tam.disabled = 0 ON tam.disabled = 0
AND ta.id_agente = tam.id_agente AND ta.id_agente = tam.id_agente
$module_search_filter $module_search_filter
@ -393,7 +402,7 @@ class Tree {
else { else {
// Add the agent counters to the columns // Add the agent counters to the columns
$agent_table = "SELECT COUNT(DISTINCT(ta.id_agente)) $agent_table = "SELECT COUNT(DISTINCT(ta.id_agente))
FROM tmetaconsole_agent AS ta FROM tmetaconsole_agent ta
WHERE ta.disabled = 0 WHERE ta.disabled = 0
AND ta.id_grupo = tg.id_grupo AND ta.id_grupo = tg.id_grupo
$group_acl $group_acl
@ -404,8 +413,8 @@ class Tree {
$columns .= ", $counter_columns"; $columns .= ", $counter_columns";
$sql = "SELECT $columns $sql = "SELECT $columns
FROM tgrupo AS tg FROM tgrupo tg
LEFT JOIN tagente AS ta LEFT JOIN tagente ta
ON ta.disabled = 0 ON ta.disabled = 0
AND tg.id_grupo = ta.id_grupo AND tg.id_grupo = ta.id_grupo
$group_acl $group_acl
@ -424,8 +433,8 @@ class Tree {
$order_fields = 'ta.nombre ASC, ta.id_agente ASC'; $order_fields = 'ta.nombre ASC, ta.id_agente ASC';
$sql = "SELECT $columns $sql = "SELECT $columns
FROM tagente AS ta FROM tagente ta
LEFT JOIN tagente_modulo AS tam LEFT JOIN tagente_modulo tam
ON tam.disabled = 0 ON tam.disabled = 0
AND ta.id_agente = tam.id_agente AND ta.id_agente = tam.id_agente
$module_search_filter $module_search_filter
@ -446,7 +455,7 @@ class Tree {
$order_fields = 'ta.nombre ASC, ta.id_tagente ASC'; $order_fields = 'ta.nombre ASC, ta.id_tagente ASC';
$sql = "SELECT $columns $sql = "SELECT $columns
FROM tmetaconsole_agent AS ta FROM tmetaconsole_agent ta
WHERE ta.disabled = 0 WHERE ta.disabled = 0
AND ta.id_grupo = $rootID AND ta.id_grupo = $rootID
$group_acl $group_acl
@ -464,9 +473,9 @@ class Tree {
$order_fields = 'tam.nombre ASC, tam.id_agente_modulo ASC'; $order_fields = 'tam.nombre ASC, tam.id_agente_modulo ASC';
$sql = "SELECT $columns $sql = "SELECT $columns
FROM tagente_modulo AS tam FROM tagente_modulo tam
$module_status_join $module_status_join
INNER JOIN tagente AS ta INNER JOIN tagente ta
ON ta.disabled = 0 ON ta.disabled = 0
AND tam.id_agente = ta.id_agente AND tam.id_agente = ta.id_agente
AND ta.id_grupo = $rootID AND ta.id_grupo = $rootID
@ -540,15 +549,15 @@ class Tree {
// Tags SQL // Tags SQL
if ($item_for_count === false) { if ($item_for_count === false) {
$sql = "SELECT $columns $sql = "SELECT $columns
FROM ttag AS tt FROM ttag tt
INNER JOIN ttag_module AS ttm INNER JOIN ttag_module ttm
ON tt.id_tag = ttm.id_tag ON tt.id_tag = ttm.id_tag
INNER JOIN tagente_modulo AS tam INNER JOIN tagente_modulo tam
ON tam.disabled = 0 ON tam.disabled = 0
AND ttm.id_agente_modulo = tam.id_agente_modulo AND ttm.id_agente_modulo = tam.id_agente_modulo
$module_search_filter $module_search_filter
$module_status_join $module_status_join
INNER JOIN tagente AS ta INNER JOIN tagente ta
ON ta.disabled = 0 ON ta.disabled = 0
AND tam.id_agente = ta.id_agente AND tam.id_agente = ta.id_agente
$group_acl $group_acl
@ -561,13 +570,13 @@ class Tree {
// Counters SQL // Counters SQL
else { else {
$agent_table = "SELECT COUNT(DISTINCT(ta.id_agente)) $agent_table = "SELECT COUNT(DISTINCT(ta.id_agente))
FROM tagente AS ta FROM tagente ta
INNER JOIN tagente_modulo AS tam INNER JOIN tagente_modulo tam
ON tam.disabled = 0 ON tam.disabled = 0
AND ta.id_agente = tam.id_agente AND ta.id_agente = tam.id_agente
$module_search_filter $module_search_filter
$module_status_join $module_status_join
INNER JOIN ttag_module AS ttm INNER JOIN ttag_module ttm
ON tam.id_agente_modulo = ttm.id_agente_modulo ON tam.id_agente_modulo = ttm.id_agente_modulo
AND ttm.id_tag = $item_for_count AND ttm.id_tag = $item_for_count
WHERE ta.disabled = 0 WHERE ta.disabled = 0
@ -585,13 +594,13 @@ class Tree {
$order_fields = 'ta.nombre ASC, ta.id_agente ASC'; $order_fields = 'ta.nombre ASC, ta.id_agente ASC';
$sql = "SELECT $columns $sql = "SELECT $columns
FROM tagente AS ta FROM tagente ta
INNER JOIN tagente_modulo AS tam INNER JOIN tagente_modulo tam
ON tam.disabled = 0 ON tam.disabled = 0
AND ta.id_agente = tam.id_agente AND ta.id_agente = tam.id_agente
$module_search_filter $module_search_filter
$module_status_join $module_status_join
INNER JOIN ttag_module AS ttm INNER JOIN ttag_module ttm
ON tam.id_agente_modulo = ttm.id_agente_modulo ON tam.id_agente_modulo = ttm.id_agente_modulo
AND ttm.id_tag = $rootID AND ttm.id_tag = $rootID
WHERE ta.disabled = 0 WHERE ta.disabled = 0
@ -609,12 +618,12 @@ class Tree {
$order_fields = 'tam.nombre ASC, tam.id_agente_modulo ASC'; $order_fields = 'tam.nombre ASC, tam.id_agente_modulo ASC';
$sql = "SELECT $columns $sql = "SELECT $columns
FROM tagente_modulo AS tam FROM tagente_modulo tam
INNER JOIN ttag_module AS ttm INNER JOIN ttag_module ttm
ON tam.id_agente_modulo = ttm.id_agente_modulo ON tam.id_agente_modulo = ttm.id_agente_modulo
AND ttm.id_tag = $rootID AND ttm.id_tag = $rootID
$module_status_join $module_status_join
INNER JOIN tagente AS ta INNER JOIN tagente ta
ON ta.disabled = 0 ON ta.disabled = 0
AND tam.id_agente = ta.id_agente AND tam.id_agente = ta.id_agente
$group_acl $group_acl
@ -649,8 +658,8 @@ class Tree {
// OS SQL // OS SQL
if ($item_for_count === false) { if ($item_for_count === false) {
$sql = "SELECT $columns $sql = "SELECT $columns
FROM tconfig_os AS tos FROM tconfig_os tos
INNER JOIN tagente AS ta INNER JOIN tagente ta
ON ta.disabled = 0 ON ta.disabled = 0
AND ta.id_os = tos.id_os AND ta.id_os = tos.id_os
$agent_search_filter $agent_search_filter
@ -663,7 +672,7 @@ class Tree {
// Counters SQL // Counters SQL
else { else {
$agent_table = "SELECT COUNT(DISTINCT(ta.id_agente)) $agent_table = "SELECT COUNT(DISTINCT(ta.id_agente))
FROM tagente AS ta FROM tagente ta
$modules_join $modules_join
WHERE ta.disabled = 0 WHERE ta.disabled = 0
AND ta.id_os = $item_for_count AND ta.id_os = $item_for_count
@ -681,7 +690,7 @@ class Tree {
$order_fields = 'ta.nombre ASC, ta.id_agente ASC'; $order_fields = 'ta.nombre ASC, ta.id_agente ASC';
$sql = "SELECT $columns $sql = "SELECT $columns
FROM tagente AS ta FROM tagente ta
$modules_join $modules_join
WHERE ta.disabled = 0 WHERE ta.disabled = 0
AND ta.id_os = $rootID AND ta.id_os = $rootID
@ -702,9 +711,9 @@ class Tree {
$agent_filter = "AND ta.id_agente = $parent"; $agent_filter = "AND ta.id_agente = $parent";
$sql = "SELECT $columns $sql = "SELECT $columns
FROM tagente_modulo AS tam FROM tagente_modulo tam
$module_status_join $module_status_join
INNER JOIN tagente AS ta INNER JOIN tagente ta
ON ta.disabled = 0 ON ta.disabled = 0
AND tam.id_agente = ta.id_agente AND tam.id_agente = ta.id_agente
$os_filter $os_filter
@ -740,13 +749,13 @@ class Tree {
// Module groups SQL // Module groups SQL
if ($item_for_count === false) { if ($item_for_count === false) {
$sql = "SELECT $columns $sql = "SELECT $columns
FROM tmodule_group AS tmg FROM tmodule_group tmg
INNER JOIN tagente_modulo AS tam INNER JOIN tagente_modulo tam
ON tam.disabled = 0 ON tam.disabled = 0
AND tam.id_module_group = tmg.id_mg AND tam.id_module_group = tmg.id_mg
$module_search_filter $module_search_filter
$module_status_join $module_status_join
INNER JOIN tagente AS ta INNER JOIN tagente ta
ON ta.disabled = 0 ON ta.disabled = 0
AND tam.id_agente = ta.id_agente AND tam.id_agente = ta.id_agente
$group_acl $group_acl
@ -758,8 +767,8 @@ class Tree {
// Counters SQL // Counters SQL
else { else {
$agent_table = "SELECT COUNT(DISTINCT(ta.id_agente)) $agent_table = "SELECT COUNT(DISTINCT(ta.id_agente))
FROM tagente AS ta FROM tagente ta
INNER JOIN tagente_modulo AS tam INNER JOIN tagente_modulo tam
ON tam.disabled = 0 ON tam.disabled = 0
AND ta.id_agente = tam.id_agente AND ta.id_agente = tam.id_agente
AND tam.id_module_group = $item_for_count AND tam.id_module_group = $item_for_count
@ -780,8 +789,8 @@ class Tree {
$order_fields = 'ta.nombre ASC, ta.id_agente ASC'; $order_fields = 'ta.nombre ASC, ta.id_agente ASC';
$sql = "SELECT $columns $sql = "SELECT $columns
FROM tagente AS ta FROM tagente ta
INNER JOIN tagente_modulo AS tam INNER JOIN tagente_modulo tam
ON tam.disabled = 0 ON tam.disabled = 0
AND ta.id_agente = tam.id_agente AND ta.id_agente = tam.id_agente
AND tam.id_module_group = $rootID AND tam.id_module_group = $rootID
@ -805,9 +814,9 @@ class Tree {
$agent_filter = "AND tam.id_agente = $parent"; $agent_filter = "AND tam.id_agente = $parent";
$sql = "SELECT $columns $sql = "SELECT $columns
FROM tagente_modulo AS tam FROM tagente_modulo tam
$module_status_join $module_status_join
INNER JOIN tagente AS ta INNER JOIN tagente ta
ON ta.disabled = 0 ON ta.disabled = 0
AND tam.id_agente = ta.id_agente AND tam.id_agente = ta.id_agente
$group_acl $group_acl
@ -843,8 +852,8 @@ class Tree {
// Modules SQL // Modules SQL
if ($item_for_count === false) { if ($item_for_count === false) {
$sql = "SELECT $columns $sql = "SELECT $columns
FROM tagente_modulo AS tam FROM tagente_modulo tam
INNER JOIN tagente AS ta INNER JOIN tagente ta
ON ta.disabled = 0 ON ta.disabled = 0
AND tam.id_agente = ta.id_agente AND tam.id_agente = ta.id_agente
$group_acl $group_acl
@ -859,8 +868,8 @@ class Tree {
// Counters SQL // Counters SQL
else { else {
$agent_table = "SELECT COUNT(DISTINCT(ta.id_agente)) $agent_table = "SELECT COUNT(DISTINCT(ta.id_agente))
FROM tagente AS ta FROM tagente ta
INNER JOIN tagente_modulo AS tam INNER JOIN tagente_modulo tam
ON tam.disabled = 0 ON tam.disabled = 0
AND ta.id_agente = tam.id_agente AND ta.id_agente = tam.id_agente
AND tam.nombre = '$item_for_count' AND tam.nombre = '$item_for_count'
@ -891,8 +900,8 @@ class Tree {
$name = io_safe_input($name); $name = io_safe_input($name);
$sql = "SELECT $columns $sql = "SELECT $columns
FROM tagente AS ta FROM tagente ta
INNER JOIN tagente_modulo AS tam INNER JOIN tagente_modulo tam
ON tam.disabled = 0 ON tam.disabled = 0
AND ta.id_agente = tam.id_agente AND ta.id_agente = tam.id_agente
AND tam.nombre = '$name' AND tam.nombre = '$name'
@ -927,7 +936,7 @@ class Tree {
// We need the agents table // We need the agents table
if (empty($agents_join)) { if (empty($agents_join)) {
$agents_join = "INNER JOIN tagente AS ta $agents_join = "INNER JOIN tagente ta
ON ta.disabled = 0 ON ta.disabled = 0
AND tam.id_agente = ta.id_agente AND tam.id_agente = ta.id_agente
$group_acl"; $group_acl";
@ -937,9 +946,9 @@ class Tree {
} }
$sql = "SELECT $columns $sql = "SELECT $columns
FROM tagente_modulo AS tam FROM tagente_modulo tam
$module_status_join $module_status_join
INNER JOIN tagente AS ta INNER JOIN tagente ta
ON ta.disabled = 0 ON ta.disabled = 0
AND tam.id_agente = ta.id_agente AND tam.id_agente = ta.id_agente
$group_acl $group_acl

View File

@ -2397,22 +2397,21 @@ function grafico_eventos_grupo ($width = 300, $height = 200, $url = "", $meta =
//is required if both DISTINCT() and COUNT() are in the statement //is required if both DISTINCT() and COUNT() are in the statement
switch ($config["dbtype"]) { switch ($config["dbtype"]) {
case "mysql": case "mysql":
case "postgresql":
$sql = sprintf ('SELECT DISTINCT(id_agente) AS id_agente, $sql = sprintf ('SELECT DISTINCT(id_agente) AS id_agente,
COUNT(id_agente) AS count'.$field_extra.' COUNT(id_agente) AS count'.$field_extra.'
FROM '.$event_table.' FROM '.$event_table.'
WHERE 1=1 %s %s WHERE 1=1 %s %s
GROUP BY id_agente'.$groupby_extra.' GROUP BY id_agente'.$groupby_extra.'
ORDER BY count DESC LIMIT 8', $url, $tags_condition); ORDER BY count DESC LIMIT 8', $url, $tags_condition);
break; break;
case "postgresql":
case "oracle": case "oracle":
$sql = sprintf ('SELECT DISTINCT(id_agente) AS id_agente, $sql = sprintf ('SELECT DISTINCT(id_agente) AS id_agente,
id_grupo, COUNT(id_agente) AS count'.$field_extra.' id_grupo, COUNT(id_agente) AS count'.$field_extra.'
FROM '.$event_table.' FROM '.$event_table.'
WHERE 1=1 %s %s WHERE rownum <= 0 %s %s
GROUP BY id_agente, id_grupo'.$groupby_extra.' GROUP BY id_agente, id_grupo'.$groupby_extra.'
ORDER BY count DESC LIMIT 8', $url, $tags_condition); ORDER BY count DESC', $url, $tags_condition);
break; break;
} }

View File

@ -1265,7 +1265,7 @@ function groups_get_agents_counter ($group, $agent_filter = array(), $module_fil
$module_status_array = array_unique($module_status_array); $module_status_array = array_unique($module_status_array);
$status_str = implode(",", $module_status_array); $status_str = implode(",", $module_status_array);
$module_status_filter = "INNER JOIN tagente_estado AS tae $module_status_filter = "INNER JOIN tagente_estado tae
ON tam.id_agente_modulo = tae.id_agente_modulo ON tam.id_agente_modulo = tae.id_agente_modulo
AND tae.estado IN ($status_str)"; AND tae.estado IN ($status_str)";
} }
@ -1276,8 +1276,8 @@ function groups_get_agents_counter ($group, $agent_filter = array(), $module_fil
// Realtime // Realtime
if ($realtime) { if ($realtime) {
$sql = "SELECT DISTINCT ta.id_agente $sql = "SELECT DISTINCT ta.id_agente
FROM tagente AS ta FROM tagente ta
INNER JOIN tagente_modulo AS tam INNER JOIN tagente_modulo tam
ON ta.id_agente = tam.id_agente ON ta.id_agente = tam.id_agente
AND tam.disabled = 0 AND tam.disabled = 0
$module_name_filter $module_name_filter
@ -1436,7 +1436,7 @@ function groups_get_agents_counter ($group, $agent_filter = array(), $module_fil
} }
$sql = "SELECT COUNT(DISTINCT ta.id_agente) $sql = "SELECT COUNT(DISTINCT ta.id_agente)
FROM tagente AS ta FROM tagente ta
WHERE ta.disabled = 0 WHERE ta.disabled = 0
$agent_name_filter $agent_name_filter
$status_filter $status_filter
@ -1738,11 +1738,11 @@ function groups_get_monitors_counter ($group, $agent_filter = array(), $module_f
if ($realtime) { if ($realtime) {
$sql = "SELECT COUNT(DISTINCT tam.id_agente_modulo) $sql = "SELECT COUNT(DISTINCT tam.id_agente_modulo)
FROM tagente_modulo AS tam FROM tagente_modulo tam
INNER JOIN tagente_estado AS tae INNER JOIN tagente_estado tae
ON tam.id_agente_modulo = tae.id_agente_modulo ON tam.id_agente_modulo = tae.id_agente_modulo
$modules_clause $modules_clause
INNER JOIN tagente AS ta INNER JOIN tagente ta
ON tam.id_agente = ta.id_agente ON tam.id_agente = ta.id_agente
AND ta.disabled = 0 AND ta.disabled = 0
$agent_name_filter $agent_name_filter
@ -1786,7 +1786,7 @@ function groups_get_monitors_counter ($group, $agent_filter = array(), $module_f
$status_columns_str = implode(",", $status_columns_array); $status_columns_str = implode(",", $status_columns_array);
$sql = "SELECT SUM($status_columns_str) $sql = "SELECT SUM($status_columns_str)
FROM tagente AS ta FROM tagente ta
WHERE ta.disabled = 0 WHERE ta.disabled = 0
$agent_name_filter $agent_name_filter
$agents_clause $agents_clause
@ -2305,7 +2305,7 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu
SELECT * SELECT *
FROM tgrupo FROM tgrupo
WHERE id_grupo IN (" . $user_groups_ids . ") WHERE id_grupo IN (" . $user_groups_ids . ")
ORDER BY nombre COLLATE utf8_general_ci ASC"); ORDER BY nombre ASC");
break; break;
} }
} }

View File

@ -1960,10 +1960,10 @@ function modules_get_relations ($params = array()) {
$sql = "SELECT DISTINCT tmr.id, tmr.module_a, tmr.module_b, $sql = "SELECT DISTINCT tmr.id, tmr.module_a, tmr.module_b,
tmr.disable_update tmr.disable_update
FROM tmodule_relationship AS tmr, FROM tmodule_relationship tmr,
tagente_modulo AS tam, tagente_modulo tam,
tagente AS ta, tagente ta,
ttipo_modulo AS ttm ttipo_modulo ttm
WHERE "; WHERE ";
$agent_filter = ""; $agent_filter = "";

View File

@ -1429,7 +1429,7 @@ function tags_get_agents_counter ($id_tag, $groups_and_tags = array(), $agent_fi
$module_status_array = array_unique($module_status_array); $module_status_array = array_unique($module_status_array);
$status_str = implode(",", $module_status_array); $status_str = implode(",", $module_status_array);
$module_status_filter = "INNER JOIN tagente_estado AS tae $module_status_filter = "INNER JOIN tagente_estado tae
ON tam.id_agente_modulo = tae.id_agente_modulo ON tam.id_agente_modulo = tae.id_agente_modulo
AND tae.estado IN ($status_str)"; AND tae.estado IN ($status_str)";
} }
@ -1439,13 +1439,13 @@ function tags_get_agents_counter ($id_tag, $groups_and_tags = array(), $agent_fi
$count = 0; $count = 0;
if ($realtime) { if ($realtime) {
$sql = "SELECT DISTINCT ta.id_agente $sql = "SELECT DISTINCT ta.id_agente
FROM tagente AS ta FROM tagente ta
INNER JOIN tagente_modulo AS tam INNER JOIN tagente_modulo tam
ON ta.id_agente = tam.id_agente ON ta.id_agente = tam.id_agente
AND tam.disabled = 0 AND tam.disabled = 0
$module_name_filter $module_name_filter
$module_status_filter $module_status_filter
INNER JOIN ttag_module AS ttm INNER JOIN ttag_module ttm
ON ttm.id_tag = $id_tag ON ttm.id_tag = $id_tag
AND tam.id_agente_modulo = ttm.id_agente_modulo AND tam.id_agente_modulo = ttm.id_agente_modulo
WHERE ta.disabled = 0 WHERE ta.disabled = 0
@ -1602,13 +1602,13 @@ function tags_get_agents_counter ($id_tag, $groups_and_tags = array(), $agent_fi
} }
$sql = "SELECT COUNT(DISTINCT ta.id_agente) $sql = "SELECT COUNT(DISTINCT ta.id_agente)
FROM tagente AS ta FROM tagente ta
INNER JOIN tagente_modulo AS tam INNER JOIN tagente_modulo tam
ON ta.id_agente = tam.id_agente ON ta.id_agente = tam.id_agente
AND tam.disabled = 0 AND tam.disabled = 0
$module_name_filter $module_name_filter
$module_status_filter $module_status_filter
INNER JOIN ttag_module AS ttm INNER JOIN ttag_module ttm
ON ttm.id_tag = $id_tag ON ttm.id_tag = $id_tag
AND tam.id_agente_modulo = ttm.id_agente_modulo AND tam.id_agente_modulo = ttm.id_agente_modulo
WHERE ta.disabled = 0 WHERE ta.disabled = 0
@ -1892,14 +1892,14 @@ function tags_get_monitors_counter ($id_tag, $groups_and_tags = array(), $agent_
} }
$sql = "SELECT COUNT(DISTINCT tam.id_agente_modulo) $sql = "SELECT COUNT(DISTINCT tam.id_agente_modulo)
FROM tagente_modulo AS tam FROM tagente_modulo tam
INNER JOIN tagente_estado AS tae INNER JOIN tagente_estado tae
ON tam.id_agente_modulo = tae.id_agente_modulo ON tam.id_agente_modulo = tae.id_agente_modulo
$modules_clause $modules_clause
INNER JOIN ttag_module AS ttm INNER JOIN ttag_module ttm
ON ttm.id_tag = $id_tag ON ttm.id_tag = $id_tag
AND tam.id_agente_modulo = ttm.id_agente_modulo AND tam.id_agente_modulo = ttm.id_agente_modulo
INNER JOIN tagente AS ta INNER JOIN tagente ta
ON tam.id_agente = ta.id_agente ON tam.id_agente = ta.id_agente
AND ta.disabled = 0 AND ta.disabled = 0
$agent_name_filter $agent_name_filter

View File

@ -307,9 +307,9 @@ if (empty($id_groups)) {
else { else {
$whereAlertSimple .= ' AND id_agent_module IN ( $whereAlertSimple .= ' AND id_agent_module IN (
SELECT tam.id_agente_modulo SELECT tam.id_agente_modulo
FROM tagente_modulo AS tam FROM tagente_modulo tam
WHERE tam.id_agente IN (SELECT ta.id_agente WHERE tam.id_agente IN (SELECT ta.id_agente
FROM tagente AS ta FROM tagente ta
WHERE ta.id_grupo IN (' . implode(',', $id_groups) . '))) '; WHERE ta.id_grupo IN (' . implode(',', $id_groups) . '))) ';
} }