为什么 Uchiwa 无法监控 CentOS7 上的数据中心?

为什么 Uchiwa 无法监控 CentOS7 上的数据中心?

这个帖子结合使用 YUM 安装 Sensu用于安装、配置和启动 Sensu 及相关服务:

sudo yum install -y erlang && \
sudo rpm -Uvh http://www.rabbitmq.com/releases/rabbitmq-server/v3.5.0/rabbitmq-server-3.5.0-1.noarch.rpm && \
sudo yum install -y redis && \
echo '[sensu]
name=sensu
baseurl=http://sensu.global.ssl.fastly.net/yum/$basearch/
gpgcheck=0
enabled=1' | sudo tee /etc/yum.repos.d/sensu.repo && \
sudo yum install -y sensu && \
sudo yum install -y uchiwa && \
for s in rabbitmq-server redis.service sensu-server sensu-api uchiwa; do sudo systemctl restart $s; done && \
sudo rabbitmqctl add_vhost /sensu && \
sudo rabbitmqctl add_user sensu secret && \
sudo rabbitmqctl set_permissions -p /sensu sensu ".*" ".*" ".*"

分析

  • 导航到 :3000 显示 uchiwa 仪表板并指示Connection error. Is the Sensu API running?
  • /var/log/sensu/sensu-api.log表示

{"timestamp":"2016-07-03T22:58:58.532905+0000","level":"warn","message":"config file does not exist or is not readable","file":"/etc/sensu/config.json"}
{"timestamp":"2016-07-03T22:58:58.533069+0000","level":"warn","message":"ignoring config file","file":"/etc/sensu/config.json"}
{"timestamp":"2016-07-03T22:58:58.533137+0000","level":"warn","message":"loading config files from directory","directory":"/etc/sensu/conf.d"}
{"timestamp":"2016-07-03T22:58:58.712175+0000","level":"info","message":"api listening","protocol":"http","bind":"0.0.0.0","port":4567}

  • config.json 似乎不存在(/etc/sensu/config.json: No such file or directory
  • 下载示例 config.json重新启动 sensu-api 也无法解决问题

{
  "rabbitmq": {
    "host": "localhost",
    "vhost": "/sensu",
    "user": "sensu",
    "password": "secret"
  },
  "redis": {
    "host": "localhost",
    "port": 6379,
    "password": "secret"
  }
}

  • redis 端口正在监听:

LISTEN     0      128    127.0.0.1:6379                     *:*

  • rabbitmq 端口也是如此:

LISTEN     0      100          *:4567                     *:* 
  • Uchiwa 无法连接到数据中心

{
  "sensu": [
    {
      "name": "Site 1",
      "host": "localhost",
      "port": 4567,
      "timeout": 10
    },
    {
      "name": "Site 2",
      "host": "localhost",
      "port": 4567,
      "ssl": false,
      "path": "",
      "user": "",
      "pass": "",
      "timeout": 10
    }
  ],
  "uchiwa": {
    "host": "0.0.0.0",
    "port": 3000,
    "refresh": 10
  }
}

{"timestamp":"2016-07-03T23:34:32.990067621Z","level":"warn","message":"GET http://localhost:4567/stashes returned: 500 Internal Server Error"}
{"timestamp":"2016-07-03T23:34:32.990102095Z","level":"warn","message":"Connection failed to the datacenter Site 1"}
{"timestamp":"2016-07-03T23:34:32.990115588Z","level":"info","message":"Updating the datacenter Site 2"}
{"timestamp":"2016-07-03T23:34:32.991462585Z","level":"warn","message":"GET http://localhost:4567/stashes returned: 500 Internal Server Error"}
{"timestamp":"2016-07-03T23:34:32.991492978Z","level":"warn","message":"Connection failed to the datacenter Site 2"}

  • 导航至<IPADDRESS>:4567结果:

{"error":"redis and transport connections not initialized"}

  • redis 回复

sudo redis-cli ping
PONG

  • redis 密码已设置,但问题仍然存在

sudo redis-cli
127.0.0.1:6379> auth secret
OK

答案1

简洁的

似乎sensu-client需要正在运行rabbitmq-server。由于这个消息代理似乎没有运行,因此无法sensu-client启动,Uchiwa 仪表板也无法监视它。

详细

如果出现以下错误:

{"error":"redis and transport connections not initialized"}

显示并redis正在监听,请检查是否rabbitmq正在运行并使用 rabbitmq-status 检查 rabbitmq 端口:

sudo systemctl status rabbitmq-server

例子

今天出现了上述错误,检查 rabbitmq 端口时发现某个端口没有监听:

{listeners,[{clustering,25672,"::"},{amqp,5672,"::"}},

由于配置了 SSL,因此应在 中配置端口 5671。/etc/rabbitmq.config重新启动 messagebroker 服务器后,ssl 端口5671开始监听,问题得到解决:

{listeners,[{clustering,25672,"::"},{amqp,5672,"::"},{'amqp/ssl',5671,"::"}]},

我的 rabbitmq 配置是:

[
{rabbit, [ 
{ssl_listeners, [5671]},
{ssl_options, [{cacertfile,"/etc/rabbitmq/ssl/cacert.pem"},
               {certfile,"/etc/rabbitmq/ssl/cert.pem"},
               {keyfile,"/etc/rabbitmq/ssl/key.pem"},
               {verify,verify_peer},
               {fail_if_no_peer_cert,true}]}
 ]}
  ].

答案2

当我在 rabbitmq.json 中设置正确的 SSL 配置时,我第一次让 RabbitMQ 工作起来,它显示了一个示例Sensu 网站之后它只说:“错误”:“未连接到 redis”

然后,我将 sensu 配置中的“localhost”更改为“127.0.0.1”,让 Redis 正常工作。由于 Redis 未监听 IPv6,并且“localhost”解析了 ::1 和 127.0.0.1,因此无法正常工作。

这是 Debian 8 上的全新安装。

答案3

验证 sensu-api 是否已配置并正在运行。在 centos-7.x 上systemctl status sensu-api
启动服务 systemctl start sensu-api

相关内容