Skip to content

Instantly share code, notes, and snippets.

@mflopez79
Created January 16, 2017 15:36
Show Gist options
  • Save mflopez79/6ebde2344d8b4c1d2607d98bfbf84433 to your computer and use it in GitHub Desktop.
Save mflopez79/6ebde2344d8b4c1d2607d98bfbf84433 to your computer and use it in GitHub Desktop.
Check rabbitMQ node status and put status to Cloudwatch
#!/bin/bash
if [ "$#" -ne 2 ]; then
echo "Illegal number of parameters"
echo "Usage: $0 <metric-name> <server_name>"
exit 100
fi
date=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
status_code=$(curl -o /dev/null -s -w "%{http_code}" -u <RABBITMQ_ADMIN_USER>:<RABBITMQ_ADMIN_PWD> "http://localhost:15672/api/healthchecks/node")
if [ $status_code -ne 200 ]
then
val=0
else
val=1
fi
/usr/local/bin/aws cloudwatch put-metric-data --metric-name $1 --namespace $2 --value $val --timestamp $date
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment