fix delete conf agents pandora_enterprise#12293

This commit is contained in:
daniel 2023-11-29 14:30:45 +01:00
parent 1bacc36bc0
commit dcb04a64ee
1 changed files with 16 additions and 8 deletions

View File

@ -330,14 +330,22 @@ sub pandora_purgedb ($$$) {
AND id_rc NOT IN (SELECT id_report_content FROM treport_content_sla_combined)"); AND id_rc NOT IN (SELECT id_report_content FROM treport_content_sla_combined)");
} }
# Delete disabled autodisable agents after some period
# Delete disabled autodisable agents after some period if (defined ($conf->{'_days_autodisable_deletion'}) && $conf->{'_days_autodisable_deletion'} > 0) {
log_message ('PURGE', 'Delete autodisabled agents where last contact is bigger than ' . $conf->{'_days_autodisable_deletion'} . ' days.'); log_message ('PURGE', 'Delete autodisabled agents where last contact is bigger than ' . $conf->{'_days_autodisable_deletion'} . ' days.');
db_do ($dbh, "DELETE FROM tagente my @agents_autodisable_to_delete = get_db_rows (
WHERE UNIX_TIMESTAMP(ultimo_contacto) + ? < UNIX_TIMESTAMP(NOW()) $dbh,
AND disabled=1 "SELECT id_agente FROM tagente
AND modo=2", $conf->{'_days_autodisable_deletion'}*8600); WHERE UNIX_TIMESTAMP(ultimo_contacto) + ? < UNIX_TIMESTAMP(NOW())
AND disabled = 1
AND modo = 2",
$conf->{'_days_autodisable_deletion'} * 8600
);
foreach my $agents_autodisable_to_delete (@agents_to_delete) {
pandora_delete_agent($dbh, $agent_to_delete->{'id_agente'});
}
}
# Delete old netflow data # Delete old netflow data
if (!defined($conf->{'_netflow_max_lifetime'})){ if (!defined($conf->{'_netflow_max_lifetime'})){