diff --git a/pandora_server/lib/PandoraFMS/DiscoveryServer.pm b/pandora_server/lib/PandoraFMS/DiscoveryServer.pm index 7a5af26d07..903a9014c3 100644 --- a/pandora_server/lib/PandoraFMS/DiscoveryServer.pm +++ b/pandora_server/lib/PandoraFMS/DiscoveryServer.pm @@ -1220,6 +1220,7 @@ sub PandoraFMS::Recon::Base::report_scanned_agents($;$) { # Update parent relationships. foreach my $agent (@agents) { + # Avoid processing if does not exist. next unless (defined($agent->{'agent_id'})); diff --git a/pandora_server/lib/PandoraFMS/Recon/Base.pm b/pandora_server/lib/PandoraFMS/Recon/Base.pm index 0c89e3060e..e2c57aea34 100644 --- a/pandora_server/lib/PandoraFMS/Recon/Base.pm +++ b/pandora_server/lib/PandoraFMS/Recon/Base.pm @@ -1887,15 +1887,17 @@ sub scan($) { # Delete previous connections. $self->call('delete_connections'); - # Connectivity from address forwarding tables. - $self->call('message', "[2/6] Finding address forwarding table connectivity...", 3); + # Connect hosts that are still unconnected using known gateways. + $self->call('message', "[2/6] Finding host to gateway connectivity.", 3); $self->{'c_network_name'} = ''; - $self->{'step'} = STEP_AFT; - ($progress, $step) = (50, 10.0 / scalar(@hosts)); # From 50% to 60%. - for (my $i = 0; defined($hosts[$i]); $i++) { + $self->{'step'} = STEP_GATEWAY; + ($progress, $step) = (50, 10.0 / scalar(@hosts)); # From 70% to 80%. + $self->get_routes(); # Update the route cache. + foreach my $host (@hosts) { $self->call('update_progress', $progress); $progress += $step; - $self->aft_connectivity($hosts[$i]); + next if ($self->has_parent($host)); + $self->gateway_connectivity($host); } # Connect hosts that are still unconnected using traceroute. @@ -1910,18 +1912,17 @@ sub scan($) { $self->traceroute_connectivity($host); } - # Connect hosts that are still unconnected using known gateways. - $self->call('message', "[4/6] Finding host to gateway connectivity.", 3); + # Connectivity from address forwarding tables. + $self->call('message', "[4/6] Finding address forwarding table connectivity...", 3); $self->{'c_network_name'} = ''; - $self->{'step'} = STEP_GATEWAY; - ($progress, $step) = (70, 10.0 / scalar(@hosts)); # From 70% to 80%. - $self->get_routes(); # Update the route cache. - foreach my $host (@hosts) { + $self->{'step'} = STEP_AFT; + ($progress, $step) = (70, 10.0 / scalar(@hosts)); # From 50% to 60%. + for (my $i = 0; defined($hosts[$i]); $i++) { $self->call('update_progress', $progress); $progress += $step; - next if ($self->has_parent($host)); - $self->gateway_connectivity($host); + $self->aft_connectivity($hosts[$i]); } + } # Apply monitoring templates