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

  • ... and use a remote (or local) machine with something like RRDtool to log that data so a reboot doesn't take out your accounting data. – Jeff Ferland Jan 9 '12 at 19:25
  • This introduces a lot of extra overhead that isn't necessary - the data's collected for you already in /proc, for example. – Brett Dikeman Jan 9 '12 at 23:52
  • BeeDee: How would you go around to collect these data from /proc? Do you mean /proc on each individual VM? I cannot be sure that each VM behaves correctly. – ervingsb Jan 10 '12 at 8:44
  • Jeff Ferland: Can you give an example of how to do this with RRDtool on a remote machine? – ervingsb Jan 10 '12 at 8:44

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.

  • Matt: This sounds like what I need. Care to elaborate on how you do this? Will you share the script that captures data from xm top as well as cacti configuration? – ervingsb Jan 10 '12 at 8:46
  • Sorry I just found this post. I will see if I can get this for you next week, if you tell me you're still interested. – Matt Feb 16 '12 at 23:34
  • Matt, will you share the configuration? – ervingsb Mar 6 '12 at 8:56

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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