in reply to Netstat summary and Perl?

That's a rather vague question. It all depends on what you are trying to do on one hand and on the other my visceral response is "there's damn little that isn't possible in Perl."

Is there a specific set of information you are trying to glomb or are you just trying to slurp and process the whole output?

Replies are listed 'Best First'.
Re: Re: Netstat summary and Perl?
by u235sentinel (Hermit) on Apr 07, 2004 at 17:22 UTC
    I was looking at gathering specific bits of information from the TCP and ICMP summary information. I didn't give specific information beyond this mainly because I'm debating which pieces I want.

    I was thinking of items such as retransmissions, failed connections and packets discarded. There is more I may want to capture and process. Right now I'm scoping the needs and what is available. Thx

          Right now I'm scoping the needs and what is available.

      And you aren't giving me much to work with.

      However, let's look at retransmissons for a second. Just like I taught myself how to translate or search for what information I need in the output of the command I am going to do the same for Perl:

      : : some handwaving... : open PIPE,"netstat -s |" or die $!; my @slurp=<PIPE>; close PIPE; chomp @slurp; grep /Retran/,@slurp; printf "%s\n",join("\n",@slurp); : :
      is going to yeild me something like:
      TCPLostRetransmit: 0 TCPFastRetrans: 0 TCPForwardRetrans: 0 TCPSlowStartRetrans: 0

      What you do beyond that depends on your requirements. I recommend you sit down and develop your requirements thoroughly and then plan your attack rather than fit your requirements to your attack. :-)

      I hope this isn't homework!

        I hope this isn't homework!

        Rofl! I wasn't looking for code or the solution actually. I started by asking if there was a Perl module that would be able to pull netstat information. Summary information at that. I was hoping to stay away from calling netstat and grepping / pattern matching. This way I could use the same code on just about any machine running Perl.

        I recommend you sit down and develop your requirements thoroughly and then plan your attack rather than fit your requirements to your attack

        Understood. I wasn't sure how much Perl could do for me in this case. Calling netstat and grepping works for me. Normally I would do it with grep/sed/awk in a shell script. :-)