The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
NAME
    Parse::Netstat - Parse the output of "netstat" command

VERSION
    This document describes version 0.07 of Parse::Netstat (from Perl
    distribution Parse-Netstat), released on 2014-08-16.

SYNOPSIS
     use Parse::Netstat qw(parse_netstat parse_netstat_win);

     my $output = `netstat -anp`;
     my $res = parse_netstat output => $output;

    Sample result:

     [
      200,
      "OK",
      {
        active_conns => [
          {
            foreign_host => "0.0.0.0",
            foreign_port => "*",
            local_host => "127.0.0.1",
            local_port => 1027,
            proto => "tcp",
            recvq => 0,
            sendq => 0,
            state => "LISTEN",
          },
          ...
          {
            foreign_host => "0.0.0.0",
            foreign_port => "*",
            local_host => "192.168.0.103",
            local_port => 56668,
            proto => "udp",
            recvq => 0,
            sendq => 0,
          },
          ...
          {
            flags   => "ACC",
            inode   => 15631,
            path    => "\@/tmp/dbus-VS3SLhDMEu",
            pid     => 4513,
            program => "dbus-daemon",
            proto   => "unix",
            refcnt  => 2,
            state   => "LISTENING",
            type    => "STREAM",
          },
        ],
      }
     ]

FUNCTIONS
  parse_netstat(%args) -> [status, msg, result, meta]
    Parse the output of Unix "netstat" command.

    Examples:

     parse_netstat();
    Netstat can be called with C<-n> (show raw IP addresses and port numbers instead
    of hostnames or port names) or without. It can be called with C<-a> (show all
    listening and non-listening socket) option or without. And can be called with
    C<-p> (show PID/program names) or without.

    For parsing output of Windows "netstat", see parse_netstat_win().

    Arguments ('*' denotes required arguments):

    *   output* => *str*

        Output of netstat command.

        This function only parses program's output. You need to invoke
        "netstat" on your own.

    *   tcp => *bool* (default: 1)

        Whether to parse TCP (and TCP6) connections.

    *   udp => *bool* (default: 1)

        Whether to parse UDP (and UDP6) connections.

    *   unix => *bool* (default: 1)

        Whether to parse Unix socket connections.

    Return value:

    Returns an enveloped result (an array).

    First element (status) is an integer containing HTTP status code (200
    means OK, 4xx caller error, 5xx function error). Second element (msg) is
    a string containing error message, or 'OK' if status is 200. Third
    element (result) is optional, the actual result. Fourth element (meta)
    is called result metadata and is optional, a hash that contains extra
    information.

     (any)

  parse_netstat_win(%args) -> [status, msg, result, meta]
    Parse the output of Windows "netstat" command.

    Netstat can be called with "-n" (show raw IP addresses and port numbers
    instead of hostnames or port names) or without. It can be called with
    "-a" (show all listening and non-listening socket) option or without. It
    can be called with "-o" (show PID) or without. And it can be called with
    "-b" (show executables) or not.

    For parsing output of Unix "netstat", see parse_netstat().

    Arguments ('*' denotes required arguments):

    *   output* => *str*

        Output of netstat command.

        This function only parses program's output. You need to invoke
        "netstat" on your own.

    *   tcp => *bool* (default: 1)

        Whether to parse TCP (and TCP6) connections.

    *   udp => *bool* (default: 1)

        Whether to parse UDP (and UDP6) connections.

    Return value:

    Returns an enveloped result (an array).

    First element (status) is an integer containing HTTP status code (200
    means OK, 4xx caller error, 5xx function error). Second element (msg) is
    a string containing error message, or 'OK' if status is 200. Third
    element (result) is optional, the actual result. Fourth element (meta)
    is called result metadata and is optional, a hash that contains extra
    information.

     (any)

SEE ALSO
HOMEPAGE
    Please visit the project's homepage at
    <https://metacpan.org/release/Parse-Netstat>.

SOURCE
    Source repository is at
    <https://github.com/sharyanto/perl-Parse-Netstat>.

BUGS
    Please report any bugs or feature requests on the bugtracker website
    <https://rt.cpan.org/Public/Dist/Display.html?Name=Parse-Netstat>

    When submitting a bug or request, please include a test-file or a patch
    to an existing test-file that illustrates the bug or desired feature.

AUTHOR
    Steven Haryanto <stevenharyanto@gmail.com>

COPYRIGHT AND LICENSE
    This software is copyright (c) 2014 by Steven Haryanto.

    This is free software; you can redistribute it and/or modify it under
    the same terms as the Perl 5 programming language system itself.