healthcheck/memcached: add brackets if ipv6

If memcached is deployed to listen on a IPv6 address, the healthcheck
command needs to be run with the right argument and the host needs
brackets.

Change-Id: I9244514d8686f72b0c47aef333a005ff61ddfdf6
This commit is contained in:
Emilien Macchi 2018-07-09 12:01:22 -05:00
parent c77b4e1972
commit 712e197b38

View File

@ -1,5 +1,11 @@
#!/bin/bash
listen_addr=$(awk 'match($0, /-l +([0-9a-fA-F\.\:]+) /, a) {print a[1]}' /etc/sysconfig/memcached)
# Add brackets if IPv6
if [[ $listen_addr =~ ":" ]]; then
listen_addr="[${listen_addr}]"
fi
echo "stats" | socat - TCP:$listen_addr:11211
exit