首页 技术 正文
技术 2022年11月10日
0 收藏 819 点赞 4,210 浏览 1365 个字

使用rabbitmqctl 管理 mq

-n 指定节点
[root@logging-master zabbix]# rabbitmqctl -n rabbit@localhost list_queues
Timeout: 60.0 seconds ...
Listing queues for vhost / ...
name messages
q_game_bilog 6822
q_withdraw_record 0
q_commission_hourly_text 0
q_user_login 0
q_pcenter_payment 0
q_commission_hourly 0# 监控脚本
[root@logging-master zabbix]# cat monitor_rabbitmq.sh
#!/bin/bash
sudo -u root rabbitmqctl -n rabbit@localhost list_queues|grep q_game_bilog|awk '{print $2}'执行结果:
[root@logging-master zabbix]# sh monitor_rabbitmq.sh
6763

加入zabbix监控项

[root@logging-master zabbix_agentd.d]# cat userparameter_rabbitmq.conf
UserParameter=q_game_bilog,sh /opt/zabbix/monitor_rabbitmq.sh

zabbix-server 测试

[root@game-tishen ~]# zabbix_get -s 192.168.224.2 -p 10050 -k 'q_game_bilog'
erlexec: HOME must be setOnly root or rabbitmq can run rabbitmqctl

# 有坑,说是只能是rabbitmq 用户和 root 用户才能执行rabbitmqctl

解决:

# 使用sudo 指定 root 用户执行命令
sudo -u root rabbitmqctl -n rabbit@localhost list_queues|grep q_game_bilog|awk '{print $2}'# 再次测试,返回结果是没有sudo权限
[root@game-tishen ~]# zabbix_get -s 192.168.224.2 -p 10050 -k 'q_game_bilog'We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things: #1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.sudo: no tty present and no askpass program specified# 在zabbix-agent端,添加zabbix sudo权限
visudo
zabbix ALL=(ALL) NOPASSWD: ALL# 再次测试,结果正常。
[root@game-tishen ~]# zabbix_get -s 192.168.224.2 -p 10050 -k 'q_game_bilog'
8566
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,999
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,511
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,357
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,140
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,770
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,848