refactor events meta pandora_enterprise#9086
This commit is contained in:
parent
ca298422bd
commit
3e59093b0e
|
@ -592,33 +592,6 @@ function events_update_status($id_evento, $status, $filter=null)
|
|||
*
|
||||
* @param array $fields Fields to retrieve.
|
||||
* @param array $filter Filters to be applied.
|
||||
* Available filters:
|
||||
* [
|
||||
* 'date_from'
|
||||
* 'time_from'
|
||||
* 'date_to'
|
||||
* 'time_to'
|
||||
* 'event_view_hr'
|
||||
* 'id_agent'
|
||||
* 'event_type'
|
||||
* 'severity'
|
||||
* 'id_group_filter'
|
||||
* 'status'
|
||||
* 'agent_alias'
|
||||
* 'search'
|
||||
* 'id_extra'
|
||||
* 'id_source_event'
|
||||
* 'user_comment'
|
||||
* 'source'
|
||||
* 'id_user_ack'
|
||||
* 'tag_with'
|
||||
* 'tag_without'
|
||||
* 'filter_only_alert'
|
||||
* 'module_search'
|
||||
* 'group_rep'
|
||||
* 'server_id'
|
||||
* ].
|
||||
*
|
||||
* @param integer $offset Offset (pagination).
|
||||
* @param integer $limit Limit (pagination).
|
||||
* @param string $order Sort order.
|
||||
|
@ -631,6 +604,33 @@ function events_update_status($id_evento, $status, $filter=null)
|
|||
* will be search.
|
||||
* @param boolean $nodeConnected Already connected to node (uses tevento).
|
||||
*
|
||||
* Available filters:
|
||||
* [
|
||||
* 'date_from'
|
||||
* 'time_from'
|
||||
* 'date_to'
|
||||
* 'time_to'
|
||||
* 'event_view_hr'
|
||||
* 'id_agent'
|
||||
* 'event_type'
|
||||
* 'severity'
|
||||
* 'id_group_filter'
|
||||
* 'status'
|
||||
* 'agent_alias'
|
||||
* 'search'
|
||||
* 'id_extra'
|
||||
* 'id_source_event'
|
||||
* 'user_comment'
|
||||
* 'source'
|
||||
* 'id_user_ack'
|
||||
* 'tag_with'
|
||||
* 'tag_without'
|
||||
* 'filter_only_alert'
|
||||
* 'module_search'
|
||||
* 'group_rep'
|
||||
* 'server_id'
|
||||
* ].
|
||||
*
|
||||
* @return array Events.
|
||||
* @throws Exception On error.
|
||||
*/
|
||||
|
@ -845,7 +845,7 @@ function events_get_all(
|
|||
}
|
||||
}
|
||||
|
||||
$groups = isset($filter['id_group_filter']) === true ? $filter['id_group_filter'] : null;
|
||||
$groups = (isset($filter['id_group_filter']) === true) ? $filter['id_group_filter'] : null;
|
||||
if ((bool) $user_is_admin === false
|
||||
&& isset($groups) === false
|
||||
) {
|
||||
|
@ -1088,7 +1088,7 @@ function events_get_all(
|
|||
// Validated or in process by.
|
||||
if (empty($filter['id_user_ack']) === false) {
|
||||
$sql_filters[] = sprintf(
|
||||
' AND te.id_usuario like lower("%%%s%%") ',
|
||||
' AND te.owner_user like lower("%%%s%%") ',
|
||||
$filter['id_user_ack']
|
||||
);
|
||||
}
|
||||
|
@ -1333,7 +1333,11 @@ function events_get_all(
|
|||
|
||||
// Pagination.
|
||||
$pagination = '';
|
||||
if (is_metaconsole() === true && empty($id_server) === true) {
|
||||
if (is_metaconsole() === true
|
||||
&& empty($id_server) === true
|
||||
&& isset($filter['csv_all']) === false
|
||||
&& $filter['csv_all'] !== 1
|
||||
) {
|
||||
// TODO: XXX TIP. captura el error.
|
||||
$pagination = sprintf(
|
||||
' LIMIT %d',
|
||||
|
@ -1632,7 +1636,11 @@ function events_get_all(
|
|||
}
|
||||
);
|
||||
|
||||
if (isset($limit, $offset) === true && $limit > 0) {
|
||||
if (isset($limit, $offset) === true
|
||||
&& $limit !== 0
|
||||
&& isset($filter['csv_all']) === false
|
||||
&& $filter['csv_all'] !== 1
|
||||
) {
|
||||
$count = count($data);
|
||||
$end = ((int) $offset !== 0) ? ($offset + $limit) : $limit;
|
||||
$finally = array_slice($data, $offset, $end, true);
|
||||
|
|
|
@ -763,7 +763,13 @@ function delete_event(table, id_evento, event_rep, row, server_id) {
|
|||
});
|
||||
}
|
||||
|
||||
function execute_delete_event_reponse(table, id_evento, event_rep, row) {
|
||||
function execute_delete_event_reponse(
|
||||
table,
|
||||
id_evento,
|
||||
event_rep,
|
||||
row,
|
||||
server_id
|
||||
) {
|
||||
var button = document.getElementById("del-" + id_evento);
|
||||
if (!button) {
|
||||
// Button does not exist. Ignore.
|
||||
|
@ -772,7 +778,14 @@ function execute_delete_event_reponse(table, id_evento, event_rep, row) {
|
|||
}
|
||||
button.children[0];
|
||||
button.children[0].src = "images/spinner.gif";
|
||||
return update_event(table, id_evento, { delete_event: 1 }, event_rep, row);
|
||||
return update_event(
|
||||
table,
|
||||
id_evento,
|
||||
{ delete_event: 1 },
|
||||
event_rep,
|
||||
row,
|
||||
server_id
|
||||
);
|
||||
}
|
||||
|
||||
// Imported from old files.
|
||||
|
@ -855,6 +868,9 @@ function execute_event_response(event_list_btn) {
|
|||
});
|
||||
}
|
||||
} else {
|
||||
var event_id = $(this).val();
|
||||
var server_id = $("#hidden-server_id_" + event_id).val();
|
||||
|
||||
// It is not a custom response
|
||||
switch (response_id) {
|
||||
case "in_progress_selected":
|
||||
|
@ -864,7 +880,8 @@ function execute_event_response(event_list_btn) {
|
|||
dt_events,
|
||||
$(this).val(),
|
||||
$(this).attr("event_rep"),
|
||||
this.parentElement.parentElement
|
||||
this.parentElement.parentElement,
|
||||
server_id
|
||||
);
|
||||
});
|
||||
break;
|
||||
|
@ -872,9 +889,10 @@ function execute_event_response(event_list_btn) {
|
|||
$(".chk_val:checked").each(function() {
|
||||
validate_event(
|
||||
dt_events,
|
||||
$(this).val(),
|
||||
event_id,
|
||||
$(this).attr("event_rep"),
|
||||
this.parentElement.parentElement
|
||||
this.parentElement.parentElement,
|
||||
server_id
|
||||
);
|
||||
});
|
||||
break;
|
||||
|
@ -882,9 +900,10 @@ function execute_event_response(event_list_btn) {
|
|||
$(".chk_val:checked").each(function() {
|
||||
execute_delete_event_reponse(
|
||||
dt_events,
|
||||
$(this).val(),
|
||||
event_id,
|
||||
$(this).attr("event_rep"),
|
||||
this.parentElement.parentElement
|
||||
this.parentElement.parentElement,
|
||||
server_id
|
||||
);
|
||||
});
|
||||
break;
|
||||
|
|
|
@ -502,6 +502,7 @@ class EventsListWidget extends Widget
|
|||
|
||||
\ui_require_css_file('events', 'include/styles/', true);
|
||||
\ui_require_css_file('tables', 'include/styles/', true);
|
||||
\ui_require_javascript_file('pandora_events');
|
||||
\ui_require_javascript_file('pandora_events', 'include/javascript/', true);
|
||||
|
||||
$this->values['groupId'] = explode(',', $this->values['groupId'][0]);
|
||||
|
@ -643,9 +644,15 @@ class EventsListWidget extends Widget
|
|||
// Recursive Groups.
|
||||
(bool) $this->values['groupRecursion'],
|
||||
// Already connected.
|
||||
($this->nodeId > 0)
|
||||
// ($this->nodeId > 0)
|
||||
);
|
||||
|
||||
if (is_metaconsole() === true
|
||||
&& empty($filter['server_id']) !== false
|
||||
) {
|
||||
$events = $events['data'];
|
||||
}
|
||||
|
||||
if ($events === false) {
|
||||
$events = [];
|
||||
}
|
||||
|
@ -689,6 +696,8 @@ class EventsListWidget extends Widget
|
|||
metaconsole_connect(null, $this->nodeId);
|
||||
}
|
||||
|
||||
hd($events, true);
|
||||
|
||||
foreach ($events as $event) {
|
||||
$data = [];
|
||||
$event['evento'] = \io_safe_output($event['evento']);
|
||||
|
|
|
@ -351,7 +351,7 @@ div.multi-response-buttons {
|
|||
}
|
||||
|
||||
#events_buffers_display ul {
|
||||
min-width: 250px;
|
||||
min-width: 400px;
|
||||
}
|
||||
|
||||
#events_buffers_display li {
|
||||
|
|
|
@ -2021,8 +2021,7 @@ function process_datatables_callback(table, settings) {
|
|||
|
||||
function process_buffers(buffers) {
|
||||
$('#events_buffers_display').empty();
|
||||
console.log(buffers);
|
||||
if(buffers.settings != undefined && buffers.data.length > 0) {
|
||||
if(buffers != null && buffers.settings != undefined && buffers.data) {
|
||||
var html = '<h3>'+buffers.settings.translate.nev;
|
||||
html += ': ('+buffers.settings.total+')</h3>';
|
||||
html += '<ul>';
|
||||
|
@ -2040,7 +2039,7 @@ function process_buffers(buffers) {
|
|||
class_total += ' danger';
|
||||
str_total = buffers.settings.translate.tevn;
|
||||
}
|
||||
html += '<span class='+class_total+'>';
|
||||
html += '<span class="'+class_total+'">';
|
||||
html += element[1];
|
||||
if(str_total != '') {
|
||||
html += '<span class="text">';
|
||||
|
|
|
@ -159,6 +159,8 @@ try {
|
|||
throw new Exception('Invalid filter. ['.$plain_filter.']');
|
||||
}
|
||||
|
||||
$filter['csv_all'] = true;
|
||||
|
||||
$names = events_get_column_names($column_names);
|
||||
|
||||
// Dump headers.
|
||||
|
@ -166,6 +168,10 @@ try {
|
|||
echo io_safe_output($n).$config['csv_divider'];
|
||||
}
|
||||
|
||||
if (is_metaconsole() === true) {
|
||||
echo 'server_id'.$config['csv_divider'];
|
||||
}
|
||||
|
||||
echo chr(13);
|
||||
|
||||
// Dump events.
|
||||
|
@ -178,11 +184,10 @@ try {
|
|||
(($step++) * $events_per_step),
|
||||
$events_per_step,
|
||||
'desc',
|
||||
'timestamp',
|
||||
$filter['history']
|
||||
'timestamp'
|
||||
);
|
||||
|
||||
if ($events === false) {
|
||||
if ($events === false || empty($events) === true) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -249,6 +254,10 @@ try {
|
|||
echo $config['csv_divider'];
|
||||
}
|
||||
|
||||
if (is_metaconsole() === true) {
|
||||
echo $row['server_id'].$config['csv_divider'];
|
||||
}
|
||||
|
||||
echo chr(13);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3289,107 +3289,6 @@ CREATE TABLE IF NOT EXISTS `tgraph_source_template` (
|
|||
PRIMARY KEY(`id_gs_template`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Table `tmetaconsole_event`
|
||||
-- ---------------------------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `tmetaconsole_event` (
|
||||
`id_evento` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`id_source_event` BIGINT UNSIGNED NOT NULL,
|
||||
`id_agente` INT NOT NULL DEFAULT 0,
|
||||
`agent_name` VARCHAR(600) NOT NULL DEFAULT '',
|
||||
`id_usuario` VARCHAR(255) NOT NULL DEFAULT '0',
|
||||
`id_grupo` MEDIUMINT NOT NULL DEFAULT 0,
|
||||
`group_name` VARCHAR(100) NOT NULL DEFAULT '',
|
||||
`estado` TINYINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
`timestamp` DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00',
|
||||
`evento` TEXT,
|
||||
`utimestamp` BIGINT NOT NULL DEFAULT 0,
|
||||
`event_type` ENUM('going_unknown','unknown','alert_fired','alert_recovered','alert_ceased','alert_manual_validation','recon_host_detected','system','error','new_agent','going_up_warning','going_up_critical','going_down_warning','going_down_normal','going_down_critical','going_up_normal', 'configuration_change') DEFAULT 'unknown',
|
||||
`id_agentmodule` INT NOT NULL DEFAULT 0,
|
||||
`module_name` VARCHAR(600) NOT NULL,
|
||||
`id_alert_am` INT NOT NULL DEFAULT 0,
|
||||
`alert_template_name` TEXT,
|
||||
`criticity` INT UNSIGNED NOT NULL DEFAULT 0,
|
||||
`user_comment` TEXT,
|
||||
`tags` TEXT,
|
||||
`source` TINYTEXT,
|
||||
`id_extra` TINYTEXT,
|
||||
`critical_instructions` TEXT ,
|
||||
`warning_instructions` TEXT ,
|
||||
`unknown_instructions` TEXT ,
|
||||
`owner_user` VARCHAR(100) NOT NULL DEFAULT '',
|
||||
`ack_utimestamp` BIGINT NOT NULL DEFAULT 0,
|
||||
`server_id` INT NOT NULL,
|
||||
`custom_data` TEXT ,
|
||||
`data` TINYTEXT ,
|
||||
`module_status` INT NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`id_evento`),
|
||||
KEY `idx_agente` (`id_agente`),
|
||||
KEY `idx_agentmodule` (`id_agentmodule`),
|
||||
KEY `server_id` (`server_id`),
|
||||
KEY `idx_utimestamp` USING BTREE (`utimestamp`),
|
||||
KEY `tme_timestamp_idx` (`timestamp`),
|
||||
KEY `tme_module_status_idx` (`module_status`),
|
||||
KEY `tme_criticity_idx` (`criticity`),
|
||||
KEY `tme_agent_name_idx` (`agent_name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
|
||||
-- Criticity: 0 - Maintance (grey)
|
||||
-- Criticity: 1 - Informational (blue)
|
||||
-- Criticity: 2 - Normal (green) (status 0)
|
||||
-- Criticity: 3 - Warning (yellow) (status 2)
|
||||
-- Criticity: 4 - Critical (red) (status 1)
|
||||
-- Criticity: 5 - Minor
|
||||
-- Criticity: 6 - Major
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Table `tmetaconsole_event_history`
|
||||
-- ---------------------------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `tmetaconsole_event_history` (
|
||||
`id_evento` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`id_source_event` BIGINT UNSIGNED NOT NULL,
|
||||
`id_agente` INT NOT NULL DEFAULT 0,
|
||||
`agent_name` VARCHAR(600) NOT NULL DEFAULT '',
|
||||
`id_usuario` VARCHAR(255) NOT NULL DEFAULT '0',
|
||||
`id_grupo` MEDIUMINT NOT NULL DEFAULT 0,
|
||||
`group_name` VARCHAR(100) NOT NULL DEFAULT '',
|
||||
`estado` TINYINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
`timestamp` DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00',
|
||||
`evento` TEXT,
|
||||
`utimestamp` BIGINT NOT NULL DEFAULT 0,
|
||||
`event_type` ENUM('going_unknown','unknown','alert_fired','alert_recovered','alert_ceased','alert_manual_validation','recon_host_detected','system','error','new_agent','going_up_warning','going_up_critical','going_down_warning','going_down_normal','going_down_critical','going_up_normal', 'configuration_change') DEFAULT 'unknown',
|
||||
`id_agentmodule` INT NOT NULL DEFAULT 0,
|
||||
`module_name` VARCHAR(600) NOT NULL,
|
||||
`id_alert_am` INT NOT NULL DEFAULT 0,
|
||||
`alert_template_name` TEXT,
|
||||
`criticity` INT UNSIGNED NOT NULL DEFAULT 0,
|
||||
`user_comment` TEXT,
|
||||
`tags` TEXT,
|
||||
`source` TINYTEXT,
|
||||
`id_extra` TINYTEXT,
|
||||
`critical_instructions` TEXT ,
|
||||
`warning_instructions` TEXT ,
|
||||
`unknown_instructions` TEXT ,
|
||||
`owner_user` VARCHAR(100) NOT NULL DEFAULT '',
|
||||
`ack_utimestamp` BIGINT NOT NULL DEFAULT 0,
|
||||
`server_id` INT NOT NULL,
|
||||
`custom_data` TEXT ,
|
||||
`data` DOUBLE DEFAULT NULL,
|
||||
`module_status` INT NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`id_evento`),
|
||||
KEY `idx_agente` (`id_agente`),
|
||||
KEY `idx_agentmodule` (`id_agentmodule`),
|
||||
KEY `idx_utimestamp` USING BTREE (`utimestamp`),
|
||||
KEY `tmeh_estado_idx` (`estado`),
|
||||
KEY `tmeh_timestamp_idx` (`timestamp`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
|
||||
-- Criticity: 0 - Maintance (grey)
|
||||
-- Criticity: 1 - Informational (blue)
|
||||
-- Criticity: 2 - Normal (green) (status 0)
|
||||
-- Criticity: 3 - Warning (yellow) (status 2)
|
||||
-- Criticity: 4 - Critical (red) (status 1)
|
||||
-- Criticity: 5 - Minor
|
||||
-- Criticity: 6 - Major
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Table `textension_translate_string`
|
||||
-- ---------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue