Merge branch 'ent-10067-anadir-filtro-alerts-triggered-en-tree-view-y-widget-tree-view' into 'develop'
Ent 10067 anadir filtro alerts triggered en tree view y widget tree view See merge request artica/pandorafms!5662
This commit is contained in:
commit
e4fd12f6de
|
@ -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';
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
@ -396,6 +404,7 @@ class TreeViewWidget extends Widget
|
|||
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) {
|
||||
|
|
|
@ -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 = '';
|
||||
?>
|
||||
|
||||
<?php if (is_metaconsole() === false) { ?>
|
||||
|
|
Loading…
Reference in New Issue