1package App::Netdisco::SSHCollector::Platform::BigIP;
2
3=head1 NAME
4
5App::Netdisco::SSHCollector::Platform::BigIP
6
7=head1 DESCRIPTION
8
9Collect ARP entries from F5 BigIP load balancers. These are Linux boxes,
10but feature an additional, proprietary IP stack which does not show
11up in the standard SNMP ipNetToMediaTable.
12
13These devices also feature a CLI interface similar to IOS, which can
14either be set as the login shell of the user, or be called from an
15ordinary shell. This module assumes the former, and if "show net arp"
16can't be executed, falls back to the latter.
17
18=cut
19
20use strict;
21use warnings;
22
23use Dancer ':script';
24use Moo;
25
26=head1 PUBLIC METHODS
27
28=over 4
29
30=item B<arpnip($host, $ssh)>
31
32Retrieve ARP entries from device. C<$host> is the hostname or IP address
33of the device. C<$ssh> is a Net::OpenSSH connection to the device.
34
35Returns a list of hashrefs in the format C<{ mac =E<gt> MACADDR, ip =E<gt> IPADDR }>.
36
37=back
38
39=cut
40
41sub arpnip {
42    my ($self, $hostlabel, $ssh, $args) = @_;
43
44    debug "$hostlabel $$ arpnip()";
45
46    my @data = $ssh->capture("show net arp");
47    unless (@data){
48        @data = $ssh->capture('tmsh -c "show net arp"');
49    }
50
51    chomp @data;
52    my @arpentries;
53
54    foreach (@data){
55        if (m/\d{1,3}\..*resolved/){
56            my (undef, $ip, $mac) = split(/\s+/);
57
58            # ips can look like 172.19.254.143%10, clean
59            $ip =~ s/%\d+//;
60
61            push(@arpentries, {mac => $mac, ip => $ip});
62        }
63    }
64
65    return @arpentries;
66}
67
681;
69