Switch branches/tags
Nothing to show
Find file Copy path
executable file 94 lines (75 sloc) 2.58 KB
# Date: 04/18/2017
# Script Purpose: Perform a real health check of the metrics service.
# Version : 1.0
if [ "$#" -lt 1 ]; then
echo "
Description: This script will actually pull Hawkular stats for an
OpenShift system pod. If the call does not return stats, then we
safely assume the service is down.
Usage: [Public URL] [OCP Token]
Example: https://hawkular-metrics-openshift-infra.ose34.moos.local asdfsdfasdf8asdifa90sd890fas8df0
If token is not provided, the script will execute oc whoami -t to get token.
Requires: cURL, and oc tools if token is not specified.
exit 1
#if user supplied token then use it, else get it from CLI
if [ "$#" -eq 2 ]; then
token=`oc whoami -t`
#This is the pod for which metrics will be quried.
#If metrics exist, this pod will exist.
readonly POD_LABEL="hawkular-cassandra"
#Metrics OCP Namespace, this is constant
readonly POD_NAMESPACE="openshift-infra"
#Two connection parameters, these may need to be tweaked
#Depending on what defines a dead service.
readonly MAX_TIME="30"
readonly CONNECT_TIMEOUT="1"
#cURL parms and headers
#parms passed to cURL
curl_parms="-sk --max-time ${MAX_TIME} --connect-timeout ${CONNECT_TIMEOUT}"
#URL to cURL
#Required, Hawkular-Tenant header.
tenant_header="Hawkular-Tenant: ${POD_NAMESPACE}"
#Required, auth token.
token_header="Authorization: Bearer ${token}"
#Not required, just included
accept_header="Accept: application/json"
#Not required, but included for logging.
#Required to get cURL to return just the HTTP status code, i.e. 200
output="-o /dev/null"
#Uncomment to debug
#echo "cURL url: " ${url}
#echo "tenant: ${tenant_header}"
#echo "token: ${token_header}"
#echo "accept: ${accept_header}"
#echo "agent: ${agent_header}"
#Perform the cURL, and store the results.
#Anything non 200 specifies an error.
http_resp_code=`curl ${curl_parms} "${url}" \
-H "${token_header}" \
-H "${tenant_header}" \
-H "${accept_header}" \
-H "${agent_header}" \
${output} -w "${http_reg}" `
#Echo the response
echo "Server Responded with HTTP Code: $http_resp_code"
#Perform check and return 0 or -1
if [ "$http_resp_code" = "200" ]; then
echo "Ok"
exit 0
echo "Error"
exit 1