This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Monitoring bandwidth

Hi,
at the moment i use the following scipt to see the bandwidth using:

 Code:
#!/usr/bin/perl -w

#prints time and bandwidth statistics (in kilobits)
$interval = 5;        #seconds
$|++;   #turns off output buffering
#open (LOGFILE, ">net-bandwidth.log") || die "Can't open log: $!.\n";

sub getpkt {
        open DEV,"/proc/net/dev";
        while() {
                if(/eth0/) {
                        @line=split(/:|\s+/);
                        close DEV;
                        return $line[2] ."\t". $line[10];
                        }
                }
                close DEV;
}
($inpkts,$outpkts) = split("\t", getpkt());

while(1){
        sleep $interval;
        ($inpkts2,$outpkts2) = split("\t", getpkt());

        #in
        $inbw = 8*(($inpkts2-$inpkts)/$interval)/1024;
        #out
        $outbw= 8*(($outpkts2-$outpkts)/$interval)/1024;

        #max
        $max = ($inbw > $outbw) ? $inbw : $outbw;

        #printf LOGFILE "%d\t%d\t%d\t%d\n", "time(), $inbw, $outbw, $max;
        printf STDOUT "%d\t%d\t%d\t%d\n", time(), $inbw, $outbw, $max; 
        $inpkts = $inpkts2;
        $outpkts = $outpkts2;

 

also i can view the connection-tracking to see what connections atm, but this is not very comfortable. I search a bandwidth monitoring where i can see like this e.g.:

Date/Time.....SRC.... Port.... DST.... Port.... kb.......% of max

kb  means how many kilobytes are used on this and the percent is the part of them from the maximum availible bandwidth which is definied in the network card settings.

so if my connection is slow, i can see exactly which computer and service do it.

Any know a tool like this, or has astaro this in theirs drawer?

[Moderator edit: changed "quote" UBB tag to "code", so the script is easier to read (indent). -andreas ]


This thread was automatically locked due to age.