Files
tripleo-common/healthcheck/common.sh
Martin Mágr b4327a4d3b Add health check for services connected to RabbitMQ
- extended common lib with check for processes opening a specific ports
- added health check scripts for services which require to be connected
  to RabbitMQ server

Implements: blueprint container-healthchecks
Change-Id: I039b4f2bc9826bece6c382ac07e8fb2495fae924
2017-07-25 14:10:21 +02:00

27 lines
688 B
Bash

: ${HEALTHCHECK_CURL_MAX_TIME:=10}
: ${HEALTHCHECK_CURL_USER_AGENT:=curl-healthcheck}
: ${HEALTHCHECK_CURL_WRITE_OUT:='\n%{http_code} %{remote_ip}:%{remote_port} %{time_total} seconds\n'}
healthcheck_curl () {
curl -q --fail \
--max-time "${HEALTHCHECK_CURL_MAX_TIME}" \
--user-agent "${HEALTHCHECK_CURL_USER_AGENT}" \
--write-out "${HEALTHCHECK_CURL_WRITE_OUT}" \
"$@" || return 1
}
healthcheck_port () {
process=$1
shift 1
port_args=()
for arg in "$@"; do
port_args+=("-i" "tcp:${arg}")
done
lsof +c0 -nP "${port_args[@]}" | awk '{print $1}' | grep -q "^${process}$"
}
get_config_val () {
crudini --get "$1" "$2" "$3" 2> /dev/null || echo "$4"
}