App-Netdisco

 view release on metacpan or  search on metacpan

bin/netdisco-do  view on Meta::CPAN

        $action, $actiontext, scalar localtime;
      $worker->run($job);
    }
    catch {
      $job->status('error');
      $job->log("error running job: $_");
    };

    if ($job->log eq 'failed to report from any worker!' and not $job->only_namespace) {
      pod2usage(
        -msg => (sprintf 'error: %s is not a valid action (no worker status recorded)', $action),
        -verbose => 2,
        -exitval => 3,
      );
    }

    info sprintf '%s: finished at %s', $action, scalar localtime;
    info sprintf '%s: status %s: %s', $action, $job->status, $job->log;
    $exitstatus = 1 if !$exitstatus and $job->status ne 'done';
  }
}

exit $exitstatus;

=encoding UTF-8

=head1 NAME

netdisco-do - Run any Netdisco job from the command-line.

=head1 SYNOPSIS

 ~/bin/netdisco-do <action> [-DISQR] [--enqueue] [--force] [--quiet] [-d <device> [-p <port>] [-e <extra>]]

=head1 DESCRIPTION

This program allows you to run any Netdisco poller job from the command-line.

=head1 ACTIONS

Note that some jobs (C<discoverall>, C<macwalk>, C<arpwalk>, C<nbtwalk>)
simply add entries to the Netdisco job queue for other jobs, so won't seem
to do much when you trigger them. Everything else happens in real-time.

However the "C<--enqueue>" option will force the queueing of the job,
regardless of type. This may be useful for cron-driven actions, or for actions
working across large IP spaces. Netdisco will refuse to queue more than 512
jobs at once unless you also add the "C<--force>" option.

For any action, if you wish to run one of its individual worker stages, then
pass C<action::stage> as the first argument to C<netdisco-do>, for example
C<discover::neighbors>.

Any action taking a C<device> parameter can be passed either a hostname or IP
address of any interface of a known or unknown device, or an IP prefix
(subnet) which will cause C<netdisco-do> to run the action on all addresses in
that range. The C<device> parameter may also be a filename that Netdisco will
open to read hostnames, IPs, or prefixes, one per line.

The C<device> parameter may be passed multiple times. In this case, all
addresses (after expanding IP Prefixes) will be handled one by one.

=head2 discover

Run a discover on the device (specified with C<-d>).

 ~/bin/netdisco-do discover -d 192.0.2.1

Run a discover on two different devices (specified with C<-d>).

 ~/bin/netdisco-do discover -d 192.0.2.1 -d 192.15.2.95

=head2 discoverall

Queue a discover for all known devices.

=head2 pingsweep

Scan an IP prefix (subnet) using ping utility (must be installed), any
host responding has a C<discover> job queued. It is recommended to queue
the C<pingsweep> job as well.

 ~/bin/netdisco-do pingsweep -d 192.0.2.0/24 --enqueue

The default ping timeout is 0.1 seconds. To change this, pass any number
to the C<-e> parameter.

=head2 macsuck

Run a macsuck on the device (specified with C<-d>).

 ~/bin/netdisco-do macsuck -d 192.0.2.1

Submit macsuck data directly to Netdisco in JSON format (see API web
docs for data format example):

 # pipe to standard input
 ~/bin/netdisco-do macsuck -d 192.0.2.1 -e '@-'
 # read from a file
 ~/bin/netdisco-do macsuck -d 192.0.2.1 -e '@/tmp/mac-address-table.json'
 # pass directly
 ~/bin/netdisco-do macsuck -d 192.0.2.1 -e '[{"ip": "string", "mac": "string", "dns": "string"}]'

=head2 macwalk

Queue a macsuck for all known devices.

=head2 arpnip

Run an arpnip on the device (specified with C<-d>).

 ~/bin/netdisco-do arpnip -d 192.0.2.1

Submit arpnip data directly to Netdisco in JSON format (see API web
docs for data format example):

 # pipe to standard input
 ~/bin/netdisco-do arpnip -d 192.0.2.1 -e '@-'
 # read from a file
 ~/bin/netdisco-do arpnip -d 192.0.2.1 -e '@/tmp/mac-address-table.json'
 # pass directly



( run in 0.425 second using v1.01-cache-2.11-cpan-5b529ec07f3 )