mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-29 16:55:05 +02:00
included secondary groups in tactical count queries
This commit is contained in:
parent
1fe0523a6a
commit
649fc829fb
@ -118,64 +118,106 @@ function tactical_get_data($id_user=false, $user_strict=false, $acltags, $return
|
|||||||
$user_groups_ids = implode(',', array_unique($user_group_children_ids));
|
$user_groups_ids = implode(',', array_unique($user_group_children_ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql_stats = "SELECT id_grupo, COUNT(id_agente) AS agents_total,
|
$sql_stats = sprintf(
|
||||||
SUM(total_count) AS monitors_total,
|
'SELECT tma.id_grupo, COUNT(tma.id_agente) AS agents_total,
|
||||||
SUM(normal_count) AS monitors_ok,
|
SUM(tma.total_count) AS monitors_total,
|
||||||
SUM(warning_count) AS monitors_warning,
|
SUM(tma.normal_count) AS monitors_ok,
|
||||||
SUM(critical_count) AS monitors_critical,
|
SUM(tma.warning_count) AS monitors_warning,
|
||||||
SUM(unknown_count) AS monitors_unknown,
|
SUM(tma.critical_count) AS monitors_critical,
|
||||||
SUM(notinit_count) AS monitors_not_init,
|
SUM(tma.unknown_count) AS monitors_unknown,
|
||||||
SUM(fired_count) AS alerts_fired
|
SUM(tma.notinit_count) AS monitors_not_init,
|
||||||
FROM $cache_table
|
SUM(tma.fired_count) AS alerts_fired
|
||||||
WHERE disabled = 0
|
FROM tmetaconsole_agent tma
|
||||||
AND id_grupo IN ($user_groups_ids)
|
LEFT JOIN tmetaconsole_agent_secondary_group tmasg
|
||||||
GROUP BY id_grupo";
|
ON tma.id_agente = tmasg.id_agent
|
||||||
|
WHERE tma.disabled = 0
|
||||||
|
AND tma.id_grupo IN (%s) OR tmasg.id_group IN (%s)
|
||||||
|
GROUP BY tma.id_grupo',
|
||||||
|
$user_groups_ids,
|
||||||
|
$user_groups_ids
|
||||||
|
);
|
||||||
|
|
||||||
$data_stats = db_get_all_rows_sql($sql_stats);
|
$data_stats = db_get_all_rows_sql($sql_stats);
|
||||||
|
|
||||||
$sql_stats_unknown = "SELECT id_grupo, COUNT(id_agente) AS agents_unknown
|
$sql_stats_unknown = sprintf(
|
||||||
FROM $cache_table
|
'SELECT tma.id_grupo, COUNT(tma.id_agente) AS agents_unknown
|
||||||
WHERE disabled = 0
|
FROM tmetaconsole_agent tma
|
||||||
AND id_grupo IN ($user_groups_ids)
|
LEFT JOIN tmetaconsole_agent_secondary_group tmasg
|
||||||
AND critical_count = 0
|
ON tma.id_agente = tmasg.id_agent
|
||||||
AND warning_count = 0
|
WHERE tma.disabled = 0
|
||||||
AND unknown_count > 0
|
AND (tma.id_grupo IN (%s) OR tmasg.id_group IN (%s))
|
||||||
GROUP BY id_grupo";
|
AND tma.critical_count = 0
|
||||||
|
AND tma.warning_count = 0
|
||||||
|
AND tma.unknown_count > 0
|
||||||
|
GROUP BY tma.id_grupo',
|
||||||
|
$user_groups_ids,
|
||||||
|
$user_groups_ids
|
||||||
|
);
|
||||||
|
|
||||||
$data_stats_unknown = db_get_all_rows_sql($sql_stats_unknown);
|
$data_stats_unknown = db_get_all_rows_sql($sql_stats_unknown);
|
||||||
|
|
||||||
$sql_stats_not_init = "SELECT id_grupo, COUNT(id_agente) AS agents_not_init
|
$sql_stats_not_init = sprintf(
|
||||||
FROM $cache_table
|
'SELECT tma.id_grupo, COUNT(tma.id_agente) AS agents_not_init
|
||||||
WHERE disabled = 0
|
FROM tmetaconsole_agent tma
|
||||||
AND id_grupo IN ($user_groups_ids)
|
LEFT JOIN tmetaconsole_agent_secondary_group tmasg
|
||||||
AND (total_count = 0 OR total_count = notinit_count)
|
ON tma.id_agente = tmasg.id_agent
|
||||||
GROUP BY id_grupo";
|
WHERE tma.disabled = 0
|
||||||
|
AND (tma.id_grupo IN (%s) OR tmasg.id_group IN (%s))
|
||||||
|
AND (tma.total_count = 0 OR tma.total_count = tma.notinit_count)
|
||||||
|
GROUP BY tma.id_grupo',
|
||||||
|
$user_groups_ids,
|
||||||
|
$user_groups_ids
|
||||||
|
);
|
||||||
|
|
||||||
$data_stats_not_init = db_get_all_rows_sql($sql_stats_not_init);
|
$data_stats_not_init = db_get_all_rows_sql($sql_stats_not_init);
|
||||||
|
|
||||||
$sql_stats_ok = "SELECT id_grupo, COUNT(id_agente) AS agents_ok
|
$sql_stats_ok = sprintf(
|
||||||
FROM $cache_table
|
'SELECT tma.id_grupo, COUNT(tma.id_agente) AS agents_ok
|
||||||
WHERE disabled = 0
|
FROM tmetaconsole_agent tma
|
||||||
AND id_grupo IN ($user_groups_ids)
|
LEFT JOIN tmetaconsole_agent_secondary_group tmasg
|
||||||
AND critical_count = 0
|
ON tma.id_agente = tmasg.id_agent
|
||||||
AND warning_count = 0
|
WHERE tma.disabled = 0
|
||||||
AND unknown_count = 0
|
AND (tma.id_grupo IN (%s) OR tmasg.id_group IN (%s))
|
||||||
AND normal_count > 0
|
AND tma.critical_count = 0
|
||||||
GROUP BY id_grupo";
|
AND tma.warning_count = 0
|
||||||
|
AND tma.unknown_count = 0
|
||||||
|
AND tma.normal_count > 0
|
||||||
|
GROUP BY tma.id_grupo',
|
||||||
|
$user_groups_ids,
|
||||||
|
$user_groups_ids
|
||||||
|
);
|
||||||
|
|
||||||
$data_stats_ok = db_get_all_rows_sql($sql_stats_ok);
|
$data_stats_ok = db_get_all_rows_sql($sql_stats_ok);
|
||||||
|
|
||||||
$sql_stats_warning = "SELECT id_grupo, COUNT(id_agente) AS agents_warning
|
$sql_stats_warning = sprintf(
|
||||||
FROM $cache_table
|
'SELECT tma.id_grupo, COUNT(tma.id_agente) AS agents_warning
|
||||||
WHERE disabled = 0
|
FROM tmetaconsole_agent tma
|
||||||
AND id_grupo IN ($user_groups_ids)
|
LEFT JOIN tmetaconsole_agent_secondary_group tmasg
|
||||||
AND critical_count = 0
|
ON tma.id_agente = tmasg.id_agent
|
||||||
AND warning_count > 0
|
WHERE tma.disabled = 0
|
||||||
GROUP BY id_grupo";
|
AND (tma.id_grupo IN (%s) OR tmasg.id_group IN (%s))
|
||||||
|
AND tma.critical_count = 0
|
||||||
|
AND tma.warning_count > 0
|
||||||
|
GROUP BY tma.id_grupo',
|
||||||
|
$user_groups_ids,
|
||||||
|
$user_groups_ids
|
||||||
|
);
|
||||||
|
|
||||||
$data_stats_warning = db_get_all_rows_sql($sql_stats_warning);
|
$data_stats_warning = db_get_all_rows_sql($sql_stats_warning);
|
||||||
|
|
||||||
$sql_stats_critical = "SELECT id_grupo, COUNT(id_agente) AS agents_critical
|
$sql_stats_critical = sprintf(
|
||||||
FROM $cache_table
|
'SELECT tma.id_grupo, COUNT(tma.id_agente) AS agents_critical
|
||||||
WHERE disabled = 0
|
FROM tmetaconsole_agent tma
|
||||||
AND id_grupo IN ($user_groups_ids)
|
LEFT JOIN tmetaconsole_agent_secondary_group tmasg
|
||||||
AND critical_count > 0
|
ON tma.id_agente = tmasg.id_agent
|
||||||
GROUP BY id_grupo";
|
WHERE tma.disabled = 0
|
||||||
|
AND (tma.id_grupo IN (%s) OR tmasg.id_group IN (%s))
|
||||||
|
AND tma.critical_count > 0
|
||||||
|
GROUP BY tma.id_grupo',
|
||||||
|
$user_groups_ids,
|
||||||
|
$user_groups_ids
|
||||||
|
);
|
||||||
|
|
||||||
$data_stats_critical = db_get_all_rows_sql($sql_stats_critical);
|
$data_stats_critical = db_get_all_rows_sql($sql_stats_critical);
|
||||||
|
|
||||||
if (!empty($data_stats)) {
|
if (!empty($data_stats)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user