Designing High-Availability for Xen Virtual Machines with HP Serviceguard for Linux

Appendix Section III
Xen Legacy Monitor Script (cmxenvmd)
The script is designed to monitor Xen VMs which are started using the Xen control script. The script
depends on the Xen Configuration file to source Xen specific environment variables. The script must
be registered as a SERVICE_CMD in the package control script.
####################################################################
# (C) Copyright 2008 Hewlett-Packard Development Company, L.P.
# @(#) Serviceguard for Linux - Xen VM monitor Script
# @(#) Product Name : HP Serviceguard for Linux
# @(#) Product Version : A.11.18.02
# @(#) Patch Name :
#
# *** Note: This file MUST NOT be edited. *****
# Any changes made to it will be overwritten when you upgrade to the
# next release of HP Serviceguard for Linux.
#
# Changing this file may lead to unrecoverable package configuration
# problems.
###################################################################
set -a
. ${SGCONFFILE:=/etc/cmcluster.conf}
. ${SGXENCONFFILE:=./xenhost.cnf}
set +a
# wait for the VM to be up first time before monitoring
run=0
if [ -x ${SG_XEN_BIN} ]; then
while [ 1 ]; do
${SG_XEN_BIN} list | grep ${SG_XEN_VM_NAME} | awk '{print $5}' | grep -e "r" -e "b"
case $? in
0)
run=1
sleep ${SG_XEN_RETRY_INTERVAL}
continue ;;
1)
# exit only when Vm is completely halted
if [ $run -eq 1 ]; then
echo "Xen VM halted"
exit 1
else
continue
fi
;;
*)
echo "Unrecoverable error occured "
exit 255 ;;
esac
done
fi
22