7bbdb3bb59a507ddc4c9100bd1109f7866f07b66
[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 cd $(dirname $0)
8 #[ -z "$ADML_CONNECTIONS" -o -z "$ADML_INSTANCES" ] && { echo "Miss configuration. Run ./configure.sh" ; exit 3 ; }
9
10 echo -n "Checking instances ... "
11 ADML_INSTANCES_ALIVE=$(pgrep ADML- | wc -l)
12 echo -n "$ADML_INSTANCES_ALIVE instances alive"
13 if [ $ADML_INSTANCES_ALIVE -lt $ADML_INSTANCES ]
14 then
15   echo " ! (expected $ADML_INSTANCES configured)"
16   RESULT_CODE=1
17 else
18   echo
19 fi
20
21 cmd="netstat -a | grep :diameter | grep ESTABLISHED | wc -l"
22 echo -n "Checking connections ... "
23 ADML_CONNECTIONS_ALIVE=$(eval $cmd)
24 ADML_TOTAL_CONNECTIONS=$((ADML_CONNECTIONS*ADML_INSTANCES))
25 echo -n "$ADML_CONNECTIONS_ALIVE connections established (using '$cmd')"
26 if [ $ADML_CONNECTIONS_ALIVE -ne $ADML_TOTAL_CONNECTIONS ]
27 then
28   echo " ! (expected $ADML_TOTAL_CONNECTIONS configured)"
29   [ $RESULT_CODE -ne 1 ] && RESULT_CODE=2
30 else
31   echo
32 fi
33
34 exit $RESULT_CODE
35