I recently found myself considering moving one of our servers to the Rackspace Cloud. I needed to get an estimate of the cost for bandwidth usage.
I remembered I had installed vnstat on that server when it was deployed. This made the bandwidth calculation completely simple:
Just have vnstat give me the bandwidth sliced by Month:
$ vnstat -m eth0 / monthly month rx | tx | total -------------------------+--------------+-------------------------------------- Aug '09 7.00 GB | 8.48 GB | 15.48 GB %:: Sep '09 14.98 GB | 15.75 GB | 30.72 GB %%%:::: Oct '09 31.70 GB | 14.79 GB | 46.50 GB %%%%%%%%::: Nov '09 45.46 GB | 14.64 GB | 60.10 GB %%%%%%%%%%%::: Dec '09 73.71 GB | 15.40 GB | 89.11 GB %%%%%%%%%%%%%%%%%%:::: Jan '10 66.25 GB | 16.89 GB | 83.14 GB %%%%%%%%%%%%%%%%:::: -------------------------+--------------+-------------------------------------- estimated 94.97 GB | 24.21 GB | 119.18 GB
The install of vnstat on Ubuntu can be done with apt-get:
sudo apt-get install vnstat
Remember, once installed to initiate you vnstat DB. Just execute vnstat and it will tell you how. vnstat -u -i eth0 in my case
Then check the man page for the command to see all the different ways you will be able to slice and dice your network data
