diff options
author | Michael Janczyk | 2010-08-18 22:00:51 +0200 |
---|---|---|
committer | Michael Janczyk | 2010-08-18 22:00:51 +0200 |
commit | 304f7d60e1bbe0098a6c0aaf64c8e352025cffe4 (patch) | |
tree | 85cfe26dbddadef9c469dff24635b5d1989c82b9 /os-plugins/plugins/xen/files/xen.examples/scripts/vm-monitor | |
parent | update makefile to install squashfs binaries (diff) | |
parent | Merge branch 'master' into vmgrid (diff) | |
download | core-304f7d60e1bbe0098a6c0aaf64c8e352025cffe4.tar.gz core-304f7d60e1bbe0098a6c0aaf64c8e352025cffe4.tar.xz core-304f7d60e1bbe0098a6c0aaf64c8e352025cffe4.zip |
Merge branch 'vmgrid'
Diffstat (limited to 'os-plugins/plugins/xen/files/xen.examples/scripts/vm-monitor')
-rwxr-xr-x | os-plugins/plugins/xen/files/xen.examples/scripts/vm-monitor | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/os-plugins/plugins/xen/files/xen.examples/scripts/vm-monitor b/os-plugins/plugins/xen/files/xen.examples/scripts/vm-monitor new file mode 100755 index 00000000..1c9a1791 --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/scripts/vm-monitor @@ -0,0 +1,41 @@ +#!/bin/bash + +basedir=$(dirname "$0") +HA_TICK=2 + +monitor() { + local path=$1 + local name=$2 + local uuid=$3 + local host=$4 + local count=0 + path=$path/lock + + while : + do + echo "name=$name uuid=$uuid host=$host count=$count" > $path + count=$(($count+1)) + sleep $HA_TICK + done& +} + +create_lock() { + local path=$1/lock + local rc=0 + + [ -f $path ] || touch $path + flock -x -w $HA_TICK $path $basedir/vm-monitor $* + rc=$? + if [ $rc -eq 1 ]; then + echo `cat $path` + exit 1 + else + exit $rc + fi +} + +if [ $0 = "$basedir/set-lock" ]; then + create_lock $* +elif [ $0 = "$basedir/vm-monitor" ]; then + monitor $* +fi |