需求:
监控rabbitmq总消息数量,设置阈值,自动发送邮件提醒
效果:
添加主机后,可用性为“未知”时解决方案:
查看端口netstat -naltp,没有10051,只有10050,说明server没有启动,但是systemctl并没有报错 , 查看日志: cat /var/log/zabbix/zabbix_server.log
根据日志修改后重启systemctl restart zabbix-server zabbix-agent
参考链接:https://blog.csdn.net/qq317781007/article/details/126543480
检测到问题,邮件已发送:
参考连接:
linux,centSO搭建zabbix:https://blog.csdn.net/zhang_Darling/article/details/131745748
https://blog.csdn.net/weixin_44200830/article/details/126486770
linux,centSO卸载zabbix:https://blog.csdn.net/wangwei021933/article/details/127479838
linux,centSO安装rabbitmq:https://www.cnblogs.com/eddyz/p/17339961.html
linux,centSO安装python3.11:https://blog.csdn.net/biaobro/article/details/128752001
linux,cetSO监控redis:https://blog.csdn.net/zwmoooooo/article/details/123524353
zabbix自定义监控项,键值:https://blog.csdn.net/CSDNYXJY/article/details/115836183
告警发送邮件:需要再zabbix用户下填写相应的邮箱地址。
脚本内容,监控rabbitmq指定交换机下的队列数量:
#!/bin/bash
# 定义RabbitMQ的API endpoint
RABBITMQ_ENDPOINT="http://localhost:15672/api"
# 定义exchange的名字
EXCHANGE_NAME="jhjnm"
# 发送HTTP GET请求获取所有的队列信息 -i
选项会显示响应头信息,-s
选项会禁止显示进度条或错误信息,-u
选项会提供用户名和密码用于身份验证
QUEUE_INFO=$(curl -s -u rabbitll:123456 ${RABBITMQ_ENDPOINT}/exchanges/%2f/jhjnm/bindings/source)
object_count=$(echo $QUEUE_INFO | jq '. | length')
echo $object_count