安装客户端。
运行visudo,在root下增加zabbix的sudo权限:

## Allow root to run any commands anywhere
root    ALL=(ALL)       ALL
zabbix  ALL=(ALL)       NOPASSWD: /usr/sbin/rabbitmqctl

去掉tty限制:

#Defaults    requiretty

在配置文件追加监控项:

#RabbitMQ
#内存
UserParameter=memory.total,sudo rabbitmqctl status |grep -o 'total,[0-9]*' |cut -d ',' -f2 |tr -d \"
UserParameter=memory.connection_readers,sudo rabbitmqctl status |grep -o 'connection_readers,[0-9]*' |cut -d ',' -f2 |tr -d \"
UserParameter=memory.connection_channels,sudo rabbitmqctl status |grep -o 'connection_channels,[0-9]*' |cut -d ',' -f2 |tr -d \"
UserParameter=memory.connection_other,sudo rabbitmqctl status |grep -o 'connection_other,[0-9]*' |cut -d ',' -f2 |tr -d \"
UserParameter=memory.queue_procs,sudo rabbitmqctl status |grep -o 'queue_procs,[0-9]*' |cut -d ',' -f2 |tr -d \"
UserParameter=memory.queue_slave_procs,sudo rabbitmqctl status |grep -o 'queue_slave_procs,[0-9]*' |cut -d ',' -f2 |tr -d \"
UserParameter=memory.plugins,sudo rabbitmqctl status |grep -o 'plugins,[0-9]*' |cut -d ',' -f2 |tr -d \"
UserParameter=memory.other_proc,sudo rabbitmqctl status |grep -o 'other_proc,[0-9]*' |cut -d ',' -f2 |tr -d \"
UserParameter=memory.mnesia,sudo rabbitmqctl status |grep -o 'mnesia,[0-9]*' |sed -n 2p |cut -d ',' -f2 |tr -d \"
UserParameter=memory.mgmt_db,sudo rabbitmqctl status |grep -o 'mgmt_db,[0-9]*' |cut -d ',' -f2 |tr -d \"
UserParameter=memory.msg_index,sudo rabbitmqctl status |grep -o 'msg_index,[0-9]*' |cut -d ',' -f2 |tr -d \"
UserParameter=memory.other_ets,sudo rabbitmqctl status |grep -o 'other_ets,[0-9]*' |cut -d ',' -f2 |tr -d \"
UserParameter=memory.binary,sudo rabbitmqctl status |grep -o 'binary,[0-9]*' |cut -d ',' -f2 |tr -d \"
UserParameter=memory.code,sudo rabbitmqctl status |grep -o 'code,[0-9]*' |cut -d ',' -f2 |tr -d \"
UserParameter=memory.atom,sudo rabbitmqctl status |grep -o 'atom,[0-9]*' |cut -d ',' -f2 |tr -d \"
UserParameter=memory.other_system,sudo rabbitmqctl status |grep -o 'other_system,[0-9]*' |cut -d ',' -f2 |tr -d \"
UserParameter=vm_memory_high_watermark,sudo rabbitmqctl status |grep -o 'vm_memory_high_watermark,.*' |cut -d ',' -f2 |tr -d \"}
UserParameter=vm_memory_limit,sudo rabbitmqctl status |grep -o 'vm_memory_limit,[0-9]*' |cut -d ',' -f2 |tr -d \"

#磁盘与文件
UserParameter=disk_free_limit,sudo rabbitmqctl status |grep -o 'disk_free_limit,[0-9]*' |cut -d ',' -f2 |tr -d \"
UserParameter=disk_free,sudo rabbitmqctl status |grep -o 'disk_free,[0-9]*' |cut -d ',' -f2 |tr -d \"
UserParameter=file_descriptors.total_limit,sudo rabbitmqctl status |grep -o 'total_limit,[0-9]*' |cut -d ',' -f2 |tr -d \"
UserParameter=file_descriptors.total_used,sudo rabbitmqctl status |grep -o 'total_used,[0-9]*' |cut -d ',' -f2 |tr -d \"
UserParameter=file_descriptors.sockets_limit,sudo rabbitmqctl status |grep -o 'sockets_limit,[0-9]*' |cut -d ',' -f2 |tr -d \"
UserParameter=file_descriptors.sockets_used,sudo rabbitmqctl status |grep -o 'sockets_used,[0-9]*' |cut -d ',' -f2 |tr -d \"

