Testing library separation: now not in launcher but isolated
[anna.git] / example / diameter / launcher / deployments / st-client / checkStatus.sh
diff --git a/example/diameter/launcher/deployments/st-client/checkStatus.sh b/example/diameter/launcher/deployments/st-client/checkStatus.sh
new file mode 100755 (executable)
index 0000000..7e7f861
--- /dev/null
@@ -0,0 +1,29 @@
+#!/bin/bash
+# Result code: 1 (miss instances (and connections)), 2 (miss connections)
+ADML_CONNECTIONS=`cat .st_conf_adml_connections 2>/dev/null`
+ADML_INSTANCES=`cat .st_conf_adml_instances 2>/dev/null`
+RESULT_CODE=0
+
+ADML_INSTANCES_ALIVE=$(pgrep ADML- | wc -l)
+echo -n "$ADML_INSTANCES_ALIVE instances alive"
+if [ $ADML_INSTANCES_ALIVE -ne $ADML_INSTANCES ]
+then
+  echo " ! (expected $ADML_INSTANCES configured)"
+  RESULT_CODE=1
+else
+  echo
+fi
+
+ADML_CONNECTIONS_ALIVE=$(netstat -a | grep :diameter | grep ESTABLISHED | wc -l)
+ADML_TOTAL_CONNECTIONS=$((ADML_CONNECTIONS*ADML_INSTANCES))
+echo -n "$ADML_CONNECTIONS_ALIVE connections established"
+if [ $ADML_CONNECTIONS_ALIVE -ne $ADML_TOTAL_CONNECTIONS ]
+then
+  echo " ! (expected $ADML_TOTAL_CONNECTIONS configured)"
+  [ $RESULT_CODE -ne 1 ] && RESULT_CODE=2
+else
+  echo
+fi
+
+exit $RESULT_CODE
+