Server Fault is a question and answer site for system and network administrators. 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

I have a linux email server that I am thinking about moving into "the cloud". After investigating the pricing I see that my major cost is going to be in bandwidth. How would you guys suggest measuring the total amount of data transferred over a period of time?

share|improve this question
What distribution? – l0c0b0x Aug 12 '09 at 22:19
up vote 7 down vote accepted

I have successfully ran vnstat on servers in the past. It's avaliable packged for fedora & ubuntu (and probably other distros). There is also a php frontend avaliable that's very easy to setup.

share|improve this answer
thanks! vnstat shows me just what I need. Very easy setup for vnstat and the php frontend. – jasondewitt Aug 13 '09 at 14:36
  • ifconfig tells you the usage for an interface, including the amount of data transferred.
  • ntop logs and analyses traffic in a lot of ways.
  • iftop and iptraf show you connections and other data at real time
share|improve this answer
Check out bandwidthd as well. – David Rickman Aug 13 '09 at 5:42

If you want the low tech version, you could just cat /proc/net/dev record the time, and then do it again, and calculate it from that. However, be aware that the counter wraps around at 2^32 bytes (4GB) (at least on my recent 32-bit kernels):

Inter-|   Receive                                                |  Transmit
 face |bytes    packets errs drop fifo frame compressed multicast|bytes    packets errs drop fifo colls carrier compressed
    lo:   51433     617    0    0    0     0          0         0    51433     617    0    0    0     0       0          0
  eth0:3270597247 14887385    0    0    0     0          0         0 694109632 7720886    0    0    0     0       0          0
  pan0:       0       0    0    0    0     0          0         0        0       0    0    0    0     0       0          0

There is a perl routine to parse this in this blog post of mine: Debuging a script that parses /proc/net/dev

share|improve this answer
+1 for simplicity and availability. Nice. – Travis Bear Apr 23 '14 at 15:09

Run sysstat on your server through cron; the network information (sar -n ALL) will give you rxkB/s and txkB/s which you can easily turn into a total traffic figure.

share|improve this answer

snmp + mrtg / rrdtool (cacti)

share|improve this answer

As someone else mentioned, vnstat is a great tool that's easy to setup and should easily give you the information you need.

Note tho, your provider should give you a view into the tool they're using for bandwidth billing. There are multiple ways to track and bill for bandwidth usage (switch port measurements vs. virtual machine counters, 95% percentile vs. total bits sent, sent and received vs. sent only) that will have a substantial impact on your ultimate billing - it's quite important to base things off of the tool that they're using for billing in order to get a true picture of what your bandwidth costs will be. This way, you can accurately take action to shift or minimize your bandwidth usage before you get hit with a major bill for bandwidth.

share|improve this answer

munin has a basic plugin for networkusage

share|improve this answer

I use collectd to collect interface traffic counts, amongst other things, and a slightly altered version of this script to generate pretty graphs and counts. The output looks something like this though is quite variable if you have specific preferences as you can see from the rrdtool gallery. If you need more detail than simple interface traffic counts, then you can use the iptables module from collectd to count more specific traffic groups.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.