Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Commit

Permalink
Fix formatting options
Browse files Browse the repository at this point in the history
	Fix tabs<->spaces and other bashate complains
	Change mode to +x to scripts missing it
	Force shell to be /bin/bash for compatibility

Change-Id: Ied5979f2d886c15b273956a9828d9e0484368bab
Signed-off-by: Pablo Iranzo Gómez <Pablo.Iranzo@gmail.com>
  • Loading branch information
iranzo committed Sep 11, 2018
1 parent fc1f301 commit 37a5c78
Show file tree
Hide file tree
Showing 73 changed files with 290 additions and 289 deletions.
10 changes: 5 additions & 5 deletions healthcheck/README.md
@@ -1,7 +1,7 @@
# Health check commands

The scripts in this directory are meant to implement the
[container-healthcheck][] blueprint. They are written to be compatible
[container-healthcheck][] blueprint. They are written to be compatible
with the Docker [HEALTHCHECK][] api.

[container-healthcheck]: https://blueprints.launchpad.net/tripleo/+spec/container-healthchecks
Expand All @@ -12,7 +12,7 @@ The scripts expect to source
want to run scripts without installing to that file, you can set the
`HEALTHCHECKS_DIR` environment variable, e.g:

$ export HEALTHCHECKS_DIR=$PWD
$ ./heat-api
{"versions": [{"status": "CURRENT", "id": "v1.0", "links": [{"href": "http://192.168.24.1:8004/v1/", "rel": "self"}]}]}
300 192.168.24.1:8004 0.002 seconds
$ export HEALTHCHECKS_DIR=$PWD
$ ./heat-api
{"versions": [{"status": "CURRENT", "id": "v1.0", "links": [{"href": "http://192.168.24.1:8004/v1/", "rel": "self"}]}]}
300 192.168.24.1:8004 0.002 seconds
2 changes: 1 addition & 1 deletion healthcheck/aodh-api
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

. ${HEALTHCHECK_SCRIPTS:-/usr/share/openstack-tripleo-common/healthcheck}/common.sh

Expand Down
8 changes: 4 additions & 4 deletions healthcheck/aodh-evaluator
Expand Up @@ -6,9 +6,9 @@ process='aodh-evaluator'
args="${@:-6379}"

