Created
August 9, 2022 18:23
-
-
Save rc9000/9b2f75e6b6c690472e3cbb41373cd585 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
use Data::Dumper; | |
=head1 PUBLIC METHODS | |
=over 4 | |
=item B<arpnip($host, $ssh)> | |
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<gt> MACADDR, ip =E<gt> 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) { | |
debug "LINE=$line"; | |
my @fields = split m/\s+/, $line; | |
debug Dumper(\@fields); | |
push @arpentries, { mac => $fields[1], ip => $fields[0] }; | |
} | |
return @arpentries; | |
} | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment