Skip to content

Instantly share code, notes, and snippets.

@veysby
Last active April 20, 2020 10:08
Show Gist options
  • Save veysby/cf89534dc023f668c499 to your computer and use it in GitHub Desktop.
Save veysby/cf89534dc023f668c499 to your computer and use it in GitHub Desktop.
Activemq: check health status using REST API
$curl http://localhost:8161/api/jolokia/read/org.apache.activemq:type=Broker,brokerName=localhost,service=Health
{"timestamp":1449776947,"status":200,"request":{"mbean":"org.apache.activemq:brokerName=localhost,service=Health,type=Broker","type":"read"},"value":{"CurrentStatus":"Good"}}
Copy link

ghost commented Sep 25, 2018

sed /can/ do the same thing, but sed doesn't understand json. You'll have to do some regex-fu in order to get a similar result. jq is like sed but with the added luxury of understanding json, so regardless of extra lines or other possible strange formatting, jq, in this case, will output the whole value of the 'value' member of the json being fed in (or nothing/error if the json is invalid or doesn't contain a member named 'value')

@petr-ujezdsky
Copy link

petr-ujezdsky commented Oct 2, 2019

I do not have jq installed in my docker image so I use much simpler version:

curl --silent --show-error "http://localhost:8161/api/jolokia/exec/org.apache.activemq:type=Broker,brokerName=localhost,service=Health/healthStatus" | tee /dev/tty | grep --silent 'Good'

The exit status give OK/KO condition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment