Add osm_health.sh check 39/6539/1
authorMike Marchetti <mmarchetti@sandvine.com>
Fri, 21 Sep 2018 16:03:05 +0000 (12:03 -0400)
committerMike Marchetti <mmarchetti@sandvine.com>
Fri, 21 Sep 2018 16:03:05 +0000 (12:03 -0400)
Change-Id: I2b9a962d0bb179eb250ea1c2097ec37f52c97144
Signed-off-by: Mike Marchetti <mmarchetti@sandvine.com>
installers/osm_health.sh [new file with mode: 0755]

diff --git a/installers/osm_health.sh b/installers/osm_health.sh
new file mode 100755 (executable)
index 0000000..8852ab3
--- /dev/null
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+WAIT_TIME=30
+NUM_SERVICES_WITH_HEALTH=3
+
+while getopts "w:s:n:" o; do
+    case "${o}" in
+        w)
+            WAIT_TIME=${OPTARG}
+            ;;
+        s)
+            STACK_NAME=${OPTARG}
+            ;;
+        n)
+            NUM_SERVICES_WITH_HEALTH=${OPTARG}
+            ;;
+    esac
+done
+
+
+time=0
+step=1
+while [ $time -le "$WAIT_TIME" ]; do
+    if [ "$(docker ps | grep " ${STACK_NAME}_" | grep -i healthy | wc -l)" -ge "$NUM_SERVICES_WITH_HEALTH" ]; then
+        exit 0
+    fi
+
+    sleep $step
+    time=$((time+step))
+done
+exit 1