Added new feature to remove past special days.

This commit is contained in:
Junichi Satoh 2016-10-08 16:12:53 +09:00
parent c4d2cc8ac4
commit 2cb08b06b6
3 changed files with 25 additions and 0 deletions

View File

@ -71,6 +71,9 @@ $table->data[8][1] = html_print_input_text ('days_delete_unknown', $config["days
$table->data[9][0] = __('Max. days before delete autodisabled agents');
$table->data[9][1] = html_print_input_text ('days_autodisable_deletion', $config["days_autodisable_deletion"], '', 5, 5, true);
$table->data[10][0] = __('Retention period of past special days') . ui_print_help_tip(__('This number is days to keep past special days. 0 means never remove.'), true);
$table->data[10][1] = html_print_input_text ('num_past_special_days', $config["num_past_special_days"], '', 5, 5, true);
$table_other = new stdClass();
$table_other->width = '100%';
$table_other->class = 'databox filters';

View File

@ -409,6 +409,8 @@ function config_update_config () {
$error_update[] = __('Big Operatiopn Step to purge old data');
if (!config_update_value ('small_operation_step_datos_purge', get_parameter ('small_operation_step_datos_purge')))
$error_update[] = __('Small Operation Step to purge old data');
if (!config_update_value ('num_past_special_days', get_parameter ('num_past_special_days')))
$error_update[] = __('Retention period of past special days');
/////////////
break;
@ -843,6 +845,10 @@ function config_process_config () {
config_update_value ('small_operation_step_datos_purge', 1000);
}
if (!isset ($config["num_past_special_days"])) {
config_update_value ('num_past_special_days', 0);
}
if (!isset ($config["event_purge"])) {
config_update_value ('event_purge', 15);
}

View File

@ -434,6 +434,20 @@ sub pandora_purgedb ($$) {
else {
log_message ('PURGE', 'log_max_lifetime is set to 0. Old log data will not be deleted.');
}
# Delete old special days
log_message ('PURGE', "Deleting old special days.");
if ($conf->{'_num_past_special_days'} > 0) {
log_message ('PURGE', 'Deleting special days older than ' . $conf->{'_num_past_special_days'} . ' days.');
if (${RDBMS} eq 'oracle') {
db_do ($dbh, "DELETE FROM talert_special_days
WHERE \"date\" < SYSDATE - $conf->{'_num_past_special_days'} AND \"date\" > '0001-01-01'");
}
elsif (${RDBMS} eq 'mysql') {
db_do ($dbh, "DELETE FROM talert_special_days
WHERE date < CURDATE() - $conf->{'_num_past_special_days'} AND date > '0001-01-01'");
}
}
}
########################################################################
@ -702,6 +716,8 @@ sub pandora_load_config ($) {
if ( $conf->{'_big_operation_step_datos_purge'} );
$SMALL_OPERATION_STEP = $conf->{'_small_operation_step_datos_purge'}
if ( $conf->{'_small_operation_step_datos_purge'} );
$conf->{'_num_past_special_days'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'num_past_special_days'");
db_disconnect ($dbh);