From 68cbea9bd00f901171c662d90b94ca6ca053a595 Mon Sep 17 00:00:00 2001 From: ramonn Date: Wed, 12 May 2010 15:33:19 +0000 Subject: [PATCH] 2010-05-12 Ramon Novoa * lib/PandoraFMS/ReconServer.pm: Make sure the agent exists when searching by IP address. Fixes bug #2957130. * util/pandora_db.pl: Fixed bug #2957130. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2711 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/ChangeLog | 7 +++++++ pandora_server/lib/PandoraFMS/ReconServer.pm | 5 ++++- pandora_server/util/pandora_db.pl | 11 ++++++++--- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index fde741e887..a5b2585907 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,10 @@ +2010-05-12 Ramon Novoa + + * lib/PandoraFMS/ReconServer.pm: Make sure the agent exists + when searching by IP address. Fixes bug #2957130. + + * util/pandora_db.pl: Fixed bug #2957130. + 2010-05-12 Sergio Martin * man/man1/tentacle.1.gz: Deleted old man page diff --git a/pandora_server/lib/PandoraFMS/ReconServer.pm b/pandora_server/lib/PandoraFMS/ReconServer.pm index 2d2d3dc6ca..1fe64213fb 100644 --- a/pandora_server/lib/PandoraFMS/ReconServer.pm +++ b/pandora_server/lib/PandoraFMS/ReconServer.pm @@ -305,7 +305,10 @@ sub get_agent_from_addr ($$) { return 0 if (! defined ($ip_address) || $ip_address eq ''); - my $agent_id = get_db_value ($dbh, 'SELECT id_agent FROM taddress, taddress_agent WHERE taddress_agent.id_a = taddress.id_a AND ip = ?', $ip_address); + my $agent_id = get_db_value ($dbh, 'SELECT id_agent FROM taddress, taddress_agent, tagente + WHERE tagente.id_agente = taddress_agent.id_agent + AND taddress_agent.id_a = taddress.id_a + AND ip = ?', $ip_address); return (defined ($agent_id)) ? $agent_id : -1; } diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 77a0fe7efe..19557b193a 100755 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -393,14 +393,19 @@ sub pandora_checkdb_integrity { print "[INTEGRITY] Deleting orphan modules \n"; # Delete orphan modules in tagente_modulo - db_do ($dbh, 'DELETE FROM tagente_modulo WHERE id_agente NOT IN (select id_agente FROM tagente)'); + db_do ($dbh, 'DELETE FROM tagente_modulo WHERE id_agente NOT IN (SELECT id_agente FROM tagente)'); # Delete orphan modules in tagente_estado - db_do ($dbh, 'DELETE FROM tagente_estado WHERE id_agente NOT IN (select id_agente FROM tagente)'); + db_do ($dbh, 'DELETE FROM tagente_estado WHERE id_agente NOT IN (SELECT id_agente FROM tagente)'); # Delete orphan data_inc reference records db_do ($dbh, 'DELETE FROM tagente_datos_inc WHERE id_agente_modulo NOT IN (SELECT id_agente_modulo FROM tagente_modulo)'); - + + # Delete all non-used IP addresses from taddress + db_do ($dbh, 'DELETE FROM taddress WHERE id_a NOT IN (SELECT id_a FROM taddress_agent)'); + + # Check enterprise tables + enterprise_hook ('pandora_checkdb_integrity_enterprise', [$dbh]); } ###############################################################################