1package App::Netdisco::SSHCollector::Platform::Clavister;
2
3=head1 NAME
4
5App::Netdisco::SSHCollector::Platform::Clavister
6
7=head1 DESCRIPTION
8
9Collect ARP entries from Clavister firewalls.
10These devices does not expose mac table through snmp.
11
12=cut
13
14use strict;
15use warnings;
16
17use Dancer ':script';
18use Moo;
19
20=head1 PUBLIC METHODS
21
22=over 4
23
24=item B<arpnip($host, $ssh)>
25
26Retrieve ARP entries from device. C<$host> is the hostname or IP address
27of the device. C<$ssh> is a Net::OpenSSH connection to the device.
28Returns an array of hashrefs in the format { mac => MACADDR, ip => IPADDR }.
29
30=back
31
32=cut
33
34sub arpnip {
35    my ($self, $hostlabel, $ssh, @args) = @_;
36    debug "$hostlabel $$ arpnip()";
37
38    my @data = $ssh->capture("neighborcache");
39    chomp @data;
40    my @arpentries;
41
42    foreach (@data){
43        next if /^Contents of Active/;
44        next if /^Idx/;
45        next if /^---/;
46        my @fields = split /\s+/, $_;
47        my $mac = $fields[2];
48        my $ip = $fields[3];
49        push(@arpentries, {mac => $mac, ip => $ip});
50    }
51    return @arpentries;
52}
53
541;
55