cluster: RHEL56 - resource-agents: Add RHEVM status program

Lon Hohberger lon at fedoraproject.org
Wed Oct 27 20:02:50 UTC 2010


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=4614278a1c9d035299873c85b1a4afc9203d4142
Commit:        4614278a1c9d035299873c85b1a4afc9203d4142
Parent:        2c6188e5cfc2ef8ef681ae7d264c27b401839585
Author:        Lon Hohberger <lhh at redhat.com>
AuthorDate:    Fri Jun 4 18:54:21 2010 -0400
Committer:     Lon Hohberger <lhh at redhat.com>
CommitterDate: Wed Oct 27 15:57:22 2010 -0400

resource-agents: Add RHEVM status program

Resolves: rhbz#583788

Signed-off-by: Lon Hohberger <lhh at redhat.com>
---
 rgmanager/src/utils/Makefile         |    6 +++-
 rgmanager/src/utils/rhev-check.sh.in |   55 ++++++++++++++++++++++++++++++++++
 2 files changed, 60 insertions(+), 1 deletions(-)

diff --git a/rgmanager/src/utils/Makefile b/rgmanager/src/utils/Makefile
index 4cc16a9..6f04f90 100644
--- a/rgmanager/src/utils/Makefile
+++ b/rgmanager/src/utils/Makefile
@@ -22,7 +22,7 @@ CFLAGS+= -DPACKAGE_VERSION=\"${RELEASE}\"
 
 LDFLAGS+= -L${libdir} -L../../../cman/lib -L../../../ccs/lib -lcman -lpthread -ldl -lncurses -L../clulib -lclulib -lccs
 
-TARGETS=clubufflush clufindhostname clustat clusvcadm clulog clunfslock
+TARGETS=clubufflush clufindhostname clustat clusvcadm clulog clunfslock rhev-check.sh
 
 all: ${TARGETS}
 
@@ -55,6 +55,10 @@ clunfslock: clunfslock.sh
 	cp clunfslock.sh clunfslock
 	chmod 755 clunfslock
 
+rhev-check.sh: rhev-check.sh.in
+	cp rhev-check.sh.in rhev-check.sh
+	chmod 755 rhev-check.sh
+
 clean:
 	rm -f *.o $(TARGETS)
 
diff --git a/rgmanager/src/utils/rhev-check.sh.in b/rgmanager/src/utils/rhev-check.sh.in
new file mode 100644
index 0000000..7baad17
--- /dev/null
+++ b/rgmanager/src/utils/rhev-check.sh.in
@@ -0,0 +1,55 @@
+#!/bin/sh
+
+MYNAME=`basename $0`
+
+do_log()
+{
+	declare severity=$1
+
+	shift
+	echo "<$severity> $*"
+	clulog -l 6 -n "$MYNAME" -s $severity "$*"
+}
+
+if [ -z "$1" ]; then
+	do_log 4 No host specified.
+	exit 1
+fi
+
+do_log 6 "Checking RHEV status on $1"
+
+tries=3
+http_code=
+
+while [ $tries -gt 0 ]; do
+	
+	# Record start/end times so we can calculate the difference
+	start_time=$(date +%s)
+	http_code="$(curl -m 10 -sk https://$1/RHEVManagerWeb/HealthStatus.aspx -D - | head -1 | cut -f2 -d' ')"
+
+	if [ "$http_code" = "200" ]; then
+		exit 0
+	fi
+
+	# Reduce sleep time if the attempt took a noticeable amount
+	# of time.
+	end_time=$(date +%s)
+	delta=$(((end_time - start_time)))
+	sleep_time=$(((5 - delta)))
+
+	((tries-=1))
+
+	# if we're going to retry and we have a nonzero sleep time,
+	# go to sleep.
+	if [ $tries -gt 0 ] && [ $sleep_time -gt 0 ]; then
+		echo sleep $sleep_time
+	fi
+done
+
+if [ -n "$http_code" ]; then
+	do_log 3 "RHEV Status check on $1 failed; last HTTP code: $http_code"
+else
+	do_log 3 "RHEV Status check on $1 failed"
+fi
+
+exit 1


More information about the cluster-commits mailing list