Monitoring the traffic usage (bytes received/transmitted) of Xen VMs can be tricky, there are very few management scripts and panels available for you. Here is a tutorial to get you started with monitoring, alerting and null routing abusive Xen guests.
Just want the source?
First off make sure that MongoDB is installed (
apt-get install mongodb for Debian/Ubuntu) and the Xen hypervisor is installed using the
Next follow these steps:
bundle installinstall necessary dependencies.
bwmon.rblines 101, 110 and 112 to your own email address, domain and subject respectively.
ruby addvm.rbAdd all your VMs with their hostnames (must be the same as
xm listand their config file).
./install.shMove the necessary scripts in place.
- Edit your crontab (
crontab -e) to run
bash /path/to/start.shat your specified interval.
- The monitor will then run the script at that interval and email you and nullroute the VM if it goes over its bandwidth allocation.
How does it work
bwmon.rb will parse the output of
xm top to get the current received & transmitted bytes for each VM. This is then logged to the DB in both cumulative and just raw form, this is then checked against the allowance and if it exceeds the VM's allowance then the IP address is null routed by REJECTing all packets in the chains INPUT, OUTPUT and FORWARD using
If you want to contact me for any more information I'm available on twitter @Will3942 or by email email@example.com