From feb2f3ffa29f91ff35773b355961ff1ea8f6087d Mon Sep 17 00:00:00 2001 From: Pablo Aragon Date: Mon, 13 Feb 2023 15:03:23 +0100 Subject: [PATCH] 10092-Widget tree view, Not normal status --- pandora_console/include/class/Tree.class.php | 21 +++++++++++++++ .../include/javascript/pandora_dashboards.js | 5 ++++ .../lib/Dashboard/Widgets/tree_view.php | 27 ++++++++++++++----- pandora_console/operation/tree.php | 7 ++++- 4 files changed, 53 insertions(+), 7 deletions(-) diff --git a/pandora_console/include/class/Tree.class.php b/pandora_console/include/class/Tree.class.php index fb88063623..bf3fbf9b5d 100644 --- a/pandora_console/include/class/Tree.class.php +++ b/pandora_console/include/class/Tree.class.php @@ -214,6 +214,11 @@ class Tree AND ta.unknown_count = 0 AND ta.normal_count > 0) '; break; + + case AGENT_STATUS_NOT_NORMAL: + $agent_status_filter = ' AND (ta.critical_count > 0 + OR ta.warning_count > 0) '; + break; } return $agent_status_filter; @@ -285,6 +290,10 @@ class Tree return $show_init_condition; } + if ((int) $this->filter['statusModule'] === 6) { + return ' AND (ta.warning_count > 0 OR ta.critical_count > 0)'; + } + $field_filter = modules_get_counter_by_states($this->filter['statusModule']); if ($field_filter === false) { return ' AND 1=0'; @@ -894,6 +903,18 @@ class Tree $agent['counters']['ok'] = $agent['normal_count']; $agent['counters']['total'] = $agent['normal_count']; break; + + case AGENT_MODULE_STATUS_NOT_NORMAL: + if (empty($agent['critical_count']) === false) { + $agent['counters']['critical'] = $agent['critical_count']; + } + + if (empty($agent['warning_count']) === false) { + $agent['counters']['warning'] = $agent['warning_count']; + } + + $agent['counters']['total'] = ($agent['warning_count'] + $agent['critical_count']); + break; } } diff --git a/pandora_console/include/javascript/pandora_dashboards.js b/pandora_console/include/javascript/pandora_dashboards.js index 02b8e47c08..cac0d10d97 100644 --- a/pandora_console/include/javascript/pandora_dashboards.js +++ b/pandora_console/include/javascript/pandora_dashboards.js @@ -956,6 +956,11 @@ function processTreeSearch(settings) { agents: settings.translate.ok.agents, modules: settings.translate.ok.modules, none: settings.translate.ok.none + }, + not_normal: { + agents: settings.translate.not_normal.agents, + modules: settings.translate.not_normal.modules, + none: settings.translate.not_normal.none } } }); diff --git a/pandora_console/include/lib/Dashboard/Widgets/tree_view.php b/pandora_console/include/lib/Dashboard/Widgets/tree_view.php index 2c0441ead8..954a6930e6 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/tree_view.php +++ b/pandora_console/include/lib/Dashboard/Widgets/tree_view.php @@ -243,6 +243,10 @@ class TreeViewWidget extends Widget $values['agentStatus'] = AGENT_STATUS_NOT_INIT; break; + case 6: + $values['agentStatus'] = AGENT_STATUS_NOT_NORMAL; + break; + default: case -1: $values['agentStatus'] = AGENT_STATUS_ALL; @@ -284,6 +288,10 @@ class TreeViewWidget extends Widget $values['moduleStatus'] = AGENT_MODULE_STATUS_NOT_INIT; break; + case 6: + $values['moduleStatus'] = AGENT_MODULE_STATUS_NOT_NORMAL; + break; + default: case -1: $values['moduleStatus'] = -1; @@ -381,12 +389,13 @@ class TreeViewWidget extends Widget // Agents status. $fields = [ - AGENT_STATUS_ALL => __('All'), - AGENT_STATUS_NORMAL => __('Normal'), - AGENT_STATUS_WARNING => __('Warning'), - AGENT_STATUS_CRITICAL => __('Critical'), - AGENT_STATUS_UNKNOWN => __('Unknown'), - AGENT_STATUS_NOT_INIT => __('Not init'), + AGENT_STATUS_ALL => __('All'), + AGENT_STATUS_NORMAL => __('Normal'), + AGENT_STATUS_WARNING => __('Warning'), + AGENT_STATUS_CRITICAL => __('Critical'), + AGENT_STATUS_UNKNOWN => __('Unknown'), + AGENT_STATUS_NOT_INIT => __('Not init'), + AGENT_STATUS_NOT_NORMAL => __('Not normal'), ]; $inputs[] = [ @@ -420,6 +429,7 @@ class TreeViewWidget extends Widget AGENT_MODULE_STATUS_CRITICAL_BAD => __('Critical'), AGENT_MODULE_STATUS_UNKNOWN => __('Unknown'), AGENT_MODULE_STATUS_NOT_INIT => __('Not init'), + AGENT_MODULE_STATUS_NOT_NORMAL => __('Not normal'), ]; if (is_metaconsole() === false) { @@ -682,6 +692,11 @@ class TreeViewWidget extends Widget 'modules' => __('Normal modules'), 'none' => __('Normal'), ], + 'not_normal' => [ + 'agents' => __('Not normal agents'), + 'modules' => __('Not normal modules'), + 'none' => __('Not normal'), + ], 'module' => __('Module'), 'timeOnlyTitle' => __('Choose time'), 'timeText' => __('Time'), diff --git a/pandora_console/operation/tree.php b/pandora_console/operation/tree.php index ece2266800..e0e5f7aef1 100755 --- a/pandora_console/operation/tree.php +++ b/pandora_console/operation/tree.php @@ -484,7 +484,12 @@ enterprise_hook('close_meta_frame'); agents: "", modules: "", none: "" - } + }, + not_normal: { + agents: "", + modules: "", + none: "" + }, } }); }