nagios test if the the service proxy is up and running, MKWS-81
[mkws-moved-to-github.git] / tools / bin / nagios-service-proxy.sh
1 #!/bin/sh
2 # Copyright (c) 2014 Index Data ApS, http://indexdata.com
3 #
4 # nagios test if the the service proxy is up and running
5
6 set -e
7 : ${mkws_host="http://mkws.indexdata.com/service-proxy/"}
8 : ${mkws_username="mkws"}
9 : ${mkws_password="mkws"}
10
11 tempfile=$(mktemp)
12 exit=0
13
14 url="$mkws_host?command=auth&action=login&username=$mkws_username&password=$mkws_password"
15 if curl -sSf "$url" > $tempfile; then
16     if ! egrep -q '<status>OK</status>' $tempfile; then
17         echo "status not OK"
18         exit=1
19     fi
20     if ! egrep -q '<response jsessionId="[0-9A-F]+"' $tempfile; then
21         echo "response jsessionId missing"
22         exit=1
23     fi
24 else
25     echo "URL: $url failed"
26     exit=1
27 fi
28
29 if [ $exit -gt 0 ]; then
30     cat $tempfile
31 fi
32
33 rm -f $tempfile
34 exit $exit
35