Can I log interface statistics?

Asked by George Brower

As more ISPs impose, test, or plan bandwidth caps, I'd like to know how much bandwidth I use.

The data are on the 'gnome-nettools' Devices tab.

I'd like to write the data to a file, periodically and at shutdown.

I've looked in the FAQ on this site and this forum.

Is there a way to periodically select network interfaces in turn and log their statistics?

A chron job comes to mind, but I'm relatively new to Linux and hope to learn whether that is the best way to go before jumping in.

Thanks.

George

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu gnome-nettool Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Christoph Langner (chrissss) said :
#1

The easiest way to monitor you traffic is vnstat [1]

$ sudo apt-get install vnstat

After that you've got to configure what network device should be monitored. E.g.

$ sudo vnstat -u -i ppp0

Now you can check how much you transmit

$ vnstat --months
ppp0
           month rx | tx | total
        ------------------------+---------------+---------------
          Aug '07 169728 MB | 57720 MB | 227449 MB
          Sep '07 138361 MB | 48635 MB | 186997 MB
          Oct '07 104895 MB | 44214 MB | 149109 MB
          Nov '07 113337 MB | 51436 MB | 164774 MB
          Dec '07 106465 MB | 38694 MB | 145159 MB
          Jan '08 161278 MB | 51183 MB | 212462 MB
        ------------------------+---------------+---------------
        estimated 166653 MB | 52889 MB | 219542 MB

The only problem. This works only, when you've got a device which is directly connected to the internet (like a dial up connection pppX) or when you're computer is the only one which is connected to your lan. When you monitor e.g. eth0 and transmit data between your computers inside your lan, you wan't get correct transfer data.

[1] http://humdi.net/vnstat/

Can you help with this problem?

Provide an answer of your own, or ask George Brower for more information if necessary.

To post a message you must log in.