如果超时或者集群状态有问题都会报警
#! /bin/bash

testrabbit() {
cc=`ssh -p 10022 root@10.11.11.42 "/usr/sbin/rabbitmqctl cluster_status | grep running"`
dd=$cc
a_status=`echo $dd | awk -F "[" {'print $2'} | awk -F "]" {'print $1'}`
echo $a_status
if [ "$a_status" == "'rabbit@prod-MQ-1','rabbit@prod-MQ-2','rabbit@prod-MQ-3'" ];then
    echo "rabbitcluster is ok"
else
    echo  "rabbitmq cluster status changed" | mail -v -s "rabbitmq cluster status changed"  xxxx@xxxx.com 2>/dev/null
fi
}
#登陆超时
timeout 10 ssh -p 10022 root@10.11.11.42 "/usr/sbin/rabbitmqctl cluster_status | grep running"
ccre=`echo $?`
if [ $ccre == 0 ];then
    testrabbit
else
     echo  "ssh 10.11.11.42 timeout" | mail -v -s "ssh timeout"  xxxx@xxxx.com 2>/dev/null  
fi