Ent 4862 mas opciones en los filtros de severidad
This commit is contained in:
parent
df721fc550
commit
7204e7c0f2
|
@ -0,0 +1,5 @@
|
|||
START TRANSACTION;
|
||||
|
||||
ALTER TABLE `tevent_filter` MODIFY `severity` TEXT NOT NULL;
|
||||
|
||||
COMMIT;
|
|
@ -1401,6 +1401,7 @@ ALTER TABLE tevent_filter ADD COLUMN `source` tinytext NOT NULL;
|
|||
ALTER TABLE tevent_filter ADD COLUMN `id_extra` tinytext NOT NULL;
|
||||
ALTER TABLE tevent_filter ADD COLUMN `id_source_event` int(10);
|
||||
ALTER TABLE `tevent_filter` MODIFY COLUMN `user_comment` text NOT NULL;
|
||||
ALTER TABLE `tevent_filter` MODIFY COLUMN `severity` text NOT NULL;
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Table `tusuario`
|
||||
|
|
|
@ -55,7 +55,7 @@ if ($id) {
|
|||
$id_group = $filter['id_group'];
|
||||
$id_name = $filter['id_name'];
|
||||
$event_type = $filter['event_type'];
|
||||
$severity = $filter['severity'];
|
||||
$severity = explode(',', $filter['severity']);
|
||||
$status = $filter['status'];
|
||||
$search = $filter['search'];
|
||||
$text_agent = $filter['text_agent'];
|
||||
|
@ -123,7 +123,7 @@ if ($update || $create) {
|
|||
$id_group_filter = get_parameter('id_group_filter');
|
||||
$id_name = (string) get_parameter('id_name');
|
||||
$event_type = get_parameter('event_type', '');
|
||||
$severity = get_parameter('severity', '');
|
||||
$severity = implode(',', get_parameter('severity', -1));
|
||||
$status = get_parameter('status', '');
|
||||
$search = get_parameter('search', '');
|
||||
$text_agent = get_parameter('text_agent', '');
|
||||
|
@ -172,6 +172,8 @@ if ($update || $create) {
|
|||
'user_comment' => $user_comment,
|
||||
'filter_only_alert' => $filter_only_alert,
|
||||
];
|
||||
|
||||
$severity = explode(',', $severity);
|
||||
}
|
||||
|
||||
if ($update) {
|
||||
|
@ -289,15 +291,24 @@ $table->data[3][1] = html_print_select(
|
|||
true
|
||||
);
|
||||
|
||||
if (empty($severity) && $severity !== '0') {
|
||||
$severity = -1;
|
||||
}
|
||||
|
||||
$table->data[4][0] = '<b>'.__('Severity').'</b>';
|
||||
$table->data[4][1] = html_print_select(
|
||||
get_priorities(),
|
||||
'severity',
|
||||
'severity[]',
|
||||
$severity,
|
||||
'',
|
||||
__('All'),
|
||||
'-1',
|
||||
true
|
||||
-1,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
'',
|
||||
false,
|
||||
'width: 175px'
|
||||
);
|
||||
|
||||
$fields = events_get_all_status();
|
||||
|
|
|
@ -231,7 +231,7 @@ if ($save_event_filter) {
|
|||
$values['id_name'] = get_parameter('id_name');
|
||||
$values['id_group'] = get_parameter('id_group');
|
||||
$values['event_type'] = get_parameter('event_type');
|
||||
$values['severity'] = get_parameter('severity');
|
||||
$values['severity'] = implode(',', get_parameter('severity', -1));
|
||||
$values['status'] = get_parameter('status');
|
||||
$values['search'] = get_parameter('search');
|
||||
$values['text_agent'] = get_parameter('text_agent');
|
||||
|
@ -278,7 +278,7 @@ if ($update_event_filter) {
|
|||
$id = get_parameter('id');
|
||||
$values['id_group'] = get_parameter('id_group');
|
||||
$values['event_type'] = get_parameter('event_type');
|
||||
$values['severity'] = get_parameter('severity');
|
||||
$values['severity'] = implode(',', get_parameter('severity', -1));
|
||||
$values['status'] = get_parameter('status');
|
||||
$values['search'] = get_parameter('search');
|
||||
$values['text_agent'] = get_parameter('text_agent');
|
||||
|
@ -439,8 +439,10 @@ function load_form_filter() {
|
|||
$("#id_group").val(val);
|
||||
if (i == 'event_type')
|
||||
$("#event_type").val(val);
|
||||
if (i == 'severity')
|
||||
$("#severity").val(val);
|
||||
if (i == 'severity') {
|
||||
const multiple = val.split(",");
|
||||
$("#severity").val(multiple);
|
||||
}
|
||||
if (i == 'status')
|
||||
$("#status").val(val);
|
||||
if (i == 'search')
|
||||
|
@ -1579,7 +1581,7 @@ if ($get_list_events_agents) {
|
|||
$id_agent = get_parameter('id_agent');
|
||||
$server_id = get_parameter('server_id');
|
||||
$event_type = get_parameter('event_type');
|
||||
$severity = get_parameter('severity');
|
||||
$severity = implode(',', get_parameter('severity', -1));
|
||||
$status = get_parameter('status');
|
||||
$search = get_parameter('search');
|
||||
$id_agent_module = get_parameter('id_agent_module');
|
||||
|
|
|
@ -751,43 +751,78 @@ function events_get_all(
|
|||
}
|
||||
|
||||
if (isset($filter['severity']) && $filter['severity'] > 0) {
|
||||
switch ($filter['severity']) {
|
||||
case EVENT_CRIT_MAINTENANCE:
|
||||
case EVENT_CRIT_INFORMATIONAL:
|
||||
case EVENT_CRIT_NORMAL:
|
||||
case EVENT_CRIT_MINOR:
|
||||
case EVENT_CRIT_WARNING:
|
||||
case EVENT_CRIT_MAJOR:
|
||||
case EVENT_CRIT_CRITICAL:
|
||||
default:
|
||||
$sql_filters[] = sprintf(
|
||||
' AND criticity = %d ',
|
||||
$filter['severity']
|
||||
);
|
||||
break;
|
||||
if (is_array($filter['severity'])) {
|
||||
if (!in_array(-1, $filter['severity'])) {
|
||||
$not_normal = array_search(EVENT_CRIT_NOT_NORMAL, $filter['severity']);
|
||||
if ($not_normal !== false) {
|
||||
unset($filter['severity'][$not_normal]);
|
||||
$sql_filters[] = sprintf(
|
||||
' AND criticity != %d',
|
||||
EVENT_CRIT_NORMAL
|
||||
);
|
||||
} else {
|
||||
$critical_warning = array_search(EVENT_CRIT_WARNING_OR_CRITICAL, $filter['severity']);
|
||||
if ($critical_warning !== false) {
|
||||
unset($filter['severity'][$critical_warning]);
|
||||
$filter['severity'][] = EVENT_CRIT_WARNING;
|
||||
$filter['severity'][] = EVENT_CRIT_CRITICAL;
|
||||
}
|
||||
|
||||
case EVENT_CRIT_WARNING_OR_CRITICAL:
|
||||
$sql_filters[] = sprintf(
|
||||
' AND (criticity = %d OR criticity = %d)',
|
||||
EVENT_CRIT_WARNING,
|
||||
EVENT_CRIT_CRITICAL
|
||||
);
|
||||
break;
|
||||
$critical_normal = array_search(EVENT_CRIT_OR_NORMAL, $filter['severity']);
|
||||
if ($critical_normal !== false) {
|
||||
unset($filter['severity'][$critical_normal]);
|
||||
$filter['severity'][] = EVENT_CRIT_NORMAL;
|
||||
$filter['severity'][] = EVENT_CRIT_CRITICAL;
|
||||
}
|
||||
|
||||
case EVENT_CRIT_NOT_NORMAL:
|
||||
$sql_filters[] = sprintf(
|
||||
' AND criticity != %d',
|
||||
EVENT_CRIT_NORMAL
|
||||
);
|
||||
break;
|
||||
if (!empty($filter['severity'])) {
|
||||
$filter['severity'] = implode(',', $filter['severity']);
|
||||
$sql_filters[] = sprintf(
|
||||
' AND criticity IN (%s)',
|
||||
$filter['severity']
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
switch ($filter['severity']) {
|
||||
case EVENT_CRIT_MAINTENANCE:
|
||||
case EVENT_CRIT_INFORMATIONAL:
|
||||
case EVENT_CRIT_NORMAL:
|
||||
case EVENT_CRIT_MINOR:
|
||||
case EVENT_CRIT_WARNING:
|
||||
case EVENT_CRIT_MAJOR:
|
||||
case EVENT_CRIT_CRITICAL:
|
||||
default:
|
||||
$sql_filters[] = sprintf(
|
||||
' AND criticity = %d ',
|
||||
$filter['severity']
|
||||
);
|
||||
break;
|
||||
|
||||
case EVENT_CRIT_OR_NORMAL:
|
||||
$sql_filters[] = sprintf(
|
||||
' AND (criticity = %d OR criticity = %d)',
|
||||
EVENT_CRIT_NORMAL,
|
||||
EVENT_CRIT_CRITICAL
|
||||
);
|
||||
break;
|
||||
case EVENT_CRIT_WARNING_OR_CRITICAL:
|
||||
$sql_filters[] = sprintf(
|
||||
' AND (criticity = %d OR criticity = %d)',
|
||||
EVENT_CRIT_WARNING,
|
||||
EVENT_CRIT_CRITICAL
|
||||
);
|
||||
break;
|
||||
|
||||
case EVENT_CRIT_NOT_NORMAL:
|
||||
$sql_filters[] = sprintf(
|
||||
' AND criticity != %d',
|
||||
EVENT_CRIT_NORMAL
|
||||
);
|
||||
break;
|
||||
|
||||
case EVENT_CRIT_OR_NORMAL:
|
||||
$sql_filters[] = sprintf(
|
||||
' AND (criticity = %d OR criticity = %d)',
|
||||
EVENT_CRIT_NORMAL,
|
||||
EVENT_CRIT_CRITICAL
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@ div.mini-criticity.h100p {
|
|||
form.flex-row div.filter_input,
|
||||
form.flex-row ul {
|
||||
width: 30%;
|
||||
min-width: 300px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: baseline;
|
||||
|
@ -47,12 +46,13 @@ div.filter_input_little {
|
|||
flex-direction: row;
|
||||
align-items: baseline;
|
||||
flex-wrap: nowrap;
|
||||
margin: 0.5em 0 0.5em 1em;
|
||||
margin: 0.5em 0 0.5em 0em;
|
||||
}
|
||||
|
||||
form.flex-row div.filter_input.large {
|
||||
flex: 1;
|
||||
min-width: 470px;
|
||||
min-width: 700px;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
div.filter_input > label,
|
||||
|
@ -120,6 +120,8 @@ table.dataTable tbody td {
|
|||
|
||||
.filter_input {
|
||||
align-items: center;
|
||||
min-width: 400px;
|
||||
max-width: 450px;
|
||||
}
|
||||
|
||||
.filter_input_little > select,
|
||||
|
|
|
@ -894,22 +894,6 @@ $in = '<div class="filter_input"><label>'.__('Event type').'</label>';
|
|||
$in .= $data.'</div>';
|
||||
$inputs[] = $in;
|
||||
|
||||
// Criticity - severity.
|
||||
$severity_select .= html_print_select(
|
||||
get_priorities(),
|
||||
'severity',
|
||||
$severity,
|
||||
'',
|
||||
__('All'),
|
||||
'-1',
|
||||
true,
|
||||
false,
|
||||
false
|
||||
);
|
||||
$in = '<div class="filter_input"><label>'.__('Severity').'</label>';
|
||||
$in .= $severity_select.'</div>';
|
||||
$inputs[] = $in;
|
||||
|
||||
// Event status.
|
||||
$data = html_print_select(
|
||||
events_get_all_status(),
|
||||
|
@ -961,6 +945,28 @@ $in = '<div class="filter_input"><label>'.__('Free search').'</label>';
|
|||
$in .= $data.'</div>';
|
||||
$inputs[] = $in;
|
||||
|
||||
if (empty($severity) && $severity !== '0') {
|
||||
$severity = -1;
|
||||
}
|
||||
|
||||
// Criticity - severity.
|
||||
$data = html_print_select(
|
||||
get_priorities(),
|
||||
'severity',
|
||||
$severity,
|
||||
'',
|
||||
__('All'),
|
||||
-1,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
'',
|
||||
false
|
||||
);
|
||||
$in = '<div class="filter_input"><label>'.__('Severity').'</label>';
|
||||
$in .= $data.'</div>';
|
||||
$inputs[] = $in;
|
||||
|
||||
$buttons = [];
|
||||
|
||||
$buttons[] = [
|
||||
|
@ -1115,8 +1121,6 @@ if (is_metaconsole()) {
|
|||
$adv_inputs[] = $in;
|
||||
}
|
||||
|
||||
// Gap.
|
||||
$adv_inputs[] = '<div class="filter_input"></div>';
|
||||
|
||||
// Date from.
|
||||
$data = html_print_input_text(
|
||||
|
|
|
@ -1098,7 +1098,7 @@ CREATE TABLE IF NOT EXISTS `tevent_filter` (
|
|||
`id_name` varchar(600) NOT NULL,
|
||||
`id_group` int(10) NOT NULL default 0,
|
||||
`event_type` text NOT NULL,
|
||||
`severity` int(10) NOT NULL default -1,
|
||||
`severity` text NOT NULL,
|
||||
`status` int(10) NOT NULL default -1,
|
||||
`search` TEXT,
|
||||
`text_agent` TEXT,
|
||||
|
|
Loading…
Reference in New Issue