Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How Can I count the received data from the internet.

I want to run my bash script and count how many MB it receive.

It could be stats for whole system.

share|improve this question

migrated from stackoverflow.com Dec 30 '12 at 16:24

This question came from our site for professional and enthusiast programmers.

    
This question is near serverfault, but stay linked to programmation... – F. Hauri Dec 30 '12 at 1:48
    
Ok. I'll remember. I'm sorry. – bluesm Dec 30 '12 at 1:54
up vote 1 down vote accepted

watch your network devices

ifconfig

ip -s link show

cat /proc/net/dev

or better use iptables whith specific counters, that let you quantize by protocol, kind of connexions, durations, etc...

create a counter rule with no jump:

iptables -A INPUT -i eth0 -p tcp --dport 80

than watch them with

iptables -nvxL INPUT

(for playing with iptable, root access is needed).

share|improve this answer
    
Why amount of data in /proc/net/dev sometimes resets ? – bluesm Dec 30 '12 at 2:08
    
What do you mean by sometimes? As I know, driver module as to be unloaded in order to reset counters (ifdown ... rmmod ... modprobe ... ifup ). But maybe are you speaking about loop happening when all bits of integer counter are full (likely depending on your architecture). – F. Hauri Dec 30 '12 at 17:42

You can use pv command, see man pv(1) page. Also you can try different bandwidth monitoring tools.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .