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]); } ###############################################################################