Fixes
[anna.git] / example / diameter / launcher / deployments / st-client / checkStatus.sh
1 #!/bin/bash
2 # Result code: 1 (miss instances (and connections)), 2 (miss connections)
3 ADML_CONNECTIONS=`cat .st_conf_adml_connections 2>/dev/null`
4 ADML_INSTANCES=`cat .st_conf_adml_instances 2>/dev/null`
5 RESULT_CODE=0
6
7 echo -n "Checking instances ... "
8 ADML_INSTANCES_ALIVE=$(pgrep ADML- | wc -l)
9 echo -n "$ADML_INSTANCES_ALIVE instances alive"
10 if [ $ADML_INSTANCES_ALIVE -ne $ADML_INSTANCES ]
11 then
12   echo " ! (expected $ADML_INSTANCES configured)"
13   RESULT_CODE=1
14 else
15   echo
16 fi
17
18 echo -n "Checking connections ... "
19 ADML_CONNECTIONS_ALIVE=$(netstat -a | grep :diameter | grep ESTABLISHED | wc -l)
20 ADML_TOTAL_CONNECTIONS=$((ADML_CONNECTIONS*ADML_INSTANCES))
21 echo -n "$ADML_CONNECTIONS_ALIVE connections established"
22 if [ $ADML_CONNECTIONS_ALIVE -ne $ADML_TOTAL_CONNECTIONS ]
23 then
24   echo " ! (expected $ADML_TOTAL_CONNECTIONS configured)"
25   [ $RESULT_CODE -ne 1 ] && RESULT_CODE=2
26 else
27   echo
28 fi
29
30 exit $RESULT_CODE
31