From 5e3f3500c43aaf2cf7d809638bd6dcc8691d00e7 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Tue, 23 Apr 2019 15:40:54 +0200 Subject: [PATCH] Added status group in metaconsole Former-commit-id: cb1dcf221012f25c72ebcc0238475f5db1241835 --- .../models/VisualConsole/Items/Group.php | 32 +++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/rest-api/models/VisualConsole/Items/Group.php b/pandora_console/include/rest-api/models/VisualConsole/Items/Group.php index 8d6f277315..b06a145cf7 100644 --- a/pandora_console/include/rest-api/models/VisualConsole/Items/Group.php +++ b/pandora_console/include/rest-api/models/VisualConsole/Items/Group.php @@ -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,