Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Bandwidth measurement with Perl?

by DaWolf (Curate)
on Sep 07, 2004 at 20:14 UTC ( [id://389198]=perlquestion: print w/replies, xml ) Need Help??

DaWolf has asked for the wisdom of the Perl Monks concerning the following question:

Greetings, fellow monks.

I'd like to make a script that measures my bandwidth (down/upload speed statistics). I've super searched and searched CPAN without any success.

Could you enlighten me with some module or approach suggestions?

Update:

I'm on windows here.

TIA,

my ($author_nickname, $author_email) = ("DaWolf","erabbott\@terra.com.br") if ($author_name eq "Er Galvão Abbott");

Replies are listed 'Best First'.
Re: Bandwidth measurement with Perl?
by BrowserUk (Patriarch) on Sep 07, 2004 at 22:48 UTC

    See the Win32::PerfLib module (it comes as standard with ActiveState distributions). It gives you access to some 240+ counters (XP, other versions vary). The API is not the easiest in the world to use, but the following program lists all the counters + a textual description of what they are. See the module POD for further info;


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail
    "Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon
Logging and Analysing Performance Counters in Windows
by ikegami (Patriarch) on Sep 07, 2004 at 21:00 UTC

    Windows has performance counters that can be used to track this, and even graph it. Head to Administrative Tools in the Control Panel and select Performance. you can see it charted in real time in System Monitor (right-click, Add Counter, ...) or log it using Counter Logs (right-click, New Log Settings, ...). I think there's a way to graph logs, but I didn't look for it since you wanted to use perl.

    When logging, you have the option of starting a new file and/or having a program automatically launched every X time units. You could use this to lauch a perl script to analyse the logs regularly. (Maybe it passes the log name as an arg?? Maybe only if you specify %1??).

    There a few file formats available (binary, CSV, TSV, binary circlular). Binary appears to be a list of packed timestamped samples preceeded with a header. You might be able to find some info on it if you search, or it should be pretty easy to deduce enough to use it. Or you could simply use CSV, which looks as follow:

    "(PDH-CSV 4.0) (Eastern Daylight Time)(240)","\Network Interface(D-Lin +k DFE-530TX PCI Fast Ethernet Adapter)\Bytes Total/sec" "09/07/2004 16:55:52.920","197.72459904908843" "09/07/2004 16:56:07.922","8463.4043604248636" "09/07/2004 16:56:22.924","3580.6992148876643" "09/07/2004 16:56:37.926","3465.1013327365235" "09/07/2004 16:56:52.928","3496.5035571311519" "09/07/2004 16:57:07.930","3578.1525481840044"

    (This should give a hint as to the fields in the bin format, btw)

Re: Bandwidth measurement with Perl?
by sintadil (Pilgrim) on Sep 07, 2004 at 20:20 UTC

    Any decent firewall has a userland interface program which spits out statistics, in text format. Work your magic on processing that output. Then you can use something like GD to make pretty graphs. If you're using PF, merlyn even wrote an excellent column on how to do exactly what you want.

      Thanks, but sadly seems that it's not ZoneAlarm's case...

      I forgot to say that I'm on Windows here...

      Regards,

      my ($author_nickname, $author_email) = ("DaWolf","erabbott\@terra.com.br") if ($author_name eq "Er Galvão Abbott");

        This node, which I found by doing a title search for "bandwidth usage", mentions SNMP, which you may be able to use.

        Ouch. Well, I did mention decent ...:)

        ZoneAlarm log files can be parsed but you probably don't want to do that to measure bandwidth. I used to have a script that parsed them. (It showed various things like the different ports that were probed at the various times of the day.)

Re: Bandwidth measurement with Perl?
by barathbr (Scribe) on Sep 07, 2004 at 22:17 UTC
    I would think if you have your own site, you could just use one of the Net::* modules to just transfer files and calculate a diff against start and end times (Time::*)

    Wouldnt that serve your purpose ??

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://389198]
Approved by Paladin
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2024-04-25 15:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found