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