From 847d7e16e39e7f954c8bae35d05a11016cc74d88 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Fri, 19 Oct 2018 15:31:31 +0100 Subject: [PATCH] #443 attempt to handle IPs and Names in show arp output - darknicht66 --- lib/App/Netdisco/SSHCollector/Platform/ASA.pm | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/App/Netdisco/SSHCollector/Platform/ASA.pm b/lib/App/Netdisco/SSHCollector/Platform/ASA.pm index 5d637e4d..d28373bf 100644 --- a/lib/App/Netdisco/SSHCollector/Platform/ASA.pm +++ b/lib/App/Netdisco/SSHCollector/Platform/ASA.pm @@ -78,6 +78,10 @@ sub arpnip { $prompt = qr/#/; ($pos, $error, $match, $before, $after) = $expect->expect(10, -re, $prompt); + $expect->send("show names\n"); + ($pos, $error, $match, $before, $after) = $expect->expect(60, -re, $prompt); + my @names = split(m/\n/, $before); + $expect->send("terminal pager 2147483647\n"); ($pos, $error, $match, $before, $after) = $expect->expect(5, -re, $prompt); @@ -94,7 +98,18 @@ sub arpnip { foreach my $line (@lines) { if ($line =~ $linereg) { my ($ip, $mac) = ($1, $2); - push @arpentries, { mac => $mac, ip => $ip }; + if ($ip !~ m/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/) { + foreach my $name (@names) { + if ($name =~ qr/name\s([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})\s([\w-]*)/x) { + if ($ip eq $2) { + $ip = $1; + } + } + } + } + if ($ip =~ m/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/) { + push @arpentries, { mac => $mac, ip => $ip }; + } } }