diff --git a/Netdisco/Changes b/Netdisco/Changes index d474428b..4061f74d 100644 --- a/Netdisco/Changes +++ b/Netdisco/Changes @@ -3,6 +3,7 @@ [ENHANCEMENTS] * #27 add SNMP tips for Huawei, CloudEngine, Linksys (stoatwblr) + * Add GAIA Embedded SSH collector (not the same as VSX, apparently) [BUG FIXES] diff --git a/Netdisco/bin/netdisco-sshcollector b/Netdisco/bin/netdisco-sshcollector index 6b62e050..4eeae6f5 100755 --- a/Netdisco/bin/netdisco-sshcollector +++ b/Netdisco/bin/netdisco-sshcollector @@ -178,6 +178,8 @@ Currently, ARP tables can be retrieved from the following device classes: =over 4 +=item * L - Check Point GAIA Embedded + =item * L - Check Point VSX =item * L - Cisco ACE diff --git a/Netdisco/lib/App/Netdisco/SSHCollector/Platform/GAIAEmbedded.pm b/Netdisco/lib/App/Netdisco/SSHCollector/Platform/GAIAEmbedded.pm new file mode 100644 index 00000000..57e4973a --- /dev/null +++ b/Netdisco/lib/App/Netdisco/SSHCollector/Platform/GAIAEmbedded.pm @@ -0,0 +1,81 @@ +package App::Netdisco::SSHCollector::Platform::GAIAEmbedded; + +=head1 NAME + +App::Netdisco::SSHCollector::Platform::GAIAembedded + +=head1 DESCRIPTION + +Collect ARP entries from Checkpoint GAIA embedded Systems +To get this Plugin to work you have to add an User like 'netdisco' with +'Network admin' right in the GAIA embedded OS + +This collector uses "C" as the command for the arp utility on your +system. If you wish to specify an absolute path, then add an C +item to your configuration: + + sshcollector: + - ip: '192.0.2.1' + user: netdisco + password: letmein + platform: GAIAEmbedded + arp_command: 'arp' + +=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 => MACADDR, ip => IPADDR }>. + +=cut + +sub arpnip { + my ($self, $hostlabel, $ssh, $args) = @_; + + debug "$hostlabel $$ arpnip()"; + + my ($pty, $pid) = $ssh->open2pty or die "unable to run remote command"; + my $expect = Expect->init($pty); + + my ($pos, $error, $match, $before, $after); + my $prompt = qr/>/; + + ($pos, $error, $match, $before, $after) = $expect->expect(30, -re, $prompt); + + my $command = ($args->{arp_command} || 'arp'); + $expect->send("$command -n \n"); + ($pos, $error, $match, $before, $after) = $expect->expect(30, -re, $prompt); + + my @arpentries = (); + my @lines = split(m/\n/, $before); + +# ? (192.168.17.178) at 5C:F9:DD:71:1F:08 [ether] on LAN1 + my $linereg = qr/\?\s+\(([0-9\.]+)\)\s+at\s+([a-fA-F0-9:]+)/; + foreach my $line (@lines) { + if ($line =~ $linereg) { + my ($ip, $mac) = ($1, $2); + push @arpentries, { mac => $mac, ip => $ip }; + } + } + + $expect->send("exit\n"); + $expect->soft_close(); + + return @arpentries; +} + +1;