Added separated field to purge inventory data. Ticket #128 GitLab

This commit is contained in:
Arturo Gonzalez 2016-12-14 13:02:10 +01:00
parent 01217fe3b2
commit e1b3f115e0
4 changed files with 35 additions and 15 deletions

View File

@ -76,6 +76,11 @@ $table->data[9][1] = html_print_input_text ('days_autodisable_deletion', $config
$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);
if (enterprise_installed ()) {
$table->data[11][0] = __('Max. days before delete inventory data');
$table->data[11][1] = html_print_input_text ('inventory_purge', $config["inventory_purge"], '', 5, 5, true);
}
$table_other = new stdClass();
$table_other->width = '100%';
$table_other->class = 'databox filters';

View File

@ -407,6 +407,10 @@ function config_update_config () {
$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');
if (isset($config['enterprise_installed']) && $config['enterprise_installed'] == 1) {
if (!config_update_value ('inventory_purge', get_parameter ('inventory_purge')))
$error_update[] = __('Max. days before delete inventory data');
}
/////////////
break;
@ -855,6 +859,12 @@ function config_process_config () {
config_update_value ('num_past_special_days', 0);
}
if (isset($config['enterprise_installed'])) {
if (!isset($config['inventory_purge'])) {
config_update_value ('inventory_purge', 21);
}
}
if (!isset ($config["event_purge"])) {
config_update_value ('event_purge', 15);
}

View File

@ -406,7 +406,7 @@ function treeview_printAlertsTable($id_module, $server_data = array(), $no_head
$row['times_fired'] = __('Times fired');
$row['last_fired'] = __('Last fired');
$table2->data['titles'] = $row;
html_debug($module_alerts, true);
foreach ($module_alerts as $module_alert) {
$template_name = db_get_value('name','talert_templates','id',$module_alert['id_alert_template']);

View File

@ -91,21 +91,11 @@ sub pandora_purgedb ($$) {
WHERE id_sesion NOT IN ( SELECT id_sesion FROM tsesion )");
log_message ('PURGE', 'Deleting old extended session data.');
}
# Delete old data
if ($conf->{'_days_purge'} > 0) {
# Delete old numeric data
pandora_delete_old_module_data ($dbh, 'tagente_datos', $ulimit_access_timestamp, $ulimit_timestamp);
# Delete old export data
pandora_delete_old_export_data ($dbh, $ulimit_timestamp);
# Delete sessions data
pandora_delete_old_session_data ($dbh, $ulimit_timestamp);
# Delete old inventory data
# Delete old inventory data
if ($conf->{'_inventory_purge'} > 0) {
if (enterprise_load (\%conf) != 0) {
my $ulimit_timestamp_inventory = time() - (86400 * $conf->{'_inventory_purge'});
log_message ('PURGE', 'Deleting old inventory data.');
@ -116,7 +106,7 @@ sub pandora_purgedb ($$) {
$first_mark = get_db_value_limit ($dbh, 'SELECT utimestamp FROM tagente_datos_inventory ORDER BY utimestamp ASC', 1);
if (defined ($first_mark)) {
$total_time = $ulimit_timestamp - $first_mark;
$total_time = $ulimit_timestamp_inventory - $first_mark;
$purge_steps = int($total_time / $BIG_OPERATION_STEP);
if ($purge_steps > 0) {
for (my $ax = 1; $ax <= $BIG_OPERATION_STEP; $ax++) {
@ -133,8 +123,22 @@ sub pandora_purgedb ($$) {
log_message ('PURGE', 'No data in tagente_datos_inventory.');
}
}
}
# Delete old data
if ($conf->{'_days_purge'} > 0) {
# Delete old numeric data
pandora_delete_old_module_data ($dbh, 'tagente_datos', $ulimit_access_timestamp, $ulimit_timestamp);
# Delete old export data
pandora_delete_old_export_data ($dbh, $ulimit_timestamp);
# Delete sessions data
pandora_delete_old_session_data ($dbh, $ulimit_timestamp);
# Delete old inventory data
#
# Now the log4x data
#
@ -700,6 +704,7 @@ sub pandora_load_config ($) {
$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'");
$conf->{'_inventory_purge'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'inventory_purge'");
$conf->{'_enterprise_installed'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'enterprise_installed'");
$conf->{'_metaconsole'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'metaconsole'");
$conf->{'_metaconsole_events_history'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'metaconsole_events_history'");