如果超时或者集群状态有问题都会报警
#! /bin/bash
testrabbit() {
cc=`ssh -p 10022 [email protected] "/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" [email protected] 2>/dev/null
fi
}
#登陆超时
timeout 10 ssh -p 10022 [email protected] "/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" [email protected] 2>/dev/null
fi