Merge branch '2641-no-se-filtran-eventos-por-grupo-secundario-en-meta' into 'develop'
2641 no se filtran eventos por grupo secundario en meta See merge request artica/pandorafms!1688
This commit is contained in:
commit
a4d1cfc9e6
|
@ -145,9 +145,10 @@ function events_get_events_grouped($sql_post, $offset = 0,
|
||||||
switch ($config["dbtype"]) {
|
switch ($config["dbtype"]) {
|
||||||
case "mysql":
|
case "mysql":
|
||||||
db_process_sql ('SET group_concat_max_len = 9999999');
|
db_process_sql ('SET group_concat_max_len = 9999999');
|
||||||
|
$event_lj = events_get_secondary_groups_left_join($table);
|
||||||
if ($total) {
|
if ($total) {
|
||||||
$sql = "SELECT COUNT(*) FROM (SELECT *
|
$sql = "SELECT COUNT(*) FROM (SELECT *
|
||||||
FROM $table te LEFT JOIN tagent_secondary_group tasg ON te.id_agente = tasg.id_agent
|
FROM $table te $event_lj
|
||||||
WHERE 1=1 " . $sql_post . "
|
WHERE 1=1 " . $sql_post . "
|
||||||
GROUP BY estado, evento, id_agente, id_agentmodule" . $groupby_extra . ") AS t";
|
GROUP BY estado, evento, id_agente, id_agentmodule" . $groupby_extra . ") AS t";
|
||||||
}
|
}
|
||||||
|
@ -163,7 +164,7 @@ function events_get_events_grouped($sql_post, $offset = 0,
|
||||||
(SELECT criticity FROM $table WHERE id_evento = MAX(te.id_evento)) AS criticity,
|
(SELECT criticity FROM $table WHERE id_evento = MAX(te.id_evento)) AS criticity,
|
||||||
(SELECT ack_utimestamp FROM $table WHERE id_evento = MAX(te.id_evento)) AS ack_utimestamp,
|
(SELECT ack_utimestamp FROM $table WHERE id_evento = MAX(te.id_evento)) AS ack_utimestamp,
|
||||||
(SELECT nombre FROM tagente_modulo WHERE id_agente_modulo = te.id_agentmodule) AS module_name
|
(SELECT nombre FROM tagente_modulo WHERE id_agente_modulo = te.id_agentmodule) AS module_name
|
||||||
FROM $table te LEFT JOIN tagent_secondary_group tasg ON te.id_agente = tasg.id_agent
|
FROM $table te $event_lj
|
||||||
WHERE 1=1 " . $sql_post . "
|
WHERE 1=1 " . $sql_post . "
|
||||||
GROUP BY estado, evento, id_agente, id_agentmodule" . $groupby_extra;
|
GROUP BY estado, evento, id_agente, id_agentmodule" . $groupby_extra;
|
||||||
$sql .= " " . events_get_sql_order($sort_field, $order, 2);
|
$sql .= " " . events_get_sql_order($sort_field, $order, 2);
|
||||||
|
@ -3323,13 +3324,13 @@ function events_get_events_grouped_by_agent($sql_post, $offset = 0,
|
||||||
$fields_extra = '';
|
$fields_extra = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$event_lj = events_get_secondary_groups_left_join($table);
|
||||||
if ($total) {
|
if ($total) {
|
||||||
$sql = "SELECT COUNT(*) FROM (select id_agente from $table WHERE 1=1
|
$sql = "SELECT COUNT(*) FROM (select id_agente from $table $event_lj WHERE 1=1
|
||||||
$sql_post GROUP BY id_agente, event_type$groupby_extra ORDER BY id_agente ) AS t";
|
$sql_post GROUP BY id_agente, event_type$groupby_extra ORDER BY id_agente ) AS t";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$sql = "select id_agente, count(*) as total$fields_extra from $table te LEFT JOIN tagent_secondary_group tasg
|
$sql = "select id_agente, count(*) as total$fields_extra from $table te $event_lj
|
||||||
ON te.id_agente = tasg.id_agent
|
|
||||||
WHERE id_agente > 0 $sql_post GROUP BY id_agente$groupby_extra ORDER BY id_agente LIMIT $offset,$pagination";
|
WHERE id_agente > 0 $sql_post GROUP BY id_agente$groupby_extra ORDER BY id_agente LIMIT $offset,$pagination";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3343,7 +3344,7 @@ function events_get_events_grouped_by_agent($sql_post, $offset = 0,
|
||||||
foreach ($events as $event) {
|
foreach ($events as $event) {
|
||||||
|
|
||||||
if ($meta) {
|
if ($meta) {
|
||||||
$sql = "select event_type from $table
|
$sql = "select event_type from $table te $event_lj
|
||||||
WHERE agent_name = '".$event['agent_name']."' $sql_post ORDER BY utimestamp DESC ";
|
WHERE agent_name = '".$event['agent_name']."' $sql_post ORDER BY utimestamp DESC ";
|
||||||
$resultado = db_get_row_sql($sql);
|
$resultado = db_get_row_sql($sql);
|
||||||
|
|
||||||
|
@ -3354,9 +3355,7 @@ function events_get_events_grouped_by_agent($sql_post, $offset = 0,
|
||||||
'event_type' => $resultado['event_type']);
|
'event_type' => $resultado['event_type']);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$sql = "SELECT event_type FROM $table te
|
$sql = "SELECT event_type FROM $table te $event_lj
|
||||||
LEFT JOIN tagent_secondary_group tasg
|
|
||||||
ON te.id_agente = tasg.id_agent
|
|
||||||
WHERE id_agente = ".$event['id_agente']." $sql_post ORDER BY utimestamp DESC ";
|
WHERE id_agente = ".$event['id_agente']." $sql_post ORDER BY utimestamp DESC ";
|
||||||
$resultado = db_get_row_sql($sql);
|
$resultado = db_get_row_sql($sql);
|
||||||
|
|
||||||
|
@ -4242,5 +4241,19 @@ function events_get_sql_order($sort_field = "timestamp", $sort = "DESC", $group_
|
||||||
return "ORDER BY $sort_field_translated $dir";
|
return "ORDER BY $sort_field_translated $dir";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SQL left join of event queries to handle secondary groups
|
||||||
|
*
|
||||||
|
* @param string Table to see if is metaconsole or not
|
||||||
|
*
|
||||||
|
* @return string With the query.
|
||||||
|
*/
|
||||||
|
function events_get_secondary_groups_left_join($table) {
|
||||||
|
if ($table == 'tevento') {
|
||||||
|
return "LEFT JOIN tagent_secondary_group tasg ON te.id_agente = tasg.id_agent";
|
||||||
|
}
|
||||||
|
return "LEFT JOIN tmetaconsole_agent_secondary_group tasg
|
||||||
|
ON te.id_agente = tasg.id_tagente AND te.server_id = tasg.id_tmetaconsole_setup";
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -740,13 +740,13 @@ echo "</div>";
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$event_table = events_get_events_table($meta, $history);
|
$event_table = events_get_events_table($meta, $history);
|
||||||
|
$event_lj = events_get_secondary_groups_left_join($event_table);
|
||||||
|
|
||||||
if ($group_rep == 0) {
|
if ($group_rep == 0) {
|
||||||
$order_sql = events_get_sql_order($sort_field, $sort_order, $group_rep);
|
$order_sql = events_get_sql_order($sort_field, $sort_order, $group_rep);
|
||||||
$sql = "SELECT DISTINCT te.*, 1 event_rep,
|
$sql = "SELECT DISTINCT te.*, 1 event_rep,
|
||||||
(SELECT nombre FROM tagente_modulo WHERE id_agente_modulo = te.id_agentmodule) AS module_name
|
(SELECT nombre FROM tagente_modulo WHERE id_agente_modulo = te.id_agentmodule) AS module_name
|
||||||
FROM $event_table te LEFT JOIN tagent_secondary_group tasg
|
FROM $event_table te $event_lj
|
||||||
ON te.id_agente = tasg.id_agent
|
|
||||||
WHERE 1=1 " . $sql_post . "
|
WHERE 1=1 " . $sql_post . "
|
||||||
$order_sql LIMIT ".$offset.",".$pagination;
|
$order_sql LIMIT ".$offset.",".$pagination;
|
||||||
|
|
||||||
|
@ -816,8 +816,7 @@ if (($config['dbtype'] == 'oracle') && ($result !== false)) {
|
||||||
if ($group_rep == 0) {
|
if ($group_rep == 0) {
|
||||||
$sql = "SELECT COUNT(DISTINCT id_evento)
|
$sql = "SELECT COUNT(DISTINCT id_evento)
|
||||||
FROM $event_table te
|
FROM $event_table te
|
||||||
LEFT JOIN tagent_secondary_group tasg
|
$event_lj
|
||||||
ON te.id_agente = tasg.id_agent
|
|
||||||
WHERE 1=1 $sql_post";
|
WHERE 1=1 $sql_post";
|
||||||
$total_events = (int) db_get_sql ($sql);
|
$total_events = (int) db_get_sql ($sql);
|
||||||
}
|
}
|
||||||
|
@ -827,8 +826,7 @@ elseif ($group_rep == 1) {
|
||||||
}
|
}
|
||||||
elseif ($group_rep == 2) {
|
elseif ($group_rep == 2) {
|
||||||
$sql = "SELECT COUNT(*) FROM (select id_agente as total from $event_table te
|
$sql = "SELECT COUNT(*) FROM (select id_agente as total from $event_table te
|
||||||
LEFT JOIN tagent_secondary_group tasg
|
$event_lj
|
||||||
ON te.id_grupo = tasg.id_group
|
|
||||||
WHERE id_agente > 0
|
WHERE id_agente > 0
|
||||||
$sql_post GROUP BY id_agente ORDER BY id_agente ) AS t";
|
$sql_post GROUP BY id_agente ORDER BY id_agente ) AS t";
|
||||||
$total_events = (int) db_get_sql ($sql);
|
$total_events = (int) db_get_sql ($sql);
|
||||||
|
|
Loading…
Reference in New Issue