aboutsummaryrefslogtreecommitdiffstats
path: root/sampleApp/ensureSdncStandby.sh
diff options
context:
space:
mode:
Diffstat (limited to 'sampleApp/ensureSdncStandby.sh')
-rwxr-xr-xsampleApp/ensureSdncStandby.sh25
1 files changed, 25 insertions, 0 deletions
diff --git a/sampleApp/ensureSdncStandby.sh b/sampleApp/ensureSdncStandby.sh
new file mode 100755
index 0000000..b9e9864
--- /dev/null
+++ b/sampleApp/ensureSdncStandby.sh
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+dir=`dirname $0`
+# query SDN-C cluster status
+clusterStatus=$( $dir/sdnc.cluster )
+
+if [ "ACTIVE" = "$clusterStatus" ];then
+ # check that standby cluster is healthy
+ health=$( $dir/sdnc.monitor )
+ if [ "FAILURE" = "$health" ];then
+ echo "Backup site is unhealthy - can't accept traffic!"
+ exit 1
+ fi
+
+ # assume transient error as other side transitions to ACTIVE
+ echo "Cluster is ACTIVE but PROM wants STANDBY! Panic!"
+ exit 0
+
+elif [ "STANDBY" = "$clusterStatus" ]; then
+ echo "Cluster is standing by"
+ exit 0
+fi
+
+echo "Unknown cluster status '$clusterStatus'"
+exit 1