Send netdisco-users mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        https://lists.sourceforge.net/lists/listinfo/netdisco-users
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of netdisco-users digest..."
Today's Topics:

   1. PaloAlto ssh collector (Davide Garofalo)
--- Begin Message ---
PaloAlto sshcollector module doesn't work.
I modified it as follow and now it works fine, but i don't know it is
following the best practies

File:
/home/netdisco/perl5/lib/perl5/App/Netdisco/SSHCollector/Platform

Function:

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/> \r?$/;

#    ($pos, $error, $match, $before, $after) = $expect->expect(20, -re,
$prompt);
#    $expect->send("set cli pager off\n");
#    ($pos, $error, $match, $before, $after) = $expect->expect(10, -re,
$prompt);
#    $expect->send("show arp all\n");
#    ($pos, $error, $match, $before, $after) = $expect->expect(20, -re,
$prompt);

#    my @arpentries;
#    for (split(/\r\n/, $before)){
#        next unless $_ =~ m/(\d{1,3}\.){3}\d{1,3}/;
#        my ($tmp, $ip, $mac) = split(/\s+/);
#        if ($ip =~ m/(\d{1,3}\.){3}\d{1,3}/ && $mac =~
m/([0-9a-f]{2}:){5}[0-9a-f]{2}/i) {
#             push(@arpentries, { ip => $ip, mac => $mac });
#        }
#    }

    ($pos, $error, $match, $before, $after) = $expect->expect(20, -re,
$prompt);
    $expect->send("set cli pager off\n show arp all\n");
    ($pos, $error, $match, $before, $after) = $expect->expect(10, -re,
$prompt);

    my @arpentries = ();
    for (split(/\r\n/, $after)){
        next unless $_ =~ m/(\d{1,3}\.){3}\d{1,3}/;
        my ($tmp, $ip, $mac) = split(/\s+/);
        if ($ip =~ m/(\d{1,3}\.){3}\d{1,3}/ && $mac =~
m/([0-9a-f]{2}:){5}[0-9a-f]{2}/i) {
             push(@arpentries, { ip => $ip, mac => $mac });
        }
    }

    $expect->send("exit\n");
    $expect->soft_close();

    return @arpentries;
}

-- 
*Davide Garofalo*

--- End Message ---
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Netdisco mailing list - Digest Mode
[email protected]
https://lists.sourceforge.net/lists/listinfo/netdisco-users

Reply via email to