From dc9feb747fe578d6e00af61f4d7710f7644c16ac Mon Sep 17 00:00:00 2001 From: Christian Ramseyer Date: Tue, 29 Jan 2019 23:40:43 +0100 Subject: [PATCH] Merge ASA.PM patch by stromsoe (#494} * Embedded # characters in the output for show names cause sshcollector not to collect any ARP entries on the ASA platform, since the $prompt variable matches in the middle of the output. Fix is to modify $prompt to match end-of-line. * Changing the terminal pager length should be done before sending show names instead of after. * Matching on IP address to see if a name needs to be mapped should include start and end field markers, in the event that the name returned from "show arp" embeds an IP address (eg, "abc1.2.3.4xyz") --- lib/App/Netdisco/SSHCollector/Platform/ASA.pm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/App/Netdisco/SSHCollector/Platform/ASA.pm b/lib/App/Netdisco/SSHCollector/Platform/ASA.pm index d28373bf..c0a4e540 100644 --- a/lib/App/Netdisco/SSHCollector/Platform/ASA.pm +++ b/lib/App/Netdisco/SSHCollector/Platform/ASA.pm @@ -75,21 +75,21 @@ sub arpnip { $expect->send( $args->{enable_password} ."\n" ); } - $prompt = qr/#/; + $prompt = qr/#\s*$/; ($pos, $error, $match, $before, $after) = $expect->expect(10, -re, $prompt); + $expect->send("terminal pager 2147483647\n"); + ($pos, $error, $match, $before, $after) = $expect->expect(5, -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); - $expect->send("show arp\n"); ($pos, $error, $match, $before, $after) = $expect->expect(60, -re, $prompt); + my @lines = split(m/\n/, $before); my @arpentries = (); - my @lines = split(m/\n/, $before); # ifname 192.0.2.1 0011.2233.4455 123 my $linereg = qr/[A-z0-9\-\.]+\s([A-z0-9\-\.]+)\s @@ -98,7 +98,7 @@ sub arpnip { foreach my $line (@lines) { if ($line =~ $linereg) { my ($ip, $mac) = ($1, $2); - if ($ip !~ m/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/) { + 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) { @@ -107,7 +107,7 @@ sub arpnip { } } } - if ($ip =~ m/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/) { + 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 }; } }