Added status group in metaconsole

Former-commit-id: cb1dcf221012f25c72ebcc0238475f5db1241835
This commit is contained in:
Daniel Maya 2019-04-23 15:40:54 +02:00
parent daa627441a
commit 5e3f3500c4
1 changed files with 30 additions and 2 deletions

View File

@ -225,8 +225,36 @@ final class Group extends Item
(int) $data['height']
);
} else {
// Get the status img src.
$status = \groups_get_status($groupId);
if (\is_metaconsole()) {
if ($groupId === 0) {
$groupId = \implode(',', \array_keys(\users_get_groups()));
}
$sql = 'SELECT SUM(fired_count) AS fired,
SUM(critical_count) AS critical,
SUM(warning_count) AS warning,
SUM(unknown_count) AS unknown
FROM tmetaconsole_agent
LEFT JOIN tmetaconsole_agent_secondary_group tasg
ON id_agente = tasg.id_agent
WHERE id_grupo IN ('.$groupId.') OR tasg.id_group IN ('.$groupId.')';
$countStatus = db_get_row_sql($sql);
if ($countStatus['fired'] > 0) {
$status = AGENT_STATUS_ALERT_FIRED;
} else if ($countStatus['critical'] > 0) {
$status = AGENT_STATUS_CRITICAL;
} else if ($countStatus['warning'] > 0) {
$status = AGENT_STATUS_WARNING;
} else if ($countStatus['unknown'] > 0) {
$status = AGENT_STATUS_UNKNOWN;
}
} else {
// Get the status img src.
$status = \groups_get_status($groupId);
}
$imagePath = \visual_map_get_image_status_element($data, $status);
$data['statusImageSrc'] = \ui_get_full_url(
$imagePath,