From 5927687ad306e730d6ad9b4023d6751c5b401d79 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Tue, 7 Feb 2023 09:49:46 +0100 Subject: [PATCH] #10321 create token events_per_query for limit consult sql --- pandora_console/godmode/setup/performance.php | 13 +++++++++++++ pandora_console/include/functions_config.php | 8 ++++++++ pandora_console/operation/events/events.php | 4 +++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/pandora_console/godmode/setup/performance.php b/pandora_console/godmode/setup/performance.php index 969ff868c1..03a3c15f99 100644 --- a/pandora_console/godmode/setup/performance.php +++ b/pandora_console/godmode/setup/performance.php @@ -528,6 +528,19 @@ $table_other->data[$i++][1] = html_print_input_text( true ); +$table_other->data[$i][0] = __('Limit of events per query'); +$table_other->data[$i++][1] = html_print_input( + [ + 'type' => 'number', + 'size' => 5, + 'max' => 10000, + 'name' => 'events_per_query', + 'value' => $config['events_per_query'], + 'return' => true, + 'style' => 'width:50px', + ] +); + $table_other->data[$i][0] = __('Compact interpolation in hours (1 Fine-20 bad)'); $table_other->data[$i++][1] = html_print_input_text( 'step_compact', diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index b0d15d5cef..09f0494018 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -848,6 +848,10 @@ function config_update_config() $error_update[] = __('Item limit for realtime reports)'); } + if (config_update_value('events_per_query', (int) get_parameter('events_per_query'), true) === false) { + $error_update[] = __('Limit of events per query'); + } + if (config_update_value('step_compact', (int) get_parameter('step_compact'), true) === false) { $error_update[] = __('Compact interpolation in hours (1 Fine-20 bad)'); } @@ -1986,6 +1990,10 @@ function config_process_config() config_update_value('report_limit', 100); } + if (!isset($config['events_per_query'])) { + config_update_value('events_per_query', 5000); + } + if (!isset($config['loginhash_pwd'])) { config_update_value('loginhash_pwd', io_input_password((rand(0, 1000) * rand(0, 1000)).'pandorahash')); } diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 6777ced4c3..bf0655b5a3 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -324,9 +324,11 @@ if (is_ajax() === true) { $start = get_parameter('start', 0); $length = get_parameter( 'length', - $config['block_size'] + $config['events_per_query'] ); + $length = ($length === '-1') ? $config['events_per_query'] : $length; + if ($get_events !== 0) { try { ob_start();