From 179b2b5d985783c796c1276c9614e7e4de260baa Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Fri, 10 Oct 2014 16:43:32 +0200 Subject: [PATCH] Added a last check for host interface names. --- pandora_server/util/recon_scripts/snmp-recon.pl | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pandora_server/util/recon_scripts/snmp-recon.pl b/pandora_server/util/recon_scripts/snmp-recon.pl index 60573a2369..174667caa9 100755 --- a/pandora_server/util/recon_scripts/snmp-recon.pl +++ b/pandora_server/util/recon_scripts/snmp-recon.pl @@ -271,7 +271,7 @@ sub get_if_from_ip($$$) { } ######################################################################################## -# Get the MAC address for the interface with the given IP address. +# Get an interface name from a MAC address. ######################################################################################## sub get_if_from_mac($$$) { my ($device, $community, $mac) = @_; @@ -639,13 +639,17 @@ sub host_connectivity($) { my $host = $ARP_CACHE{$mac}; next unless defined ($HOSTS{$host}); my $device_if_name = get_if_from_aft($device, $COMMUNITIES{$device}, $mac); + my $host_if_name = defined($COMMUNITIES{$host}) ? get_if_from_mac($host, $COMMUNITIES{$host}, $mac) : ''; if ($VISITED_DEVICES{$device}->{'type'} eq 'router') { - message("Host $host is connected to router $device (if $device_if_name)."); + message("Host $host " . ($host_if_name ne '' ? "(if $host_if_name)" : '') . " is connected to router $device (if $device_if_name)."); + } + elsif ($VISITED_DEVICES{$device}->{'type'} eq 'switch') { + message("Host $host " . ($host_if_name ne '' ? "(if $host_if_name)" : '') . " is connected to switch $device (if $device_if_name)."); } else { - message("Host $host is connected to switch $device (if $device_if_name)."); + message("Host $host " . ($host_if_name ne '' ? "(if $host_if_name)" : '') . " is connected to host $device (if $device_if_name)."); } - connect_pandora_agents($device, $device_if_name, $host, ''); + connect_pandora_agents($device, $device_if_name, $host, $host_if_name); } }