Hi folks,<br><br>I'm trying to find a good way to monitor rabbit for inclusion in an HA cluster (pacemaker/corosync).<br><br>Does anyone have a good resource agent already created for such a purpose?<br><br>Here is what I've got so far:<br>
<br><br>#!/bin/bash <br>#######################################################################<br>
# Initialization: <br>. /usr/lib/ocf/resource.d/heartbeat/.ocf-shellfuncs<br>#######################################################################<br><br>meta_data() {<br>
cat <<END<br><?xml version="1.0"?><br><!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd"><br><resource-agent name="rabbitmq" version="0.9"> <br><version>1.0</version> <br>
<br><longdesc lang="en"><br>Rabbitmq agent <br></longdesc> <br><shortdesc lang="en">Rabbitmq resource agent</shortdesc><br><actions><br><action name="start" timeout="90" /><br>
<action name="stop" timeout="100" /><br><action name="monitor" timeout="20" interval="10" depth="0" start-delay="0" /><br><action name="meta-data" timeout="5" /> <br>
<action name="validate-all" timeout="30" /> <br></actions> <br></resource-agent> <br>
END <br>} <br><br>usage() {<br> cat <<END<br>usage: $0 {start|stop|monitor|validate-all|meta-data}<br>
<br>END<br>} <br><br>start() {<br> /usr/sbin/rabbitmq-multi start_all 1 2>&1 > /dev/null<br> exit $? <br>} <br>
<br>stop() {<br> /usr/sbin/rabbitmq-multi stop_all 2>&1 > /dev/null<br> ret=$? <br><br> if [ $ret -eq 2 ]; then<br> return $OCF_SUCCESS <br> fi <br>
<br> if [ $ret -ne 0 ]; then<br> sleep 5 <br> pidof beam.smp <br> ret=$? <br> if [ $ret -eq 1 ]; then<br> /usr/bin/killall -TERM epmd beam.smp<br> sleep 30<br> /usr/bin/killall -KILL epmd beam.smp<br>
fi<br> fi<br> return $OCF_SUCCESS<br>}<br><br>monitor() {<br> status=`/usr/sbin/rabbitmq-multi status 2>&1`<br> res=$?<br> if [ $res -eq 2 ]; then<br> return $OCF_NOT_RUNNING<br> fi<br><br> if [[ $status =~ 'not_running' ]]; then<br>
return $OCF_NOT_RUNNING<br> else<br> if [ $res -eq 0 ]; then<br> return $OCF_SUCCESS<br> else<br> return $OCF_ERR_GENERIC<br> fi<br> fi<br>}<br><br>validate() {<br> return $OCF_SUCCESS<br>}<br>
<br>case $__OCF_ACTION in<br>meta-data) meta_data<br> exit $OCF_SUCCESS<br> ;;<br>start) start;;<br>stop) stop;;<br>monitor) monitor;;<br>validate-all) validate;;<br>
usage|help) usage<br> exit $OCF_SUCCESS<br> ;;<br>*) usage<br> exit $OCF_ERR_UNIMPLEMENTED<br> ;;<br>esac<br>rc=$?<br>ocf_log debug "${OCF_RESOURCE_INSTANCE} $__OCF_ACTION : $rc"<br>
exit $rc<br><br><br>---------<br><br>It feels like a bit of a kludge though. If anyone has any suggestions on how to thoroughly monitor rabbit, please let me know.<br><br><br>Regards,<br><br>-- <br>Mark Steele<br>Director of development<br>
Bering Media Inc.<br><br><br>