zoukankan      html  css  js  c++  java
  • 为Zabbix配置RabbitMQ监控模板

    RabbitMQ的配置参考 https://github.com/jasonmcintosh/rabbitmq-zabbix 

    简而言之,具体分为几个步骤:

    1. 将脚本文件(scripts文件夹)和配置文件(zabbix_agent.d/zabbix-rabbitmq.conf)拷贝至/etc/zabbix/ 文件夹,按需修改文件夹权限给zabbix用户(自测环境是使用root用户,所以不需要修改权限)

    2. 配置。不建议使用guest用户,而是新建用户,并赋予其“只读权限”,即仅有几项监控相关的API可以访问,以下仅是一个参考:

    rabbitmqctl add_user zabbix pass
    rabbitmqctl set_user_tags zabbix monitoring
    rabbitmqctl set_permissions -p / zabbix '^aliveness-test$' '^amq.default$' '^aliveness-test$’

    编辑/etc/zabbix/scripts/rabbitmq/.rab.auth文件,填写如下内容:

    USERNAME=guest
    PASSWORD=******
    CONF=/etc/zabbix/zabbix_agent.conf
    LOGLEVEL=DEBUG
    LOGFILE=/var/log/zabbix/rabbitmq_zabbix.log
    HOSTNAME=192.168.122.208
    PORT=15672

    3. 在Zabbix Dashboard上导入模板,配置给相关主机

    4. 重启zabbix-agent
    注意,因为我们是直接root用户,所以暂时可不需要创建zabbix用户,只需要确保.rab.auth文件中的配置是正确的即可。当然,最最最重要的是要确保rabbitmq-plugins中启用了rabbitmq-management: 
    [root@f-q ~(keystone_admin)]# rabbitmq-plugins enable rabbitmq_management
    The following plugins have been enabled:
      mochiweb
      webmachine
      rabbitmq_web_dispatch
      amqp_client
      rabbitmq_management_agent
      rabbitmq_management
    Applying plugin configuration to rabbit@f-q... started 6 plugins.
    检查rabbitmq-plugins插件列表可发现:
    这个问题的排查来自于最开始配置了模板之后,提示Dead RabbitMQ,但是RabbitMQ服务正常。于是简单的尝试http api,看下效果:
    [root@f-q ~(keystone_admin)]#  curl -i -u guest:***** http://192.168.122.208:15672/api/vhosts
    curl: (7) Failed connect to 192.168.122.208:15672; Connection refused
    [root@f-q ~(keystone_admin)]#  curl -i -u guest:***** http://192.168.122.208:5672/api/vhosts
    AMQP
    [root@f-q ~(keystone_admin)]# curl curl -i -u guest:***** http://192.168.122.208:25672/api/
    curl: (6) Could not resolve host: curl; Name or service not known
    curl: (52) Empty reply from server
    [root@f-q ~(keystone_admin)]#
    View Code
    其实这里由于对rabbitmq的了解不够,所以没有第一时间看到问题——即模板配置说明中明确默认使用的是15672的端口,而我们的15672的端口并不连通,说明这个端口背后的服务是没启动的,那么这个端口是干嘛的呢?通过Google,我们查到RabbitMQ的官方文档中的说明:
    4369: epmd, a peer discovery service used by RabbitMQ nodes and CLI tools
    5672, 5671: used by AMQP 0-9-1 and 1.0 clients without and with TLS
    25672: used for inter-node and CLI tools communication (Erlang distribution server port) and is allocated from a dynamic range (limited to a single port by default, computed as AMQP port + 20000). Unless external connections on these ports are really necessary (e.g. the cluster uses federation or CLI tools are used on machines outside the subnet), these ports should not be publicly exposed. See networking guide for details.
    35672-35682: used by CLI tools (Erlang distribution client ports) for communication with nodes and is allocated from a dynamic range (computed as server distribution port + 10000 through server distribution port + 10010). See networking guide for details.
    15672: HTTP API clients, management UI and rabbitmqadmin (only if the management pluginis enabled)
    61613, 61614: STOMP clients without and with TLS (only if the STOMP plugin is enabled)
    1883, 8883: (MQTT clients without and with TLS, if the MQTT plugin is enabled
    15674: STOMP-over-WebSockets clients (only if the Web STOMP plugin is enabled)
    15675: MQTT-over-WebSockets clients (only if the Web MQTT plugin is enabled)
    也就是说,我们必须要启用rabbitmq_management插件,才能保证15672,HTTP API客户端可用!
    那么完成脚本和参数配置,并导入模板后,试着创建主机(虽然是fake driver),看到zabbix dashboard上的变化:
    有数据变化就是好的……虽然只有message count和message rates,没有我们想要的连接数等信息……
  • 相关阅读:
    为什么使用enable_shared_from_this——shared_ptr两类错误
    More Effective C++ Item14:明智运用exception specifications
    用“双优先队列”方法解决双/多指标的规划问题
    彻底理解AC多模式匹配算法
    CentOS7安装MySQL
    CentOS7配置本地Yum源
    数组
    比较运算符
    申明变量
    相等运算符==与等同运算符===
  • 原文地址:https://www.cnblogs.com/gushiren/p/9593086.html
Copyright © 2011-2022 走看看