How do I monitor network traffic usage on Xen virtual machines running on Debian GNU/Linux Squeeze?
I have a number of Xen virtual machines (domUs) running on a few physical machines (dom0s). Each domU can be started on or live-migrated to one of the physical machines.
I would like to monitor and account how much network traffic is used on each domU. That is, how many bytes are being sent and received per month, week, day, hour.
I thought this would be a pretty common task for system administrators using virtual machines on Linux, however, I have not been able to find any easy way of doing it.
I am looking forward to hearing your approaches to this.
If you are using iptables, you can config something like this.
iptables traffic accounting
We wrote a script that runs on every dom0 each minutes, gets stats from "xm top" and pushes them to a memcache queue. From there Cacti queries the memcache queue, and updates the graphs.
If you want to centrally collect the information, and assuming the guests are trusted (ie, not client machines you're billing for) the most flexible way will probably be to install SNMP on the guests. Then you have thousands of options for SNMP-based monitoring and collection.
If that's too much overhead, look in
/proc/net/dev
; I suppose you could parse that yourself and upload values to a central machine in some fashion. If done on the dom0's, you would need to assign persistent vif names, etc.You could also install the iptables NetFlow module, and export the NetFlow data to an analyzer such as WANGuard (it also IP Accounting/Billing). It stores the data in a database so you have history, and you can configure all sorts of pretty graphs. Top Talkers by IP Address, protocol, etc.