Xenserver and APC UPS Management

Recently i got an incident of a customer that he wants to trigger a shutdown on UPS fault e.g. battery discharged.
If you want to let your normal physical windows machine be managed by those triggers form the ups you have to install the powerchute software and connect it to the ups. But if you want to do this with your Xen-Server you propably won't polute it with snmp or other libraries you have to care about every update.

The small elegant path consists of following steps:
- create a Windows VM
- install Powerchute UPS Management Suite on it and connect it to your UPS
- install the Xencenter
- create a bat that conatains:

c:\xe\xe -s masterserver -u root -pw rootpw vm-shutdown vm=vm
c:\xe\xe -s masterserver -u root -pw rootpw host-disable host=masterserver
c:\xe\xe -s masterserver -u root -pw rootpw host-shutdown host=masterserver
(remember not to shutdown the "management"-vm that runs the script, just the otherswich my contain e.g. sql server)

- go to the management interface
- create a event on battery discharge e.g. and add the bat file there
- be happy