diff --git a/pandora_console/include/functions_groupview.php b/pandora_console/include/functions_groupview.php index 7ababa9b95..9c1ae5841c 100644 --- a/pandora_console/include/functions_groupview.php +++ b/pandora_console/include/functions_groupview.php @@ -206,3 +206,43 @@ function groupview_get_groups_list($id_user=false, $access='AR', $is_not_paginat 'counter' => $counter, ]; } + + +function get_recursive_groups_heatmap($parent_group, $acl) +{ + if ($parent_group['counter'] > 0) { + foreach ($parent_group['groups'] as $group_key => $group_value) { + if ((int) $group_value['_id_'] === 0) { + continue; + } + + $childrens = groups_get_children($group_value['_id_'], true, $acl, false); + if (empty($childrens) === false) { + foreach ($childrens as $children) { + $children_status = groups_get_status($children['id_grupo']); + $parent_group['groups'][$group_key]['_monitor_checks_']++; + switch ($children_status) { + case AGENT_STATUS_CRITICAL: + $parent_group['groups'][$group_key]['_monitors_critical_']++; + break; + + case AGENT_STATUS_WARNING: + $parent_group['groups'][$group_key]['_monitors_warning_']++; + break; + + case AGENT_STATUS_UNKNOWN: + $parent_group['groups'][$group_key]['_monitors_unknown_']++; + break; + + case AGENT_STATUS_NORMAL: + default: + $parent_group['groups'][$group_key]['_monitors_ok_']++; + break; + } + } + } + } + } + + return $parent_group; +} diff --git a/pandora_console/include/lib/TacticalView/elements/Groups.php b/pandora_console/include/lib/TacticalView/elements/Groups.php index 860d10c130..f8bcf8392d 100644 --- a/pandora_console/include/lib/TacticalView/elements/Groups.php +++ b/pandora_console/include/lib/TacticalView/elements/Groups.php @@ -454,13 +454,17 @@ class Groups extends Element // ACL Check. $agent_a = check_acl($config['id_user'], 0, 'AR'); $agent_w = check_acl($config['id_user'], 0, 'AW'); + $acl = ($agent_a == true) ? 'AR' : (($agent_w == true) ? 'AW' : 'AR'); $groups_list = groupview_get_groups_list( $config['id_user'], - ($agent_a == true) ? 'AR' : (($agent_w == true) ? 'AW' : 'AR'), + $acl, true ); + // Recursive groups. + $groups_list = get_recursive_groups_heatmap($groups_list, $acl); + $total_groups = $groups_list['counter']; $groups = $groups_list['groups']; // Best square.