diff --git a/pandora_console/include/class/Tree.class.php b/pandora_console/include/class/Tree.class.php index c5af28b54f..b6aca966a7 100644 --- a/pandora_console/include/class/Tree.class.php +++ b/pandora_console/include/class/Tree.class.php @@ -133,6 +133,11 @@ class Tree protected function getEmptyModuleFilterStatus() { + if ($this->filter['statusModule'] === 'fired') { + $this->filter['statusModuleOriginal'] = $this->filter['statusModule']; + $this->filter['statusModule'] = -1; + } + return ( !isset($this->filter['statusModule']) || $this->filter['statusModule'] == -1 @@ -219,6 +224,10 @@ class Tree $agent_status_filter = ' AND (ta.critical_count > 0 OR ta.warning_count > 0) '; break; + + case AGENT_STATUS_ALERT_FIRED: + $agent_status_filter = ' AND ta.fired_count > 0 '; + break; } return $agent_status_filter; @@ -284,6 +293,11 @@ class Tree protected function getModuleStatusFilter() { + if ($this->filter['statusModule'] === 'fired') { + $this->filter['statusModuleOriginal'] = $this->filter['statusModule']; + $this->filter['statusModule'] = -1; + } + $show_init_condition = ($this->filter['show_not_init_agents']) ? '' : ' AND ta.notinit_count <> ta.total_count'; if ($this->getEmptyModuleFilterStatus()) { @@ -294,6 +308,10 @@ class Tree return ' AND (ta.warning_count > 0 OR ta.critical_count > 0)'; } + if ($this->filter['statusModule'] === 'fired') { + return ' AND ta.fired_count > 0'; + } + $field_filter = modules_get_counter_by_states($this->filter['statusModule']); if ($field_filter === false) { return ' AND 1=0'; @@ -333,6 +351,11 @@ class Tree protected function getModuleStatusFilterFromTestado($state=false, $without_ands=false) { + if ($this->filter['statusModule'] === 'fired') { + $this->filter['statusModuleOriginal'] = $this->filter['statusModule']; + $this->filter['statusModule'] = -1; + } + $selected_status = ($state !== false && $state !== self::TV_DEFAULT_AGENT_STATUS) ? $state : $this->filter['statusModule']; $filter = [modules_get_state_condition($selected_status)]; @@ -811,6 +834,11 @@ class Tree protected function processAgent(&$agent, $server=false) { + if ($this->filter['statusModule'] === 'fired') { + $this->filter['statusModuleOriginal'] = $this->filter['statusModule']; + $this->filter['statusModule'] = -1; + } + global $config; $agent['type'] = 'agent'; diff --git a/pandora_console/include/javascript/tree/TreeController.js b/pandora_console/include/javascript/tree/TreeController.js index 59a4f43d50..a32a749c5e 100644 --- a/pandora_console/include/javascript/tree/TreeController.js +++ b/pandora_console/include/javascript/tree/TreeController.js @@ -1381,7 +1381,6 @@ var TreeController = { .removeClass("leaf-closed") .removeClass("leaf-error") .addClass("leaf-loading"); - $.ajax({ url: controller.ajaxURL, type: "POST", @@ -1413,6 +1412,53 @@ var TreeController = { data.tree.length > 0) || $group.length > 0 ) { + if (controller.filter.statusModule === "fired") { + var newData = { success: data.success, tree: [] }; + + data.tree.forEach(element => { + // Agents. + if ( + typeof element.counters !== "undefined" && + element.counters.alerts > 0 + ) { + var treeTmp = element; + + treeTmp.counters.critical = 0; + treeTmp.counters.not_init = 0; + treeTmp.counters.ok = 0; + treeTmp.counters.unknown = 0; + treeTmp.counters.warning = 0; + treeTmp.counters.total = + element.counters.alerts; + + treeTmp.critical_count = 0; + treeTmp.normal_count = 0; + treeTmp.notinit_count = 0; + treeTmp.unknown_count = 0; + treeTmp.warning_count = 0; + treeTmp.total_count = element.fired_count; + + treeTmp.state_critical = 0; + treeTmp.state_normal = 0; + treeTmp.state_notinit = 0; + treeTmp.state_unknown = 0; + treeTmp.state_warning = 0; + treeTmp.state_total = element.fired_count; + + newData.tree.push(treeTmp); + data = newData; + } + + // Modules. + if (element.alerts > 0) { + var treeTmp = element; + + newData.tree.push(treeTmp); + data = newData; + } + }); + } + $node.addClass("leaf-open"); if ($group.length <= 0) { @@ -1513,6 +1559,34 @@ var TreeController = { this.reload(); }, init: function(data) { + if (data.filter.statusModule === "fired") { + const newData = { + ajaxUrl: data.ajaxURL, + baseURL: data.baseURL, + counterTitle: data.counterTitle, + detailRecipient: data.detailRecipient, + emptyMessage: data.emptyMessage, + filter: data.filter, + foundMessage: data.foundMessage, + page: data.page, + recipient: data.recipient, + tree: [] + }; + data.tree.forEach(element => { + if (element.counters.alerts > 0) { + element.counters.critical = 0; + element.counters.not_init = 0; + element.counters.ok = 0; + element.counters.unknown = 0; + element.counters.warning = 0; + element.counters.total = element.counters.alerts; + + newData.tree.push(element); + } + }); + + data = newData; + } if ( typeof data.recipient !== "undefined" && data.recipient.length > 0 diff --git a/pandora_console/include/lib/Dashboard/Widgets/tree_view.php b/pandora_console/include/lib/Dashboard/Widgets/tree_view.php index a351f8b156..1e811c0592 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/tree_view.php +++ b/pandora_console/include/lib/Dashboard/Widgets/tree_view.php @@ -239,6 +239,10 @@ class TreeViewWidget extends Widget $values['agentStatus'] = AGENT_STATUS_UNKNOWN; break; + case 4: + $values['agentStatus'] = AGENT_STATUS_ALERT_FIRED; + break; + case 5: $values['agentStatus'] = AGENT_STATUS_NOT_INIT; break; @@ -292,6 +296,10 @@ class TreeViewWidget extends Widget $values['moduleStatus'] = AGENT_MODULE_STATUS_NOT_NORMAL; break; + case 'fired': + $values['moduleStatus'] = 'fired'; + break; + default: case -1: $values['moduleStatus'] = -1; @@ -389,13 +397,14 @@ 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_NOT_NORMAL => __('Not normal'), + 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'), + AGENT_STATUS_ALERT_FIRED => __('Fired alerts'), ]; $inputs[] = [ @@ -430,6 +439,7 @@ class TreeViewWidget extends Widget AGENT_MODULE_STATUS_UNKNOWN => __('Unknown'), AGENT_MODULE_STATUS_NOT_INIT => __('Not init'), AGENT_MODULE_STATUS_NOT_NORMAL => __('Not normal'), + 'fired' => __('Fired alerts'), ]; if (is_metaconsole() === false) { diff --git a/pandora_console/operation/tree.php b/pandora_console/operation/tree.php index 35f960744b..8ca4343ea0 100755 --- a/pandora_console/operation/tree.php +++ b/pandora_console/operation/tree.php @@ -210,6 +210,7 @@ $agent_status_arr[AGENT_STATUS_WARNING] = __('Warning'); $agent_status_arr[AGENT_STATUS_CRITICAL] = __('Critical'); $agent_status_arr[AGENT_STATUS_UNKNOWN] = __('Unknown'); $agent_status_arr[AGENT_STATUS_NOT_INIT] = __('Not init'); +$agent_status_arr[AGENT_STATUS_ALERT_FIRED] = __('Fired alerts'); $table->data['group_row'][] = html_print_label_input_block( __('Search group'), @@ -271,7 +272,7 @@ $table->data['agent_row'][] = html_print_label_input_block( 0, true, false, - true, + false, '', false, 'width:100%' @@ -300,6 +301,7 @@ if (is_metaconsole() === false) { $module_status_arr[AGENT_MODULE_STATUS_CRITICAL_BAD] = __('Critical'); $module_status_arr[AGENT_MODULE_STATUS_UNKNOWN] = __('Unknown'); $module_status_arr[AGENT_MODULE_STATUS_NOT_INIT] = __('Not init'); + $module_status_arr['fired'] = __('Fired alerts'); $table->data['last_row'][] = html_print_label_input_block( __('Search module'), @@ -322,7 +324,7 @@ if (is_metaconsole() === false) { 0, true, false, - true, + false, '', false, 'width:100%' @@ -380,7 +382,7 @@ html_print_div( ] ); -$infoHeadTitle = 'Sombra oscura'; +$infoHeadTitle = ''; ?>