Typo
[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 : ${user_agent="nagios service-proxy v0.9"}
11
12 tempfile=$(mktemp)
13 exit=0
14
15 url="$mkws_host?command=auth&action=login&username=$mkws_username&password=$mkws_password"
16 if curl -sSf -A "$user_agent" "$url" > $tempfile; then
17     if ! egrep -q '<status>OK</status>' $tempfile; then
18         echo "status not OK"
19         exit=1
20     fi
21     if ! egrep -q '<response jsessionId="[0-9A-F]+"' $tempfile; then
22         echo "response jsessionId missing"
23         exit=1
24     fi
25 else
26     echo "URL: $url failed"
27     exit=1
28 fi
29
30 if [ $exit -gt 0 ]; then
31     cat $tempfile
32 fi
33
34 rm -f $tempfile
35 exit $exit
36