in reply to Re: Re: Netstat summary and Perl?
in thread Netstat summary and Perl?

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!

Replies are listed 'Best First'.
Re: Re: Re: Re: Netstat summary and Perl?
by u235sentinel (Hermit) on Apr 07, 2004 at 17:58 UTC
    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. :-)

          Normally I would do it with grep/sed/awk in a shell script.

      Sure you could. Buy why? You can do that in Perl without spawning off a process for each grep/sed/awk operation I am performing. Comparision:

      netstat -s | grep 'Trans' | awk '{... ehh... whatever...
      just used three processes...
      open PIPE... whatever... my @line = grep 'Trans',<PIPE>; close PIPOE
      used two. I know that is a weak example, but I hope it clarifies my position.

      Plan your work... work your plan...