#进程
UserParameter=processes.limit,sudo rabbitmqctl status |grep -o '{limit,[0-9]*' |cut -d ',' -f2 |tr -d \"
UserParameter=processes.used,sudo rabbitmqctl status |grep -o '{used,[0-9]*' |cut -d ',' -f2 |tr -d \"

#消息
UserParameter=run_queue,sudo rabbitmqctl status |grep -o 'run_queue,[0-9]*' |cut -d ',' -f2 |tr -d \"
UserParameter=uptime,sudo rabbitmqctl status |grep -o 'uptime,[0-9]*' |cut -d ',' -f2 |tr -d \"
UserParameter=kernel.net_ticktime,sudo rabbitmqctl status |grep -o 'net_ticktime,[0-9]*' |cut -d ',' -f2 |tr -d \"
UserParameter=userVisitRecordQueue,sudo rabbitmqctl list_queues -p / |grep 'userVisitRecordQueue' |awk '{print 2}' |tr -d \"
UserParameter=urlFilterQueue,sudo rabbitmqctl list_queues -p / |grep 'urlFilterQueue' |awk '{print2}' |tr -d \"
UserParameter=userMonitorProcessQueue,sudo rabbitmqctl list_queues -p / |grep 'userMonitorProcessQueue' |awk '{print 2}' |tr -d \"
UserParameter=operationRecordQueue,sudo rabbitmqctl list_queues -p / |grep 'operationRecordQueue' |awk '{print2}' |tr -d \"
UserParameter=qrtzMonitorQueue,sudo rabbitmqctl list_queues -p / |grep 'qrtzMonitorQueue' |awk '{print $2}' |tr -d \"
UserParameter=list_connections,sudo rabbitmqctl list_connections |grep 'running' |wc -l
UserParameter=list_channels,sudo rabbitmqctl list_channels |grep '<*>' |wc -l
UserParameter=list_consumers,sudo rabbitmqctl list_consumers |grep '<*>' |wc -l

#集群名称,节点名称,集群内节点数,集群内活动节点数
UserParameter=cluster.name,sudo rabbitmqctl cluster_status |grep 'cluster_name,*' |cut -d '"' -f2
UserParameter=cluster.node_name,sudo rabbitmqctl cluster_status |grep 'Cluster status of node' |awk '{print $5}'
UserParameter=cluster.nodes_count,sudo rabbitmqctl cluster_status |sed -n 2p |cut -d '[' -f4 |grep -o ',' |wc -l
UserParameter=cluster.nodes_running_count,sudo rabbitmqctl cluster_status |sed -n 3p |cut -d '[' -f2 |grep -o ',' |wc -l

配置模板:



    3.2
    2017-03-28T10:26:11Z
    
        
            RabbitMQ
        
    
    
        
    
    
        
            {RabbitMQ:run_queue.last()}<>0
            0
            
            {HOST.NAME}:Erlang进程队列开始阻塞
            0
            
            
            0
            2
            
            0
            0
            
            
        
        
            {RabbitMQ:run_queue.last()}<>0 and {RabbitMQ:run_queue.last(#2)}<>0
            0
            
            {HOST.NAME}:Erlang进程队列持续阻塞
            0
            
            
            0
            4
            
            0
            0
            
            
        
        
            {RabbitMQ:cluster.nodes_running_count.last()}<>2
            0
            
            {HOST.NAME}:RabbitMQ集群可用节点数量异常
            0
            
            
            0
            3
            
            0
            0
            
            
        
        
            {RabbitMQ:cluster.nodes_running_count.last()}=0
            0
            
            {HOST.NAME}:RabbitMQ集群无可用节点
            0
            
            
            0
            5
            
            0
            0
            
                
                    {HOST.NAME}:RabbitMQ集群可用节点数量异常
                    {RabbitMQ:cluster.nodes_running_count.last()}<>2
                    
                
            
            
        
    

此方法占用大量cpu资源,需要按需开启监控项,并适当增加采集周期。

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注

Captcha Code