6

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?

jasondewitt
  • 193
  • 2
  • 3
  • 8

8 Answers8

7

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.

theotherreceive
  • 8,365
  • 1
  • 31
  • 44
3
  • 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
Javier
  • 9,268
  • 2
  • 24
  • 24
3

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

Kyle Brandt
  • 83,619
  • 74
  • 305
  • 448
1

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.

womble
  • 96,255
  • 29
  • 175
  • 230
1

snmp + mrtg / rrdtool (cacti)

alexus
  • 13,112
  • 32
  • 117
  • 174
1

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.

Jason Abate
  • 441
  • 4
  • 3
0

munin has a basic plugin for networkusage

blauwblaatje
  • 953
  • 1
  • 6
  • 19
0

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.

David Spillett
  • 22,754
  • 45
  • 67