-
Notifications
You must be signed in to change notification settings - Fork 11
/
checkServerStatus.sh
executable file
·84 lines (71 loc) · 2.12 KB
/
checkServerStatus.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/bash
if [ /$1/ == /--nocolor/ ]; then
RED=''
GRN=''
NOCOL=''
shift
else
RED='\x1b[22;31m'
GRN='\x1b[22;32m'
NOCOL='\x1b[0m'
fi
if [ /$1/ == // ]; then
echo 'To check status, you need to specify local, dev, stg, or prd.'
echo './checkStatus prd, for example'
exit
else
if [ $1 == 'local' ]; then
API_URL='http://localhost:8009'
UPLOAD_URL='http://localhost:9122'
BLIP_URL='http://localhost:3000'
fi
if [ $1 == 'dev' ]; then
API_URL='https://dev-api.tidepool.org'
UPLOAD_URL='https://dev-uploads.tidepool.org'
BLIP_URL='https://dev-blip.tidepool.org'
fi
if [ $1 == 'stg' ]; then
API_URL='https://stg-api.tidepool.org'
UPLOAD_URL='https://stg-uploads.tidepool.org'
BLIP_URL='https://stg-blip.tidepool.org'
fi
if [ $1 == 'prd' ]; then
API_URL='https://api.tidepool.org'
UPLOAD_URL='https://uploads.tidepool.org'
BLIP_URL='https://blip.tidepool.org'
fi
fi
checkStatus() {
server=$1
url=$2
response=$(curl --write-out %{http_code} --insecure --silent --output /dev/null $url)
now=$(date "+%H:%M:%S")
if [ $response == "200" ]; then
COL=$GRN
state='-good-'
else
COL=$RED
state='*FAIL*'
fi
echo -e $now $COL$state$NOCOL response $COL $response $NOCOL -- $server
}
checkStatusThroughStyx() {
server=$1
styxpath=$2
url=$API_URL/$styxpath/status
checkStatus $server $url
}
# we can't check status of hakken because we have no route to it directly through styx
# we can't check status of styx directly, but if these things work then
# styx is functional
# for now, all we check is that these server endpoints return 200.
# we should probably do more.
checkStatusThroughStyx shoreline auth
checkStatusThroughStyx highwater metrics
checkStatusThroughStyx seagull metadata
checkStatusThroughStyx gatekeeper access
checkStatusThroughStyx hydrophone confirm
checkStatusThroughStyx message_api message
checkStatusThroughStyx tide-whisperer data
checkStatus jellyfish $UPLOAD_URL/status
checkStatus blip $BLIP_URL/index.html