From 5a0b3eb4a18a898ecdd67f2de4885b5301ee713e Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Tue, 3 May 2022 18:10:42 +0200 Subject: [PATCH] #8930 Fixed prune agents --- pandora_console/include/class/Tree.class.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/pandora_console/include/class/Tree.class.php b/pandora_console/include/class/Tree.class.php index 8d99fb6d82..fb88063623 100644 --- a/pandora_console/include/class/Tree.class.php +++ b/pandora_console/include/class/Tree.class.php @@ -811,7 +811,7 @@ class Tree } } - // Counters + // Counters. if (empty($agent['counters'])) { $agent['counters'] = []; @@ -824,7 +824,7 @@ class Tree $agent['counters']['alerts'] = isset($agent['fired_count']) ? $agent['fired_count'] : 0; } - // Status image + // Status image. $agent['statusImageHTML'] = agents_tree_view_status_img_ball( $agent['counters']['critical'], $agent['counters']['warning'], @@ -834,7 +834,14 @@ class Tree $agent['counters']['alerts'] ); - // search module recalculate counters + $agent['agentStatus'] = -1; + if ((bool) $this->filter['show_not_init_agents'] === true) { + if ($agent['total_count'] === 0 || $agent['total_count'] === $agent['notinit_count']) { + $agent['agentStatus'] = AGENT_STATUS_NOT_INIT; + } + } + + // Search module recalculate counters. if (array_key_exists('state_normal', $agent)) { $agent['counters']['unknown'] = $agent['state_unknown']; $agent['counters']['critical'] = $agent['state_critical']; @@ -935,7 +942,8 @@ class Tree foreach ($agents as $iterator => $agent) { $this->processAgent($agents[$iterator], $server); if ($agents[$iterator]['counters']['total'] !== '0' - || (bool) $this->filter['show_not_init_agents'] === true + || ((bool) $this->filter['show_not_init_agents'] === true + && $agents[$iterator]['agentStatus'] === AGENT_STATUS_NOT_INIT) ) { $agents_aux[] = $agents[$iterator]; }