Thanks curx,
I have made some modifications to make that Linux LSB compatible.
#!/bin/bash
_VZCTL="/usr/sbin/vzctl"
_VZLIST="/usr/sbin/vzlist"
_VZLIST_OPTS="-Hostatus"
status()
{
STAT=`/usr/sbin/vzlist -Hostatus 105`
if [ $STAT = "running" ];then
echo "running"
return 0
else
echo "stopped"
return 3
fi
}
case "$1" in
start)
$_VZCTL $1 105
;;
stop)
$_VZCTL $1 105
;;
status)
status
RETVAL=$?
;;
*)
echo "Usage: havps1 {start|stop|status}"
exit 1
;;
esac
exit $RETVAL
I have another question.
The above script will give the status of the VPS and using that I can do the fail over. But the status will not help, if the VPS is in some resource problem like resource failure in UBC and VPS is in crashed state. But the status will be showing as running.
Is there any method to monitor the resource failure also ?
Any idea ? What is the best method ?