From 82add0179d0a0ae6c2af0f3121d796ca269fde6c Mon Sep 17 00:00:00 2001 From: koichirok Date: Thu, 8 Mar 2012 06:35:48 +0000 Subject: [PATCH] 2012-03-08 Koichiro Kikuchi * util/pandora_db.pl: Don't delete alerts if non-init/unknown module to which these alerts assigned has not been deleted. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5716 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/ChangeLog | 5 +++++ pandora_server/util/pandora_db.pl | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index b1063c5691..0a1db6dc5f 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,8 @@ +2012-03-08 Koichiro Kikuchi + + * util/pandora_db.pl: Don't delete alerts if non-init/unknown + module to which these alerts assigned has not been deleted. + 2012-03-07 Sancho Lerena * util/pandora_xml_stress.conf diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 814b643e68..ffacd79886 100755 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -447,7 +447,7 @@ sub pandora_checkdb_consistency { db_do ($dbh, 'DELETE FROM tagente_modulo WHERE disabled = 0 AND id_agente_modulo = ?', $id_agente_modulo);; # Delete any alerts associated to the module - db_do ($dbh, 'DELETE FROM talert_template_modules WHERE id_agent_module = ?', $id_agente_modulo); + db_do ($dbh, 'DELETE FROM talert_template_modules WHERE id_agent_module = ? AND NOT EXISTS (SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente_modulo = ?)', $id_agente_modulo, $id_agente_modulo); } print "[CHECKDB] Deleting unknown data (More than " . $conf{'_days_delete_unknown'} . " days)... \n"; @@ -464,7 +464,7 @@ sub pandora_checkdb_consistency { db_do ($dbh, 'DELETE FROM tagente_modulo WHERE disabled = 0 AND id_agente_modulo = ?', $id_agente_modulo);; # Delete any alerts associated to the module - db_do ($dbh, 'DELETE FROM talert_template_modules WHERE id_agent_module = ?', $id_agente_modulo); + db_do ($dbh, 'DELETE FROM talert_template_modules WHERE id_agent_module = ? AND NOT EXISTS (SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente_modulo', $id_agente_modulo); } } print "[CHECKDB] Checking database consistency (Missing status)... \n";