Simple task like setting up monitoring with monit for rabbit mq include two parts:

  1. As discussed here Modify /etc/init.d/rabbitmq-server
The following are added to the start
function:
    pid=`/usr/sbin/rabbitmqctl status | perl -n -e'/{pid,(\d+)/ && print $1'`
    echo $pid > /var/run/rabbitmq.pid
    Right before:
    echo SUCCESS The pid file is deleted within the stop function:
              rm /var/run/rabbitmq.pid right after,
              if [ $RETVAL = 0 ] ; then
  1. Add this to monit configuration file:
### rabbitmq-server
    check process rabbitmq-server with pidfile /var/run/rabbitmq.pid
    group rabbitmq
    start program "/etc/init.d/rabbitmq-server start"
    stop program "/etc/init.d/rabbitmq-server stop"
    if failed port 5672 type tcp then restart
    if 3 restarts within 3 cycles then timeout

Comments

comments powered by Disqus