2014-06-24 Ramon Novoa <rnovoa@artica.es>

* 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
This commit is contained in:
ramonn 2014-06-24 13:20:19 +00:00
parent f8a4628d3a
commit 752b7a9fee
2 changed files with 23 additions and 3 deletions

View File

@ -1,3 +1,7 @@
2014-06-24 Ramon Novoa <rnovoa@artica.es>
* util/recon_scripts/snmp-recon.pl: Improved host connection.
2014-06-24 Vanessa Gil <vanessa.gil@artica.es>
* util/recon_scripts/snmpdevices.pl: Deleted file.

View File

@ -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);