From 752b7a9fee3b47f4eab5f7cfad34f0b6ed4ba4b7 Mon Sep 17 00:00:00 2001 From: ramonn Date: Tue, 24 Jun 2014 13:20:19 +0000 Subject: [PATCH] 2014-06-24 Ramon Novoa * util/recon_scripts/snmp-recon.pl: Improved host connection. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@10278 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/ChangeLog | 4 ++++ .../util/recon_scripts/snmp-recon.pl | 22 ++++++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index e192fa2340..e0d74bfad7 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,7 @@ +2014-06-24 Ramon Novoa + + * util/recon_scripts/snmp-recon.pl: Improved host connection. + 2014-06-24 Vanessa Gil * util/recon_scripts/snmpdevices.pl: Deleted file. diff --git a/pandora_server/util/recon_scripts/snmp-recon.pl b/pandora_server/util/recon_scripts/snmp-recon.pl index 75fb159477..981a1e6584 100755 --- a/pandora_server/util/recon_scripts/snmp-recon.pl +++ b/pandora_server/util/recon_scripts/snmp-recon.pl @@ -781,14 +781,26 @@ sub connect_pandora_agents($$$$) { # Mark the two devices as connected. $CONNECTIONS{"${module_id_1}_${module_id_2}"} = 1; - $VISITED_DEVICES{$dev_1}->{'connected'} = 1; - $VISITED_DEVICES{$dev_2}->{'connected'} = 1; + if (ref($VISITED_DEVICES{$dev_1}) eq 'HASH') { + $VISITED_DEVICES{$dev_1}->{'connected'} = 1; + } else { + ${$VISITED_DEVICES{$dev_1}}->{'connected'} = 1; # An alias. + } + if (ref($VISITED_DEVICES{$dev_2}) eq 'HASH') { + $VISITED_DEVICES{$dev_2}->{'connected'} = 1; + } else { + ${$VISITED_DEVICES{$dev_2}}->{'connected'} = 1; # An alias. + } # Connect the modules if they are not already connected. my $connection_id = get_db_value($DBH, 'SELECT id FROM tmodule_relationship WHERE (module_a = ? AND module_b = ?) OR (module_b = ? AND module_a = ?)', $module_id_1, $module_id_2, $module_id_1, $module_id_2); if (! defined($connection_id)) { db_do($DBH, 'INSERT INTO tmodule_relationship (`module_a`, `module_b`, `id_rt`) VALUES(?, ?, ?)', $module_id_1, $module_id_2, $TASK_ID); } + + # Unset parents (otherwise the map will look broken). + db_do($DBH, 'UPDATE tagente SET id_parent=0 WHERE id_agente=?', $agent_1->{'id_agente'}); + db_do($DBH, 'UPDATE tagente SET id_parent=0 WHERE id_agente=?', $agent_2->{'id_agente'}); } @@ -873,6 +885,9 @@ sub traceroute_connectivity($) { # Check if the parent agent exists. my $agent = get_agent_from_addr ($DBH, $host_addr); + if (!defined($agent)) { + $agent = get_agent_from_name($DBH, $host_addr); + } if (defined ($agent)) { $parent_id = $agent->{'id_agente'}; last; @@ -981,7 +996,8 @@ foreach my $device ((@ROUTERS, @SWITCHES)) { host_connectivity($device); } foreach my $host (keys(%HOSTS)) { - next if ($VISITED_DEVICES{$host}->{'connected'} == 1); + next unless (ref($VISITED_DEVICES{$host}) eq 'HASH'); # Skip aliases. + next if ($VISITED_DEVICES{$host}->{'connected'} == 1); # Skip already connected hosts. traceroute_connectivity($host); } update_recon_task($DBH, $TASK_ID, -1);