Ent 3977 conteo módulos de agente con grupos secundarios
This commit is contained in:
parent
828203ed06
commit
8572540f9a
|
@ -47,37 +47,13 @@ function tactical_get_data($id_user=false, $user_strict=false, $acltags, $return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($user_groups_ids)) {
|
if (!empty($user_groups_ids)) {
|
||||||
switch ($config['dbtype']) {
|
$list_groups = db_get_all_rows_sql(
|
||||||
case 'mysql':
|
'
|
||||||
$list_groups = db_get_all_rows_sql(
|
SELECT *
|
||||||
'
|
FROM tgrupo
|
||||||
SELECT *
|
WHERE id_grupo IN ('.$user_groups_ids.')
|
||||||
FROM tgrupo
|
ORDER BY nombre COLLATE utf8_general_ci ASC'
|
||||||
WHERE id_grupo IN ('.$user_groups_ids.')
|
);
|
||||||
ORDER BY nombre COLLATE utf8_general_ci ASC'
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'postgresql':
|
|
||||||
$list_groups = db_get_all_rows_sql(
|
|
||||||
'
|
|
||||||
SELECT *
|
|
||||||
FROM tgrupo
|
|
||||||
WHERE id_grupo IN ('.$user_groups_ids.')
|
|
||||||
ORDER BY nombre ASC'
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'oracle':
|
|
||||||
$list_groups = db_get_all_rows_sql(
|
|
||||||
'
|
|
||||||
SELECT *
|
|
||||||
FROM tgrupo
|
|
||||||
WHERE id_grupo IN ('.$user_groups_ids.')
|
|
||||||
ORDER BY nombre ASC'
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$list = [];
|
$list = [];
|
||||||
|
@ -242,14 +218,36 @@ function tactical_get_data($id_user=false, $user_strict=false, $acltags, $return
|
||||||
|
|
||||||
$list['_server_sanity_'] = format_numeric((100 - $list['_module_sanity_']), 1);
|
$list['_server_sanity_'] = format_numeric((100 - $list['_module_sanity_']), 1);
|
||||||
} else if (($config['realtimestats'] == 0)) {
|
} else if (($config['realtimestats'] == 0)) {
|
||||||
$group_stat = db_get_all_rows_sql(
|
if (users_is_admin()) {
|
||||||
"SELECT
|
$group_stat = db_get_all_rows_sql(
|
||||||
SUM(ta.normal_count) as normal, SUM(ta.critical_count) as critical,
|
sprintf(
|
||||||
SUM(ta.warning_count) as warning,SUM(ta.unknown_count) as unknown,
|
'SELECT
|
||||||
SUM(ta.notinit_count) as not_init, SUM(fired_count) as alerts_fired
|
SUM(ta.normal_count) as normal, SUM(ta.critical_count) as critical,
|
||||||
FROM tagente ta
|
SUM(ta.warning_count) as warning,SUM(ta.unknown_count) as unknown,
|
||||||
WHERE disabled = 0 AND id_grupo IN ($user_groups_ids)"
|
SUM(ta.notinit_count) as not_init, SUM(ta.fired_count) as alerts_fired
|
||||||
);
|
FROM tagente ta
|
||||||
|
WHERE ta.disabled = 0 AND ta.id_grupo IN (%s)
|
||||||
|
',
|
||||||
|
$user_groups_ids
|
||||||
|
)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$group_stat = db_get_all_rows_sql(
|
||||||
|
sprintf(
|
||||||
|
'SELECT
|
||||||
|
SUM(ta.normal_count) as normal, SUM(ta.critical_count) as critical,
|
||||||
|
SUM(ta.warning_count) as warning,SUM(ta.unknown_count) as unknown,
|
||||||
|
SUM(ta.notinit_count) as not_init, SUM(ta.fired_count) as alerts_fired
|
||||||
|
FROM tagente ta
|
||||||
|
LEFT JOIN tagent_secondary_group tasg
|
||||||
|
ON ta.id_agente = tasg.id_agent
|
||||||
|
WHERE ta.disabled = 0 AND
|
||||||
|
(ta.id_grupo IN ( %s ) OR tasg.id_group IN ( %s ))',
|
||||||
|
$user_groups_ids,
|
||||||
|
$user_groups_ids
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$list['_agents_unknown_'] = $group_stat[0]['unknown'];
|
$list['_agents_unknown_'] = $group_stat[0]['unknown'];
|
||||||
$list['_monitors_alerts_fired_'] = $group_stat[0]['alerts_fired'];
|
$list['_monitors_alerts_fired_'] = $group_stat[0]['alerts_fired'];
|
||||||
|
@ -303,19 +301,41 @@ function tactical_get_data($id_user=false, $user_strict=false, $acltags, $return
|
||||||
|
|
||||||
$list['_server_sanity_'] = format_numeric((100 - $list['_module_sanity_']), 1);
|
$list['_server_sanity_'] = format_numeric((100 - $list['_module_sanity_']), 1);
|
||||||
} else {
|
} else {
|
||||||
$_tag_condition = '';
|
if (users_is_admin()) {
|
||||||
$result_list = db_get_all_rows_sql(
|
$result_list = db_get_all_rows_sql(
|
||||||
"SELECT COUNT(*) as contado, estado
|
sprintf(
|
||||||
FROM tagente_estado tae INNER JOIN tagente ta
|
'SELECT COUNT(*) as contado, estado FROM tagente_estado tae
|
||||||
ON tae.id_agente = ta.id_agente
|
INNER JOIN tagente ta
|
||||||
AND ta.disabled = 0
|
ON tae.id_agente = ta.id_agente
|
||||||
AND ta.id_grupo IN ( $user_groups_ids )
|
AND ta.disabled = 0
|
||||||
INNER JOIN tagente_modulo tam
|
AND ta.id_grupo IN ( %s )
|
||||||
ON tae.id_agente_modulo = tam.id_agente_modulo
|
INNER JOIN tagente_modulo tam
|
||||||
AND tam.disabled = 0
|
ON tae.id_agente_modulo = tam.id_agente_modulo
|
||||||
$_tag_condition
|
AND tam.disabled = 0
|
||||||
GROUP BY estado"
|
GROUP BY estado',
|
||||||
);
|
$user_groups_ids
|
||||||
|
)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$result_list = db_get_all_rows_sql(
|
||||||
|
sprintf(
|
||||||
|
'SELECT COUNT(*) as contado, estado
|
||||||
|
FROM tagente_estado tae
|
||||||
|
INNER JOIN tagente ta
|
||||||
|
ON tae.id_agente = ta.id_agente
|
||||||
|
AND ta.disabled = 0
|
||||||
|
INNER JOIN tagente_modulo tam
|
||||||
|
ON tae.id_agente_modulo = tam.id_agente_modulo
|
||||||
|
AND tam.disabled = 0
|
||||||
|
LEFT JOIN tagent_secondary_group tasg
|
||||||
|
ON ta.id_agente = tasg.id_agent
|
||||||
|
WHERE (ta.id_grupo IN ( %s ) OR tasg.id_group IN ( %s ))
|
||||||
|
GROUP BY estado',
|
||||||
|
$user_groups_ids,
|
||||||
|
$user_groups_ids
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($result_list)) {
|
if (empty($result_list)) {
|
||||||
$result_list = [];
|
$result_list = [];
|
||||||
|
|
Loading…
Reference in New Issue