print container logs when not healthy 85/6685/2
authortierno <alfonso.tiernosepulveda@telefonica.com>
Thu, 11 Oct 2018 13:03:06 +0000 (15:03 +0200)
committertierno <alfonso.tiernosepulveda@telefonica.com>
Thu, 11 Oct 2018 13:08:39 +0000 (15:08 +0200)
Change-Id: I826cab4eb2e79ee89ecf633361009fb2ad5d0d05
Signed-off-by: tierno <alfonso.tiernosepulveda@telefonica.com>
installers/osm_health.sh

index 2be8ce4..4625dc8 100755 (executable)
@@ -2,8 +2,9 @@
 
 WAIT_TIME=60
 NUM_SERVICES_WITH_HEALTH=3
+SERVICES_WITH_HEALTH="nbi ro kafka"
 
-while getopts "w:s:n:" o; do
+while getopts "w:s:n:c:" o; do
     case "${o}" in
         w)
             WAIT_TIME=${OPTARG}
@@ -14,6 +15,9 @@ while getopts "w:s:n:" o; do
         n)
             NUM_SERVICES_WITH_HEALTH=${OPTARG}
             ;;
+        c)
+            SERVICES_WITH_HEALTH="${OPTARG}"
+            ;;
     esac
 done
 
@@ -32,4 +36,14 @@ done
 echo "Not all Docker services are healthy"
 docker ps | grep " ${STACK_NAME}_"
 
+for S_WITH_HEALTH in $SERVICES_WITH_HEALTH ; do
+    docker ps | grep " ${STACK_NAME}_" | grep -i healthy | grep -q "_${S_WITH_HEALTH}."  && continue
+    echo
+    echo BEGIN LOGS of container ${S_WITH_HEALTH} not healthy
+    docker service logs ${STACK_NAME}_${S_WITH_HEALTH} 2>&1 | tail -n 100
+    echo END LOGS of container ${S_WITH_HEALTH} not healthy
+    echo
+done
+
 exit 1
+