From 8ab6ed98cb3d9b51c32416f3eb7e04a63ead534b Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Tue, 20 Mar 2012 12:23:39 +0000 Subject: [PATCH] 2012-03-20 Miguel de Dios * util/pandora_db.pl: added lines to purge the contents in the report that have not a modules or agents. Merged from the branch pandora_4.0 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5799 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/ChangeLog | 7 +++++++ pandora_server/util/pandora_db.pl | 13 +++++++++++++ 2 files changed, 20 insertions(+) diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index f3cecf0e2c..0788078db6 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,10 @@ +2012-03-20 Miguel de Dios + + * util/pandora_db.pl: added lines to purge the contents in the report that + have not a modules or agents. + + Merged from the branch pandora_4.0 + 2012-03-12 Sancho Lerena * util/pandora_xml_stress.agents diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 9f30e0e42b..e87f2a7400 100755 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -232,6 +232,19 @@ sub pandora_purgedb ($$) { } else { print "[PURGE] No data in tagente_access\n"; } + + #Purge the reports + print "[PURGE] Delete contents in report that have some deleted modules...\n"; + db_do ($dbh, "DELETE FROM treport_content WHERE id_agent_module NOT IN (SELECT id_agente_modulo FROM tagente_modulo) AND id_agent_module != 0;"); + db_do ($dbh, "DELETE FROM treport_content_item WHERE id_agent_module NOT IN (SELECT id_agente_modulo FROM tagente_modulo) AND id_agent_module != 0;"); + db_do ($dbh, "DELETE FROM treport_content_sla_combined WHERE id_agent_module NOT IN (SELECT id_agente_modulo FROM tagente_modulo) AND id_agent_module != 0;"); + + print "[PURGE] Delete contents in report that have some deleted agents...\n"; + db_do ($dbh, "DELETE FROM treport_content WHERE id_agent NOT IN (SELECT id_agente FROM tagente) AND id_agent != 0;"); + + print "[PURGE] Delete empty contents in report (like SLA or Exception)...\n" + db_do ($dbh, "DELETE FROM treport_content WHERE type LIKE 'exception' AND id_rc NOT IN (SELECT id_report_content FROM treport_content_item);"); + db_do ($dbh, "DELETE FROM treport_content WHERE type LIKE 'sla' AND id_rc NOT IN (SELECT id_report_content FROM treport_content_sla_combined);"); } ###############################################################################