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()
|
protected function getEmptyModuleFilterStatus()
|
||||||
{
|
{
|
||||||
|
if ($this->filter['statusModule'] === 'fired') {
|
||||||
|
$this->filter['statusModuleOriginal'] = $this->filter['statusModule'];
|
||||||
|
$this->filter['statusModule'] = -1;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
!isset($this->filter['statusModule']) ||
|
!isset($this->filter['statusModule']) ||
|
||||||
$this->filter['statusModule'] == -1
|
$this->filter['statusModule'] == -1
|
||||||
|
@ -219,6 +224,10 @@ class Tree
|
||||||
$agent_status_filter = ' AND (ta.critical_count > 0
|
$agent_status_filter = ' AND (ta.critical_count > 0
|
||||||
OR ta.warning_count > 0) ';
|
OR ta.warning_count > 0) ';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case AGENT_STATUS_ALERT_FIRED:
|
||||||
|
$agent_status_filter = ' AND ta.fired_count > 0 ';
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $agent_status_filter;
|
return $agent_status_filter;
|
||||||
|
@ -284,6 +293,11 @@ class Tree
|
||||||
|
|
||||||
protected function getModuleStatusFilter()
|
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';
|
$show_init_condition = ($this->filter['show_not_init_agents']) ? '' : ' AND ta.notinit_count <> ta.total_count';
|
||||||
|
|
||||||
if ($this->getEmptyModuleFilterStatus()) {
|
if ($this->getEmptyModuleFilterStatus()) {
|
||||||
|
@ -294,6 +308,10 @@ class Tree
|
||||||
return ' AND (ta.warning_count > 0 OR ta.critical_count > 0)';
|
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']);
|
$field_filter = modules_get_counter_by_states($this->filter['statusModule']);
|
||||||
if ($field_filter === false) {
|
if ($field_filter === false) {
|
||||||
return ' AND 1=0';
|
return ' AND 1=0';
|
||||||
|
@ -333,6 +351,11 @@ class Tree
|
||||||
|
|
||||||
protected function getModuleStatusFilterFromTestado($state=false, $without_ands=false)
|
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'];
|
$selected_status = ($state !== false && $state !== self::TV_DEFAULT_AGENT_STATUS) ? $state : $this->filter['statusModule'];
|
||||||
|
|
||||||
$filter = [modules_get_state_condition($selected_status)];
|
$filter = [modules_get_state_condition($selected_status)];
|
||||||
|
@ -811,6 +834,11 @@ class Tree
|
||||||
|
|
||||||
protected function processAgent(&$agent, $server=false)
|
protected function processAgent(&$agent, $server=false)
|
||||||
{
|
{
|
||||||
|
if ($this->filter['statusModule'] === 'fired') {
|
||||||
|
$this->filter['statusModuleOriginal'] = $this->filter['statusModule'];
|
||||||
|
$this->filter['statusModule'] = -1;
|
||||||
|
}
|
||||||
|
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
$agent['type'] = 'agent';
|
$agent['type'] = 'agent';
|
||||||
|
|
|
@ -1381,7 +1381,6 @@ var TreeController = {
|
||||||
.removeClass("leaf-closed")
|
.removeClass("leaf-closed")
|
||||||
.removeClass("leaf-error")
|
.removeClass("leaf-error")
|
||||||
.addClass("leaf-loading");
|
.addClass("leaf-loading");
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: controller.ajaxURL,
|
url: controller.ajaxURL,
|
||||||
type: "POST",
|
type: "POST",
|
||||||
|
@ -1413,6 +1412,53 @@ var TreeController = {
|
||||||
data.tree.length > 0) ||
|
data.tree.length > 0) ||
|
||||||
$group.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");
|
$node.addClass("leaf-open");
|
||||||
|
|
||||||
if ($group.length <= 0) {
|
if ($group.length <= 0) {
|
||||||
|
@ -1513,6 +1559,34 @@ var TreeController = {
|
||||||
this.reload();
|
this.reload();
|
||||||
},
|
},
|
||||||
init: function(data) {
|
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 (
|
if (
|
||||||
typeof data.recipient !== "undefined" &&
|
typeof data.recipient !== "undefined" &&
|
||||||
data.recipient.length > 0
|
data.recipient.length > 0
|
||||||
|
|
|
@ -239,6 +239,10 @@ class TreeViewWidget extends Widget
|
||||||
$values['agentStatus'] = AGENT_STATUS_UNKNOWN;
|
$values['agentStatus'] = AGENT_STATUS_UNKNOWN;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 4:
|
||||||
|
$values['agentStatus'] = AGENT_STATUS_ALERT_FIRED;
|
||||||
|
break;
|
||||||
|
|
||||||
case 5:
|
case 5:
|
||||||
$values['agentStatus'] = AGENT_STATUS_NOT_INIT;
|
$values['agentStatus'] = AGENT_STATUS_NOT_INIT;
|
||||||
break;
|
break;
|
||||||
|
@ -292,6 +296,10 @@ class TreeViewWidget extends Widget
|
||||||
$values['moduleStatus'] = AGENT_MODULE_STATUS_NOT_NORMAL;
|
$values['moduleStatus'] = AGENT_MODULE_STATUS_NOT_NORMAL;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'fired':
|
||||||
|
$values['moduleStatus'] = 'fired';
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
case -1:
|
case -1:
|
||||||
$values['moduleStatus'] = -1;
|
$values['moduleStatus'] = -1;
|
||||||
|
@ -389,13 +397,14 @@ class TreeViewWidget extends Widget
|
||||||
|
|
||||||
// Agents status.
|
// Agents status.
|
||||||
$fields = [
|
$fields = [
|
||||||
AGENT_STATUS_ALL => __('All'),
|
AGENT_STATUS_ALL => __('All'),
|
||||||
AGENT_STATUS_NORMAL => __('Normal'),
|
AGENT_STATUS_NORMAL => __('Normal'),
|
||||||
AGENT_STATUS_WARNING => __('Warning'),
|
AGENT_STATUS_WARNING => __('Warning'),
|
||||||
AGENT_STATUS_CRITICAL => __('Critical'),
|
AGENT_STATUS_CRITICAL => __('Critical'),
|
||||||
AGENT_STATUS_UNKNOWN => __('Unknown'),
|
AGENT_STATUS_UNKNOWN => __('Unknown'),
|
||||||
AGENT_STATUS_NOT_INIT => __('Not init'),
|
AGENT_STATUS_NOT_INIT => __('Not init'),
|
||||||
AGENT_STATUS_NOT_NORMAL => __('Not normal'),
|
AGENT_STATUS_NOT_NORMAL => __('Not normal'),
|
||||||
|
AGENT_STATUS_ALERT_FIRED => __('Fired alerts'),
|
||||||
];
|
];
|
||||||
|
|
||||||
$inputs[] = [
|
$inputs[] = [
|
||||||
|
@ -430,6 +439,7 @@ class TreeViewWidget extends Widget
|
||||||
AGENT_MODULE_STATUS_UNKNOWN => __('Unknown'),
|
AGENT_MODULE_STATUS_UNKNOWN => __('Unknown'),
|
||||||
AGENT_MODULE_STATUS_NOT_INIT => __('Not init'),
|
AGENT_MODULE_STATUS_NOT_INIT => __('Not init'),
|
||||||
AGENT_MODULE_STATUS_NOT_NORMAL => __('Not normal'),
|
AGENT_MODULE_STATUS_NOT_NORMAL => __('Not normal'),
|
||||||
|
'fired' => __('Fired alerts'),
|
||||||
];
|
];
|
||||||
|
|
||||||
if (is_metaconsole() === false) {
|
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_CRITICAL] = __('Critical');
|
||||||
$agent_status_arr[AGENT_STATUS_UNKNOWN] = __('Unknown');
|
$agent_status_arr[AGENT_STATUS_UNKNOWN] = __('Unknown');
|
||||||
$agent_status_arr[AGENT_STATUS_NOT_INIT] = __('Not init');
|
$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(
|
$table->data['group_row'][] = html_print_label_input_block(
|
||||||
__('Search group'),
|
__('Search group'),
|
||||||
|
@ -271,7 +272,7 @@ $table->data['agent_row'][] = html_print_label_input_block(
|
||||||
0,
|
0,
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
true,
|
false,
|
||||||
'',
|
'',
|
||||||
false,
|
false,
|
||||||
'width:100%'
|
'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_CRITICAL_BAD] = __('Critical');
|
||||||
$module_status_arr[AGENT_MODULE_STATUS_UNKNOWN] = __('Unknown');
|
$module_status_arr[AGENT_MODULE_STATUS_UNKNOWN] = __('Unknown');
|
||||||
$module_status_arr[AGENT_MODULE_STATUS_NOT_INIT] = __('Not init');
|
$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(
|
$table->data['last_row'][] = html_print_label_input_block(
|
||||||
__('Search module'),
|
__('Search module'),
|
||||||
|
@ -322,7 +324,7 @@ if (is_metaconsole() === false) {
|
||||||
0,
|
0,
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
true,
|
false,
|
||||||
'',
|
'',
|
||||||
false,
|
false,
|
||||||
'width:100%'
|
'width:100%'
|
||||||
|
@ -380,7 +382,7 @@ html_print_div(
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
$infoHeadTitle = 'Sombra oscura';
|
$infoHeadTitle = '';
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<?php if (is_metaconsole() === false) { ?>
|
<?php if (is_metaconsole() === false) { ?>
|
||||||
|
|
Loading…
Reference in New Issue