Merge branch 'ent-9301-anadir-token-de-mantenimiento-para-que-el-pandora_db-elimine-agentes-deshabilitados-manualmente' into 'develop'

Ent-9301-anadir-token-de-mantenimiento-para-que-el-pandora_db-elimine-agentes-deshabilitados

See merge request artica/pandorafms!6051
This commit is contained in:
Daniel Rodriguez 2023-07-27 13:08:05 +00:00
commit 42a5fc0716
3 changed files with 31 additions and 1 deletions

View File

@ -559,6 +559,18 @@ if (enterprise_installed()) {
);
}
$table->data[7][1] = html_print_label_input_block(
__('Max. days before disabled agents are deleted'),
html_print_input_text(
'delete_disabled_agents',
$config['delete_disabled_agents'],
'',
false,
0,
true
)
);
$table_other = new stdClass();
$table_other->width = '100%';
$table_other->class = 'filter-table-adv';

View File

@ -974,6 +974,10 @@ function config_update_config()
}
}
if (config_update_value('delete_disabled_agents', get_parameter('delete_disabled_agents'), true) === false) {
$error_update[] = __('Max. days before disabled agents are deleted');
}
if (config_update_value('delete_old_messages', get_parameter('delete_old_messages'), true) === false) {
$error_update[] = __('Max. days before delete old messages');
}
@ -2231,6 +2235,10 @@ function config_process_config()
}
}
if (!isset($config['delete_disabled_agents'])) {
config_update_value('delete_disabled_agents', 0);
}
if (!isset($config['delete_old_messages'])) {
config_update_value('delete_old_messages', 21);
}

View File

@ -135,7 +135,16 @@ sub pandora_purgedb ($$$) {
}
}
}
# Delete manually disabled agents after some period
if (defined ($conf->{'_delete_disabled_agents'}) && $conf->{'_delete_disabled_agents'} > 0) {
log_message('PURGE', "Deleting old disabled agents (More than " . $conf->{'_delete_disabled_agents'} . " days).");
db_do ($dbh, "DELETE FROM tagente
WHERE UNIX_TIMESTAMP(ultimo_contacto) + ? < UNIX_TIMESTAMP(NOW())
AND disabled = 1
AND modo != 2", $conf->{'_delete_disabled_agents'} * 8600);
}
# Delete old data
if ($conf->{'_days_purge'} > 0) {
@ -685,6 +694,7 @@ sub pandora_load_config_pdb ($) {
$conf->{'_days_delete_not_initialized'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'days_delete_not_initialized'");
$conf->{'_delete_notinit'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'delete_notinit'");
$conf->{'_inventory_purge'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'inventory_purge'");
$conf->{'_delete_disabled_agents'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'delete_disabled_agents'");
$conf->{'_delete_old_messages'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'delete_old_messages'");
$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'");