Skip to content

Instantly share code, notes, and snippets.

@nirbhabbarat
Created February 4, 2018 03:16
Show Gist options
  • Save nirbhabbarat/bfcb20057f3df565a442121f5cdf4452 to your computer and use it in GitHub Desktop.
Save nirbhabbarat/bfcb20057f3df565a442121f5cdf4452 to your computer and use it in GitHub Desktop.
Check rabbitmq is running or not, else restart and send customer message to slack, email, sms or phone call API
#!/bin/bash
# port 15672 belongs to rabbitmq management portal, if not enabled use below command.
# rabbitmq-plugins enable rabbitmq_management
# guest:guest replace it with username:password of rabbitmq readonly user
status=$(curl -s -o /dev/null -w "%{http_code}" localhost:15672/api/overview --user guest:guest)
if [ $status = "200" ]; then
echo "rabbitMQ running"
else
echo "restarting RabbitMQ"
sudo /etc/init.d/rabbitmq-server start
# send slack notification, replace with custom commands to SMS, Email.
curl -X POST --data-urlencode "payload={\"channel\": \"#CHANNEL\", \"username\": \"RabbitMQ\", \"text\": \"RabbitMQ restarted on HOSTNAME.\", \"icon_emoji\": \":ghost:\"}" WEBHOOKURL
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment