Feature: add warnings when history days is more less than purge days

This commit is contained in:
m-lopez-f 2016-11-11 10:29:47 +01:00
parent 94b22eb69b
commit cc10f01c10
3 changed files with 21 additions and 1 deletions

View File

@ -24,7 +24,7 @@ if (! check_acl ($config['id_user'], 0, "PM") && ! is_user_admin ($config['id_us
return; return;
} }
// Load enterprise extensions // Load enterprise extensions
enterprise_include_once ('godmode/setup/setup.php'); //~ enterprise_include_once ('godmode/setup/setup.php');
/* /*
NOTICE FOR DEVELOPERS: NOTICE FOR DEVELOPERS:
@ -44,6 +44,8 @@ $table->style[0] = "font-weight: bold";
$table->size[0] = '70%'; $table->size[0] = '70%';
$table->size[1] = '30%'; $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][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); $table->data[1][1] = html_print_input_text ('event_purge', $config["event_purge"], '', 5, 5, true);

View File

@ -648,6 +648,8 @@ function config_update_config () {
case 'hist_db': case 'hist_db':
if (!config_update_value ('history_db_enabled', get_parameter ('history_db_enabled'))) if (!config_update_value ('history_db_enabled', get_parameter ('history_db_enabled')))
$error_update[] = __('Enable history database'); $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'))) if (!config_update_value ('history_db_host', get_parameter ('history_db_host')))
$error_update[] = __('Host'); $error_update[] = __('Host');
if (!config_update_value ('history_db_port', get_parameter ('history_db_port'))) if (!config_update_value ('history_db_port', get_parameter ('history_db_port')))
@ -660,6 +662,8 @@ function config_update_config () {
$error_update[] = __('Database password'); $error_update[] = __('Database password');
if (!config_update_value ('history_db_days', get_parameter ('history_db_days'))) if (!config_update_value ('history_db_days', get_parameter ('history_db_days')))
$error_update[] = __('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'))) if (!config_update_value ('history_db_step', get_parameter ('history_db_step')))
$error_update[] = __('Step'); $error_update[] = __('Step');
if (!config_update_value ('history_db_delay', get_parameter ('history_db_delay'))) if (!config_update_value ('history_db_delay', get_parameter ('history_db_delay')))
@ -1062,6 +1066,10 @@ function config_process_config () {
config_update_value ( 'history_db_enabled', false); 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'])) { if (!isset ($config['history_db_host'])) {
config_update_value ( 'history_db_host', ''); config_update_value ( 'history_db_host', '');
} }
@ -1086,6 +1094,10 @@ function config_process_config () {
config_update_value ( 'history_db_days', 0); 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'])) { if (!isset ($config['history_db_step'])) {
config_update_value ( 'history_db_step', 0); config_update_value ( 'history_db_step', 0);
} }

View File

@ -689,12 +689,14 @@ sub pandora_load_config ($) {
$conf->{'_last_compact'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'last_compact'"); $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->{'_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_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_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_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_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_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_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_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_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->{'_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'"); $conf->{'_days_delete_unknown'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'days_delete_unknown'");
@ -1038,6 +1040,10 @@ sub pandoradb_main ($$$) {
# Move old data to the history DB # Move old data to the history DB
if (defined ($history_dbh)) { 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'}])); 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 # Compact on if enable and DaysCompact are below DaysPurge