if healthcheck_port $process $args; then
exit 0
exit 0
else
ports=${args// /,}
echo "There is no $process process with opened Redis ports ($ports) running in the container"
exit 1
ports=${args// /,}
echo "There is no $process process with opened Redis ports ($ports) running in the container"
exit 1
fi
8 changes: 4 additions & 4 deletions healthcheck/aodh-listener
Expand Up @@ -6,9 +6,9 @@ process='aodh-listener'
args="${@:-5671 5672}"

if healthcheck_port $process $args; then
exit 0
exit 0
else
ports=${args// /,}
echo "There is no $process process with opened RabbitMQ ports ($ports) running in the container"
exit 1
ports=${args// /,}
echo "There is no $process process with opened RabbitMQ ports ($ports) running in the container"
exit 1
fi
8 changes: 4 additions & 4 deletions healthcheck/aodh-notifier
Expand Up @@ -6,9 +6,9 @@ process='aodh-notifier'
args="${@:-5671 5672}"

if healthcheck_port $process $args; then
exit 0
exit 0
else
ports=${args// /,}
echo "There is no $process process with opened RabbitMQ ports ($ports) running in the container"
exit 1
ports=${args// /,}
echo "There is no $process process with opened RabbitMQ ports ($ports) running in the container"
exit 1
fi
2 changes: 1 addition & 1 deletion healthcheck/barbican-api
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

. ${HEALTHCHECK_SCRIPTS:-/usr/share/openstack-tripleo-common/healthcheck}/common.sh

Expand Down
8 changes: 4 additions & 4 deletions healthcheck/barbican-keystone-listener
Expand Up @@ -6,9 +6,9 @@ process='barbican-keystone-listener'
args="${@:-5671 5672}"

if healthcheck_port $process $args; then
exit 0
exit 0
else
ports=${args// /,}
echo "There is no $process process with opened RabbitMQ ports ($ports) running in the container"
exit 1
ports=${args// /,}
echo "There is no $process process with opened RabbitMQ ports ($ports) running in the container"
exit 1
fi
8 changes: 4 additions & 4 deletions healthcheck/barbican-worker
Expand Up @@ -6,9 +6,9 @@ process='barbican-worker'
args="${@:-5671 5672}"

if healthcheck_port $process $args; then
exit 0
exit 0
else
ports=${args// /,}
echo "There is no $process process with opened RabbitMQ ports ($ports) running in the container"
exit 1
ports=${args// /,}
echo "There is no $process process with opened RabbitMQ ports ($ports) running in the container"
exit 1
fi
8 changes: 4 additions & 4 deletions healthcheck/ceilometer-agent-central
Expand Up @@ -6,9 +6,9 @@ process='ceilometer-polling'
args="${@:-6379}"

if healthcheck_port $process $args; then
exit 0
exit 0
else
ports=${args// /,}
echo "There is no $process process with opened Redis ports ($ports) running in the container"
exit 1
ports=${args// /,}
echo "There is no $process process with opened Redis ports ($ports) running in the container"
exit 1
fi
8 changes: 4 additions & 4 deletions healthcheck/ceilometer-agent-compute
Expand Up @@ -6,9 +6,9 @@ process='ceilometer-polling'
args="${@:-5671 5672}"

if healthcheck_port $process $args; then
exit 0
exit 0
else
ports=${args// /,}
echo "There is no $process process with opened RabbitMQ ports ($ports) running in the container"
exit 1
ports=${args// /,}
echo "There is no $process process with opened RabbitMQ ports ($ports) running in the container"
exit 1
fi
8 changes: 4 additions & 4 deletions healthcheck/ceilometer-agent-ipmi
Expand Up @@ -6,9 +6,9 @@ process='ceilometer-polling'
args="${@:-6379}"

if healthcheck_port $process $args; then
exit 0
exit 0
else
ports=${args// /,}
echo "There is no $process process with opened Redis ports ($ports) running in the container"
exit 1
ports=${args// /,}
echo "There is no $process process with opened Redis ports ($ports) running in the container"
exit 1
fi
8 changes: 4 additions & 4 deletions healthcheck/ceilometer-agent-notification
Expand Up @@ -6,9 +6,9 @@ process='ceilometer-agent-notification'
args="${@:-5671 5672}"

if healthcheck_port $process $args; then
exit 0
exit 0
else
ports=${args// /,}
echo "There is no $process process with opened RabbitMQ ports ($ports) running in the container"
exit 1
ports=${args// /,}
echo "There is no $process process with opened RabbitMQ ports ($ports) running in the container"
exit 1
fi
2 changes: 1 addition & 1 deletion healthcheck/cinder-api
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

. ${HEALTHCHECK_SCRIPTS:-/usr/share/openstack-tripleo-common/healthcheck}/common.sh

Expand Down
8 changes: 4 additions & 4 deletions healthcheck/cinder-backup
Expand Up @@ -6,9 +6,9 @@ process='cinder-backup'
args="${@:-5671 5672}"

if healthcheck_port $process $args; then
exit 0
exit 0
else
ports=${args// /,}
echo "There is no $process process with opened RabbitMQ ports ($ports) running in the container"
exit 1
ports=${args// /,}
echo "There is no $process process with opened RabbitMQ ports ($ports) running in the container"
exit 1
fi
8 changes: 4 additions & 4 deletions healthcheck/cinder-scheduler
Expand Up @@ -6,9 +6,9 @@ process='cinder-scheduler'
args="${@:-5671 5672}"

if healthcheck_port $process $args; then
exit 0
exit 0
else
ports=${args// /,}
echo "There is no $process process with opened RabbitMQ ports ($ports) running in the container"
exit 1
ports=${args// /,}
echo "There is no $process process with opened RabbitMQ ports ($ports) running in the container"
exit 1
fi
8 changes: 4 additions & 4 deletions healthcheck/cinder-volume
Expand Up @@ -6,9 +6,9 @@ process='cinder-volume'
args="${@:-5671 5672}"

if healthcheck_port $process $args; then
exit 0
exit 0
else
ports=${args// /,}
echo "There is no $process process with opened RabbitMQ ports ($ports) running in the container"
exit 1
ports=${args// /,}
echo "There is no $process process with opened RabbitMQ ports ($ports) running in the container"
exit 1
fi
97 changes: 49 additions & 48 deletions healthcheck/common.sh 100644 → 100755
@@ -1,55 +1,56 @@
#!/bin/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 -g -k -q --fail \
--max-time "${HEALTHCHECK_CURL_MAX_TIME}" \
--user-agent "${HEALTHCHECK_CURL_USER_AGENT}" \
--write-out "${HEALTHCHECK_CURL_WRITE_OUT}" \
"$@" || return 1
curl -g -k -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
process=$1

# ss truncate command name to 15 characters and this behaviour
# cannot be disabled
if [ ${#process} -gt 15 ] ; then
process=${process:0:15}
fi
# ss truncate command name to 15 characters and this behaviour
# cannot be disabled
if [ ${#process} -gt 15 ] ; then
process=${process:0:15}
fi

shift 1
args=$@
ports=${args// /|}
ss -ntp | awk '{print $5,"-",$6}' | egrep ":($ports)" | grep "$process"
shift 1
args=$@
ports=${args// /|}
ss -ntp | awk '{print $5,"-",$6}' | egrep ":($ports)" | grep "$process"
}

healthcheck_listen () {
process=$1
process=$1

# ss truncate command name to 15 characters and this behaviour
# cannot be disabled
if [ ${#process} -gt 15 ] ; then
process=${process:0:15}
fi
# ss truncate command name to 15 characters and this behaviour
# cannot be disabled
if [ ${#process} -gt 15 ] ; then
process=${process:0:15}
fi

shift 1
args=$@
ports=${args// /|}
ss -lnp | awk '{print $5,"-",$7}' | egrep ":($ports)" | grep "$process"
shift 1
args=$@
ports=${args// /|}
ss -lnp | awk '{print $5,"-",$7}' | egrep ":($ports)" | grep "$process"
}

healthcheck_socket () {
process=$1
socket=$2
process=$1
socket=$2

# lsof truncate command name to 15 characters and this behaviour
# cannot be disabled
if [ ${#process} -gt 15 ] ; then
process=${process:0:15}
fi
lsof -Fc -Ua $socket | grep "c$process"
# lsof truncate command name to 15 characters and this behaviour
# cannot be disabled
if [ ${#process} -gt 15 ] ; then
process=${process:0:15}
fi
lsof -Fc -Ua $socket | grep "c$process"
}

healthcheck_file_modification () {
Expand All @@ -60,27 +61,27 @@ healthcheck_file_modification () {
last_mod=$(stat -c '%Y' $file_path)
limit_epoch=$(( curr_time-limit_seconds ))
if [ "$limit_epoch" -gt "$last_mod" ]; then
return 1
return 1
fi
}

get_config_val () {
crudini --get "$1" "$2" "$3" 2> /dev/null || echo "$4"
crudini --get "$1" "$2" "$3" 2> /dev/null || echo "$4"
}

# apachectl -S is slightly harder to parse and doesn't say if the vhost is serving SSL
get_url_from_vhost () {
vhost_file=$1
server_name=$(awk '/ServerName/ {print $2}' $vhost_file)
ssl_enabled=$(awk '/SSLEngine/ {print $2}' $vhost_file)
bind_port=$(grep -h "<VirtualHost .*>" $vhost_file | sed 's/<VirtualHost .*:\(.*\)>/\1/')
wsgi_alias=$(awk '/WSGIScriptAlias/ {print $2}' $vhost_file)
proto=http
if [[ $ssl_enabled == "on" ]]; then
proto=https
fi
if [[ $wsgi_alias != "/" ]]; then
wsgi_alias="${wsgi_alias}/"
fi
echo ${proto}://${server_name}:${bind_port}${wsgi_alias}
vhost_file=$1
server_name=$(awk '/ServerName/ {print $2}' $vhost_file)
ssl_enabled=$(awk '/SSLEngine/ {print $2}' $vhost_file)
bind_port=$(grep -h "<VirtualHost .*>" $vhost_file | sed 's/<VirtualHost .*:\(.*\)>/\1/')
wsgi_alias=$(awk '/WSGIScriptAlias/ {print $2}' $vhost_file)
proto=http
if [[ $ssl_enabled == "on" ]]; then
proto=https
fi
if [[ $wsgi_alias != "/" ]]; then
wsgi_alias="${wsgi_alias}/"
fi
echo ${proto}://${server_name}:${bind_port}${wsgi_alias}
}
2 changes: 1 addition & 1 deletion healthcheck/fluentd
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

. ${HEALTHCHECK_SCRIPTS:-/usr/share/openstack-tripleo-common/healthcheck}/common.sh

Expand Down
4 changes: 2 additions & 2 deletions healthcheck/glance-api
@@ -1,12 +1,12 @@
#!/bin/sh
#!/bin/bash

. ${HEALTHCHECK_SCRIPTS:-/usr/share/openstack-tripleo-common/healthcheck}/common.sh

bind_host=$(get_config_val /etc/glance/glance-api.conf DEFAULT bind_host 127.0.0.1)
bind_port=$(get_config_val /etc/glance/glance-api.conf DEFAULT bind_port 9292)
# Add brackets if IPv6
if [[ $bind_host =~ ":" ]]; then
bind_host="[${bind_host}]"
bind_host="[${bind_host}]"
fi
# glance-api is still eventlet
healthcheck_curl http://${bind_host}:${bind_port}/
2 changes: 1 addition & 1 deletion healthcheck/gnocchi-api
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

. ${HEALTHCHECK_SCRIPTS:-/usr/share/openstack-tripleo-common/healthcheck}/common.sh

Expand Down
8 changes: 4 additions & 4 deletions healthcheck/gnocchi-metricd
Expand Up @@ -6,9 +6,9 @@ process='gnocchi-metricd'
args="${@:-6379}"

if healthcheck_port $process $args; then
exit 0
exit 0
else
ports=${args// /,}
echo "There is no $process process with opened Redis ports ($ports) running in the container"
exit 1
ports=${args// /,}
echo "There is no $process process with opened Redis ports ($ports) running in the container"
exit 1
fi
4 changes: 2 additions & 2 deletions healthcheck/gnocchi-statsd
Expand Up @@ -6,6 +6,6 @@ process='gnocchi-statsd'
bind_port=$(get_config_val /etc/gnocchi/gnocchi.conf statsd port 8125)

if ! healthcheck_listen $process $bind_port; then
echo "There is no $process process listening on ports $bind_port in the container."
exit 1
echo "There is no $process process listening on ports $bind_port in the container."
exit 1
fi
2 changes: 1 addition & 1 deletion healthcheck/heat-api
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

. ${HEALTHCHECK_SCRIPTS:-/usr/share/openstack-tripleo-common/healthcheck}/common.sh

Expand Down

0 comments on commit 37a5c78

Please sign in to comment.