refactor events meta pandora_enterprise#9086

This commit is contained in:
Daniel Barbero Martin 2022-06-13 17:06:09 +02:00
parent 5680b82563
commit 90013603a7
3 changed files with 78 additions and 56 deletions

View File

@ -2054,6 +2054,10 @@ function config_process_config()
config_update_value('max_execution_event_response', 10);
}
if (!isset($config['max_number_of_events_per_node'])) {
config_update_value('max_number_of_events_per_node', 100000);
}
if (!isset($config['max_macro_fields'])) {
config_update_value('max_macro_fields', 10);
}

View File

@ -1338,13 +1338,18 @@ function events_get_all(
$id_server = 0;
if (empty($filter['id_server']) === false) {
$id_server = $filter['id_server'];
} else if (empty($filter['server_id']) === false) {
$id_server = $filter['server_id'];
}
// Pagination.
$pagination = '';
if (is_metaconsole() === true) {
// TODO: XXX TOTAL 10000 - 10000000. settins meta 300000; TIP. capturra el error.
$pagination = ' LIMIT 100000 ';
if (is_metaconsole() === true && empty($id_server) === true) {
// TODO: XXX TIP. capturra el error.
$pagination = sprintf(
' LIMIT %d',
$config['max_number_of_events_per_node']
);
} else if (isset($limit, $offset) === true && $limit > 0) {
$pagination = sprintf(' LIMIT %d OFFSET %d', $limit, $offset);
}
@ -1512,7 +1517,13 @@ function events_get_all(
('.$sql.') tbase';
}
if ($count !== true) {
if ($count === true
&& (is_metaconsole() !== false
|| (is_metaconsole() === true && empty($filter['server_id']) === false))
) {
$sql = 'SELECT count(*) as nitems FROM ('.$sql.') tt';
}
if (is_metaconsole() === true) {
$result_meta = [];
$metaconsole_connections = metaconsole_get_names();
@ -1569,6 +1580,7 @@ function events_get_all(
}
}
if (empty($filter['server_id']) === true) {
// TODO: XXX;
hd($sort_field, true);
hd($order, true);
@ -1620,20 +1632,23 @@ function events_get_all(
$count = count($data);
$end = ((int) $offset !== 0) ? ($offset + $limit) : $limit;
$finally = array_slice($data, $offset, $end, true);
$return = [
'data' => $finally,
'total' => $count,
];
} else {
// TODO: XXX limit * nodes.
$return = array_slice($data, 0, 1000000, true);
$return = array_slice(
$data,
0,
($config['max_number_of_events_per_node'] * count($metaconsole_connections)),
true
);
}
return $return;
}
} else {
$sql = 'SELECT count(*) as nitems FROM ('.$sql.') tt';
return $data;
}
}
if ($return_sql) {

View File

@ -352,7 +352,10 @@ if (is_ajax() === true) {
$history
);
if (is_metaconsole() === false) {
if (is_metaconsole() === false
|| (is_metaconsole() === true
&& empty($filter['server_id']) === false)
) {
$count = events_get_all(
'count',
$filter,