AnyEvent-Porttracker

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

NAME
    AnyEvent::Porttracker - Porttracker/PortIQ API client interface.

SYNOPSIS
       use AnyEvent::Porttracker;

       my $api = new AnyEvent::Porttracker
          host => "10.0.0.1",
          user => "admin",
          pass => "31331",
          tls  => 1,
       ;

       # Example 1
       # a simple request: ping the server synchronously

       my ($timestamp, $pid) = $api->req_sync ("ping");

       # Example 2
       # find all realms, start a discovery on all of them
       # and wait until all discovery processes have finished
       # but execute individual discoveries in parallel,
       # asynchronously

       my $cv = AE::cv;

       $cv->begin;
       # find all realms
       $api->req (realm_info => ["gid", "name"], sub {
          my ($api, @realms) = @_;

          # start discovery on all realms
          for my $realm (@realms) {
             my ($gid, $name) = @$realm;

             $cv->begin;
             $api->req (realm_discover => $gid, sub {
                warn "discovery for realm '$name' finished\n";
                $cv->end;
             });
          }

          $cv->end;
       });

       $cv->recv;

       # Example 3
       # subscribe to realm_poll_stop events and report each occurance

       $api->req (subscribe => "realm_poll_stop", sub {});
       $api->on (realm_poll_stop_event => sub {
          my ($api, $gid) = @_;
          warn "this just in: poll for realm <$gid> finished.\n";
       });

       AE::cv->recv; # wait forever

DESCRIPTION
    Porttracker (<http://www.porttracker.com/>) is a product that (among
    other things) scans switches and routers in a network and gives a
    coherent view of which end devices are connected to which switch ports
    on which switches and routers. It also offers a JSON-based client API,
    for which this module is an implementation.

    In addition to Porttracker, the PortIQ product is also supported, as it
    uses the same protocol.

    If you do not have access to either a Porttracker or PortIQ box then
    this module will be of little value to you.

    This module is an AnyEvent user, you need to make sure that you use and
    run a supported event loop.

    To quickly understand how this module works you should read how to
    construct a new connection object and then read about the event/callback
    system.

    The actual low-level protocol and, more importantly, the existing
    requests and responses, are documented in the official Porttracker API
    documentation (a copy of which is included in this module as
    AnyEvent::Porttracker::protocol.



( run in 0.763 second using v1.01-cache-2.11-cpan-39bf76dae61 )