From 6fc0ff8a722aa6294557cff9706f70dc6d485c2c Mon Sep 17 00:00:00 2001 From: m-lopez-f Date: Fri, 11 Nov 2016 10:29:47 +0100 Subject: [PATCH] Feature: add warnings when history days is more less than purge days (cherry picked from commit cc10f01c10a91cd10d9b8934f69a91bca841913c) --- pandora_console/godmode/setup/performance.php | 4 +++- pandora_console/include/functions_config.php | 12 ++++++++++++ pandora_server/util/pandora_db.pl | 6 ++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/pandora_console/godmode/setup/performance.php b/pandora_console/godmode/setup/performance.php index 2158bcddeb..94d661a7cb 100644 --- a/pandora_console/godmode/setup/performance.php +++ b/pandora_console/godmode/setup/performance.php @@ -24,7 +24,7 @@ if (! check_acl ($config['id_user'], 0, "PM") && ! is_user_admin ($config['id_us return; } // Load enterprise extensions -enterprise_include_once ('godmode/setup/setup.php'); +//~ enterprise_include_once ('godmode/setup/setup.php'); /* NOTICE FOR DEVELOPERS: @@ -44,6 +44,8 @@ $table->style[0] = "font-weight: bold"; $table->size[0] = '70%'; $table->size[1] = '30%'; +enterprise_hook('enterprise_warnings_history_days'); + $table->data[1][0] = __('Max. days before delete events') . ui_print_help_tip(__('If the compaction or purge of the data is more frequent than the events deletion, anomalies in module graphs could appear'), true); $table->data[1][1] = html_print_input_text ('event_purge', $config["event_purge"], '', 5, 5, true); diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 176f411ed5..3b2c62026f 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -640,6 +640,8 @@ function config_update_config () { case 'hist_db': if (!config_update_value ('history_db_enabled', get_parameter ('history_db_enabled'))) $error_update[] = __('Enable history database'); + if (!config_update_value ('history_event_enabled', get_parameter ('history_event_enabled'))) + $error_update[] = __('Enable history event'); if (!config_update_value ('history_db_host', get_parameter ('history_db_host'))) $error_update[] = __('Host'); if (!config_update_value ('history_db_port', get_parameter ('history_db_port'))) @@ -652,6 +654,8 @@ function config_update_config () { $error_update[] = __('Database password'); if (!config_update_value ('history_db_days', get_parameter ('history_db_days'))) $error_update[] = __('Days'); + if (!config_update_value ('history_event_days', get_parameter ('history_event_days'))) + $error_update[] = __('Event Days'); if (!config_update_value ('history_db_step', get_parameter ('history_db_step'))) $error_update[] = __('Step'); if (!config_update_value ('history_db_delay', get_parameter ('history_db_delay'))) @@ -1037,6 +1041,10 @@ function config_process_config () { config_update_value ( 'history_db_enabled', false); } + if (!isset ($config['history_event_enabled'])) { + config_update_value ( 'history_event_enabled', false); + } + if (!isset ($config['history_db_host'])) { config_update_value ( 'history_db_host', ''); } @@ -1061,6 +1069,10 @@ function config_process_config () { config_update_value ( 'history_db_days', 0); } + if (!isset ($config['history_event_days'])) { + config_update_value ('history_event_days', 90); + } + if (!isset ($config['history_db_step'])) { config_update_value ( 'history_db_step', 0); } diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 3bce3cc1e5..cefc4ba2ed 100644 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -662,12 +662,14 @@ sub pandora_load_config ($) { $conf->{'_last_compact'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'last_compact'"); $conf->{'_step_compact'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'step_compact'"); $conf->{'_history_db_enabled'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_enabled'"); + $conf->{'_history_event_enabled'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_event_enabled'"); $conf->{'_history_db_host'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_host'"); $conf->{'_history_db_port'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_port'"); $conf->{'_history_db_name'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_name'"); $conf->{'_history_db_user'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_user'"); $conf->{'_history_db_pass'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_pass'"); $conf->{'_history_db_days'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_days'"); + $conf->{'_history_event_days'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_event_days'"); $conf->{'_history_db_step'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_step'"); $conf->{'_history_db_delay'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_delay'"); $conf->{'_days_delete_unknown'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'days_delete_unknown'"); @@ -1000,6 +1002,10 @@ sub pandoradb_main ($$$) { # Move old data to the history DB if (defined ($history_dbh)) { undef ($history_dbh) unless defined (enterprise_hook ('pandora_historydb', [$dbh, $history_dbh, $conf->{'_history_db_days'}, $conf->{'_history_db_step'}, $conf->{'_history_db_delay'}])); + if (defined($conf{'_history_event_enabled'})) { + log_message ('', "Entrando a los eventoss :::: " . $conf->{'_history_event_days'} . "\n"); + undef ($history_dbh) unless defined (enterprise_hook ('pandora_history_event', [$dbh, $history_dbh, $conf->{'_history_event_days'}, $conf->{'_history_db_step'}, $conf->{'_history_db_delay'}])); + } } # Compact on if enable and DaysCompact are below DaysPurge