This repository has been archived by the owner on Nov 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 159
/
Copy pathservice_check.sh
executable file
·85 lines (67 loc) · 2.05 KB
/
service_check.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
85
#!/bin/bash
# set -euo pipefail
IFS=$'\n\t'
usage() { echo "Usage: service_check.sh -d <dns host Url> -n <teamName> " 1>&2; exit 1; }
declare dnsUrl=""
declare teamName=""
# Initialize parameters specified from command line
while getopts ":d:n:" arg; do
case "${arg}" in
d)
dnsUrl=${OPTARG}
;;
n)
teamName=${OPTARG}
;;
esac
done
shift $((OPTIND-1))
#Prompt for parameters is some required parameters are missing
if [[ -z "$dnsUrl" ]]; then
echo "Public DNS address where the API will be hosted behind."
echo "Enter public DNS name."
read dnsUrl
[[ "${dnsUrl:?}" ]]
fi
if [[ -z "$teamName" ]]; then
echo "Enter a team name to be used in app provisioning:"
read teamName
fi
echo "Checking services for ([X] = PASSED):"
echo "Team Name:" $teamName
echo -e "DNS Url:" $dnsUrl"\n"
poi_URL=$dnsUrl"/api/healthcheck/poi"
user_URL=$dnsUrl"/api/healthcheck/user"
trips_URL=$dnsUrl"/api/healthcheck/trips"
user_java_URL=$dnsUrl"/api/healthcheck/user-java"
echo -e "Checking POI:\t"$poi_URL
echo -e "Checking USER:\t"$user_URL
echo -e "Checking TRIPS:\t"$trips_URL
echo -e "Checking USER JAVA:\t"$user_java_URL"\n"
status_code_poi=`curl -sL -w "%{http_code}\\n" "$poi_URL" -o /dev/null`
if [[ "$status_code_poi" == "200" ]]; then
echo "poi [X]"
else
echo "poi [ ]"
fi
status_code_user=`curl -sL -w "%{http_code}\\n" "$user_URL" -o /dev/null`
if [[ "$status_code_user" == "200" ]]; then
echo "user [X]"
else
echo "user [ ]"
fi
status_code_trips=`curl -sL -w "%{http_code}\\n" "$trips_URL" -o /dev/null`
if [[ "$status_code_trips" == "200" ]]; then
echo "trips [X]"
else
echo "trips [ ]"
fi
status_code_user_java=`curl -sL -w "%{http_code}\\n" "$user_java_URL" -o /dev/null`
if [[ "$status_code_user_java" == "200" ]]; then
echo "user-java [X]"
else
echo "user-java [ ]"
fi
if [[ "$status_code_poi" == "200" ]] && [[ "$status_code_user" == "200" ]] && [[ "$status_code_trips" == "200" ]] && [[ "$status_code_user_java" == "200" ]]; then
echo "All checks passed"
fi