You are not logged in.

#1 2007-06-12 07:49:38

bijoux
Member
Registered: 2007-04-29
Posts: 18

monitoring bandwidth speeds

Hello,
Does anybody know the algorithm to get upload/download transfers from /proc/net/dev? I am trying to write a script that generates upload/download rates per execution (not realtime) Thanks.

Offline

#2 2007-06-12 13:59:52

harlekin
Member
From: Germany
Registered: 2006-07-13
Posts: 408

Re: monitoring bandwidth speeds

Algorithm? Did you take a look at this file?

cat /proc/net/dev
Inter-|   Receive                                                |  Transmit
 face |bytes    packets errs drop fifo frame compressed multicast|bytes    packets errs drop fifo colls carrier compressed
    lo: 1261576   14674    0    0    0     0          0         0  1261576   14674    0    0    0     0       0          0
  eth0:       0       0    0    0    0     0          0         0        0       0    0    0    0     0       0          0
  eth1: 1042245    1317    0   23    0     0          0         0   134495    1280    0    0    0     0       0          0

You could easily create a bash script that does what you want to do.
Just grab the values. For example:

recv_bytes=`grep eth1 /proc/net/dev | awk '{print $2}'`
sleep 1
recv_bytes2=`grep eth1 /proc/net/dev | awk '{print $2}'`
echo "download rate: $[$recv_bytes2 - $recv_bytes] bytes per second"

Or something like this.

Last edited by harlekin (2007-06-12 14:03:15)


Hail to the thief!

Offline

Board footer

Powered by FluxBB