From 072d783a851bae76dadbbff555fe01e677410ac5 Mon Sep 17 00:00:00 2001 From: Christian Ramseyer Date: Fri, 13 May 2022 18:33:42 +0200 Subject: [PATCH] add Aruba.pm contributed by @sgb1reg in discussion #869 --- .../Netdisco/SSHCollector/Platform/Aruba.pm | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 lib/App/Netdisco/SSHCollector/Platform/Aruba.pm diff --git a/lib/App/Netdisco/SSHCollector/Platform/Aruba.pm b/lib/App/Netdisco/SSHCollector/Platform/Aruba.pm new file mode 100644 index 00000000..851fb4d6 --- /dev/null +++ b/lib/App/Netdisco/SSHCollector/Platform/Aruba.pm @@ -0,0 +1,51 @@ +package App::Netdisco::SSHCollector::Platform::Aruba; + +=head1 NAME + +App::Netdisco::SSHCollector::Platform::Aruba + +=head1 DESCRIPTION + +=cut + +use strict; +use warnings; + +use Dancer ':script'; +use Expect; +use Moo; + +=head1 PUBLIC METHODS + +=over 4 + +=item B + +Retrieve ARP entries from device. C<$host> is the hostname or IP address +of the device. C<$ssh> is a Net::OpenSSH connection to the device. + +Returns a list of hashrefs in the format C<{ mac =E MACADDR, ip =E IPADDR }>. + +=back + +=cut + +sub arpnip { + my ($self, $hostlabel, $ssh, $args) = @_; + + debug "$hostlabel $$ arpnip()"; + my @data = $ssh->capture("show arp"); + + chomp @data; + my @arpentries; + + # 172.16.20.15 00:24:b2:69:86:7d vlan interface state + foreach my $line (@data) { + my @fields = split m/\s+/, $line; + + push @arpentries, { mac => $fields[1], ip => $fields[0] }; + } + return @arpentries; +} + +1;