Skip to content

Instantly share code, notes, and snippets.

@ukn
Last active October 27, 2016 16:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ukn/d810cb8fa2c0c65aeefdbed5a4e8a326 to your computer and use it in GitHub Desktop.
Save ukn/d810cb8fa2c0c65aeefdbed5a4e8a326 to your computer and use it in GitHub Desktop.
bash function that gives nicely formated services status from consul
ss() {
if [[ -z ${2+x} ]]; then
ssh ${1} "curl -s localhost:8500/v1/catalog/services | \
jq -rc 'keys | .[]' | while read i; do curl -s localhost:8500/v1/health/service/\${i} | jq -r '.[] | .Checks[] | select(.CheckID != \"serfHealth\") | .ServiceName + \" \" + .CheckID + \" \" + .Status'; done | column -t -x"
else
ssh ${1} "curl -s localhost:8500/v1/health/service/${2} | jq -r '.[] | .Checks[] | select(.CheckID != \"serfHealth\") | .CheckID + \"\t\" + .Status + \"\t\t\" + .Output'"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment