Skip to content

Instantly share code, notes, and snippets.

@scottillogical
Created November 21, 2018 20:34
Show Gist options
  • Save scottillogical/7770886dd09cfbdefb0ac63b39501af0 to your computer and use it in GitHub Desktop.
Save scottillogical/7770886dd09cfbdefb0ac63b39501af0 to your computer and use it in GitHub Desktop.
detect rabbitmq missing bindings
#!/bin/bash
if [ -z "$RMQ_USERNAME" ]; then
echo "Error:RMQ_USERNAME was not set."
exit 1
fi
if [ -z "$RMQ_PASSWORD" ]; then
echo "Error:RMQ_PASSWORD was not set."
exit 1
fi
if [ -z "$RMQ_IP" ]; then
echo "Error:RMQ_IP was not set."
exit 1
fi
set -e
baseUrl="http://$RMQ_IP:15672/api"
for vhostqueue in $(curl --fail -q --header "Accept: application/json" -u $RMQ_USERNAME:$RMQ_PASSWORD "$baseUrl/queues" | jq -r '.[] | .vhost + "/" + .name' ); do
curl --fail --header "Accept: application/json" -s -u $RMQ_USERNAME:$RMQ_PASSWORD "$baseUrl/queues/${vhostqueue}/bindings" | jq '.' | jq --arg vhostqueue $vhostqueue 'select(length <= 0) | $vhostqueue,.'
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment