mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 16:24:54 +02:00
Merge branch 'ent-12293-16468-borrado-de-agentes-deshabilitados-mediante-el-pandora_db' into 'develop'
delete agents pandora_db pandora_enterprise#12293 See merge request artica/pandorafms!6656
This commit is contained in:
commit
868598b1b2
@ -142,10 +142,18 @@ sub pandora_purgedb ($$$) {
|
|||||||
# Delete manually disabled agents after some period
|
# Delete manually disabled agents after some period
|
||||||
if (defined ($conf->{'_delete_disabled_agents'}) && $conf->{'_delete_disabled_agents'} > 0) {
|
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).");
|
log_message('PURGE', "Deleting old disabled agents (More than " . $conf->{'_delete_disabled_agents'} . " days).");
|
||||||
db_do ($dbh, "DELETE FROM tagente
|
my @agents_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->{'_delete_disabled_agents'} * 8600);
|
WHERE UNIX_TIMESTAMP(ultimo_contacto) + ? < UNIX_TIMESTAMP(NOW())
|
||||||
|
AND disabled = 1
|
||||||
|
AND modo != 2",
|
||||||
|
$conf->{'_delete_disabled_agents'} * 8600
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach my $agent_to_delete (@agents_to_delete) {
|
||||||
|
pandora_delete_agent($dbh, $agent_to_delete->{'id_agente'}, $conf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Delete old data
|
# Delete old data
|
||||||
@ -322,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 $agent_autodisable_to_delete (@agents_autodisable_to_delete) {
|
||||||
|
pandora_delete_agent($dbh, $agent_autodisable_to_delete->{'id_agente'}, $conf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Delete old netflow data
|
# Delete old netflow data
|
||||||
if (!defined($conf->{'_netflow_max_lifetime'})){
|
if (!defined($conf->{'_netflow_max_lifetime'})){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user