You are not logged in.
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
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