Here is a short script, which you can use to shutdown any Citrix Xenserver upon powerfailure,
Firstly you need a pc connected to a ups, running some sort of ups software, usually this software lets you run a script upon power failure, such as Apcupsd
Basically all you have to do is tell the ups software to run this script upon power failure.
DSTSRV="10.0.1.5" #Enter the Ip Address of your server
DSTUSER="root" #Enter your username root default
DSTPASS="password" #enter your password
SRVSHUT="xen1shutdown.sh" #this is a file created temporarily to shutdown your vms and server
SRVNAME="Yourxenservername" #enter your xenserver hostname here
xe -s "$DSTSRV" -u "$DSTUSER" -pw "$DSTPASS" vm-list | grep running -B 1 | grep name-label | awk -F: '{print $2}' | sed 's/ //' | awk -F: -v DSTSRV=$DSTSRV -v DSTUSER=$DSTUSER -v DSTPASS=$DSTPASS '{print "xe -s " DSTSRV " -u " DSTUSER " -pw "DSTPASS" vm-shutdown vm=\"" $1 "\""}' > "$SRVSHUT"
echo xe -s "$DSTSRV" -u "$DSTUSER" -pw "$DSTPASS" host-disable host="$SRVNAME" >> "$SRVSHUT"
echo xe -s "$DSTSRV" -u "$DSTUSER" -pw "$DSTPASS" host-shutdown host="$SRVNAME" >> "$SRVSHUT"
chmod 777 "$SRVSHUT"
./"$SRVSHUT"
rm -rf "$SRVSHUT"
Save this to a file give it execute permissions chmod +x whateveryoucallthisfile
Pls note that you have to edit the DSTSRV DSTUSER DSTPASS SRVNAME variables to reflect your servers ip username password and hostname
Hope you find this usefull, i had been searching for somethin like this, and didn’t find anything so i decided to write it myself
TYVM you’ve solved all my premlobs