RE: Module to pull Netstat summary information?

From: David Le Blanc (david.leblanc_at_identity-solutions.com.au)
Date: 02/28/04


Date: Sat, 28 Feb 2004 15:19:42 +1100
To: "Wiggins d Anconia" <wiggins@danconia.org>,	<u235sentinel@comcast.net>,	<beginners@perl.org>,	<u235sentinel@comcast.net>


> -----Original Message-----
> From: Wiggins d Anconia [mailto:wiggins@danconia.org]
> Sent: Saturday, 28 February 2004 4:00 AM
> To: u235sentinel@comcast.net; beginners@perl.org
> Subject: Re: Module to pull Netstat summary information?
>
> Please bottom post....
>
> > This works however I was hoping perl had a module so I
> didn't have to
> run a system application. I've been playing around with
> modules such as
> scp, telnet and ftp. I'm curious if there is one for netstat.
> >
> > thanks :-)
> > > I am still new to working with Perl myself but I think I
> know the anwer
> > > to this one...
> > >
> > > #!/bin/perl
> > >
> > > use strict;
> > > use warnings;
> > >
> > > my $cmd = system('netstat -s')or die "Could not run command: $1";
> > > my $cmd = system('netstat -a | grep tcp')or die "Could not run
> command: $1";
> > >
> > > HTH
> > > Jas
> > >
> > > u235sentinel@comcast.net wrote:
> > >
> > > > Is there a CPAN module to pull netstat summary
> information from a
> system?
> > > >
> > > > Rather than run 'netstat -s', I was hoping to find some
> way within
> perl.
> > > >
> > > > What I basically want to do is generate a couple of reports from
> the summary
> > > output. ICMP and TCP information. If someone can point me in the
> right
> > > direction I should be good to go :-)
> > > >
> > > > Thanks
> > >
> > >
>
> It appears netstat just reads the values from /proc/net and
> prints them
> in a nice way, so presumably you could use standard opens on the /proc
> files and read specifically what you want rather than having netstat
> parse them for you. Though this might actually be one of the places
> where shelling out makes sense. CPAN didn't turn up much...

/proc is not available on most OS's. Mind you 'netstat' isn't worth
much on some of them either.

Are you developing for Linux? A generic Linux PROC handler might
be they way you go. Want to achieve CPAN developer status? :-)



Relevant Pages

  • Re: Module to pull Netstat summary information?
    ... > I am still new to working with Perl myself but I think I know the anwer ... If netstat executed successfully then it will return 0 (zero) otherwise ...
    (perl.beginners)
  • Re: Module to pull Netstat summary information?
    ... scp, telnet and ftp. ... I'm curious if there is one for netstat. ... >> I am still new to working with Perl myself but I think I know the anwer ...
    (perl.beginners)
  • Re: Network traffic stats
    ... it can calculate for packet sizes over X period. ... I assume the same data is available to netstat since it can record how ... write a front-end in perl or somesuch, ...
    (comp.unix.bsd.openbsd.misc)