diff --git a/utils/rabbitmq-update-pid.sh b/utils/rabbitmq-update-pid.sh index 382515428..d5360b2fe 100755 --- a/utils/rabbitmq-update-pid.sh +++ b/utils/rabbitmq-update-pid.sh @@ -1,16 +1,16 @@ #!/bin/bash -#Hack to parse rabbitmq pid and place it into the correct directory. This is also -#done in our rabbitmq init.d script, but placing it here so that monit recognizes -# it faster (in time for the upcoming airtime-check-system) -codename=`lsb_release -cs` -if [ "$codename" = "lucid" -o "$codename" = "maverick" -o "$codename" = "natty" -o "$codename" = "squeeze" ] -then - rabbitmqpid=`sed "s/.*,\(.*\)\}.*/\1/" /var/lib/rabbitmq/pids` -else - #RabbitMQ in Ubuntu Oneiric and newer have a different way of storing the PID. +/etc/init.d/rabbitmq-server status | grep "\[{pid" +pid_found="$?" + +if [ "$pid_found" == "0" ]; then + #PID is available in the status message rabbitmqstatus=`/etc/init.d/rabbitmq-server status | grep "\[{pid"` rabbitmqpid=`echo $rabbitmqstatus | sed "s/.*,\(.*\)\}.*/\1/"` +else + #PID should be available from file + rabbitmqpid=`sed "s/.*,\(.*\)\}.*/\1/" /var/lib/rabbitmq/pids` fi + echo "RabbitMQ PID: $rabbitmqpid" echo "$rabbitmqpid" > /var/run/rabbitmq.pid