6

I use a 3G cellular Internet connection with a very strict traffic limit, but some times I go to office and use an unlimited and fast cable connection (and of course I do traffic-consuming operations, like updating the system there).

I'd like to keep track of how much have I already downloaded using the mobile connection (so, it can either filter by interface or be easily suspendable so that I can pause it when I use an unlimited line) this month (so, the counter most not reset when I reboot my laptop or reconnect, I'd lile to only reset it manually).

What's the easiest way to do this in Ubuntu 10.10?

I wouldn't like to set up any complex monitoring/billing systems.

3 Answers 3

3

The simplest method

You can use ifconfig on you network interface (mine is eth0) - it counts the amount of data sent and received since the interface was started.

# Bytes Receive
ifconfig eth0 | awk '/RX bytes/ {print $2}' | awk -F: '{print $2}'

# Bytes Transmitted
ifconfig eth0 | awk '/RX bytes/ {print $6}' | awk -F: '{print $2}'

# A human readable output
ifconfig eth0 | awk '/RX bytes/ {print $3, $4}' # Received
ifconfig eth0 | awk '/RX bytes/ {print $7, $8}' # Transmitted

Making it persistent

Not so simple

1
  • I restart it frequently and would like a persistent counter.
    – Ivan
    Nov 2, 2010 at 20:15
1

The Ubuntu community wiki lists instructions on using a couple of tools - ipac-ng and vnstat. They aren't necessarily simple, but they are better than writing your own scripts:

https://help.ubuntu.com/community/HowToMonitorInternetTrafficTotals

0

If you want a graphical way to track your network usage:

try:

  • this screenlet (you will need screenlets (search for screenlets in software center or do sudo apt-get install screenlets in a terminal, then launch screenlets from (alt+f2) the run dialog, and click the install screenlet button when the config dialog comes up.
  • There is an applet for gnome-panel that does the same job (but sadly I do not remember the name). I will add that to my answer as soon as I find it (I'm searching for it). you may be able to find it under netmonitor I think

For each of these, you can choose which interface (eth0, wlan0, etc) to track from their preferences. You can also clear your totals every time you disconnect, so you know exactly how much you have used.

You must log in to answer this question.

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