| 1 | package App::Netdisco::SSHCollector::Platform::Clavister; | ||
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | App::Netdisco::SSHCollector::Platform::Clavister | ||
| 6 | |||
| 7 | =head1 DESCRIPTION | ||
| 8 | |||
| 9 | Collect ARP entries from Clavister firewalls. | ||
| 10 | These devices does not expose mac table through snmp. | ||
| 11 | |||
| 12 | =cut | ||
| 13 | |||
| 14 | use strict; | ||
| 15 | use warnings; | ||
| 16 | |||
| 17 | use Dancer ':script'; | ||
| 18 | use Moo; | ||
| 19 | |||
| 20 | =head1 PUBLIC METHODS | ||
| 21 | |||
| 22 | =over 4 | ||
| 23 | |||
| 24 | =item B<arpnip($host, $ssh)> | ||
| 25 | |||
| 26 | Retrieve ARP entries from device. C<$host> is the hostname or IP address | ||
| 27 | of the device. C<$ssh> is a Net::OpenSSH connection to the device. | ||
| 28 | Returns an array of hashrefs in the format { mac => MACADDR, ip => IPADDR }. | ||
| 29 | |||
| 30 | =back | ||
| 31 | |||
| 32 | =cut | ||
| 33 | |||
| 34 | sub 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 | |||
| 54 | 1; |