consul/get_services: tabulated list of services

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2023-09-26 11:19:07 +02:00
parent 869c472a9b
commit 8855498e1d
No known key found for this signature in database
GPG Key ID: FE65CD384D5BF7B4
1 changed files with 14 additions and 0 deletions

14
consul/get_services.sh Executable file
View File

@ -0,0 +1,14 @@
#!/usr/bin/env bash
CONSUL_URL="${CONSUL_URL:-http://localhost:8500/v1/catalog}"
SERVICE="${1}"
[[ -z "${SERVICE}" ]] && { echo "No service name given!" >&2; exit 1; }
readarray -t DCS < <(curl -s "${CONSUL_URL}/datacenters" | jq -r '.[]')
for DC in "${DCS[@]}"; do
curl -s "${CONSUL_URL}/service/${SERVICE}?dc=${DC}"
done \
| jq -r '.[] | [.Node, .ServiceName, .ServiceID, .ServiceMeta.version] | @tsv' \
| column -t