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

这篇文章与使用YUM的安装Sensu相结合,用于安装,configuration和启动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? 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 

简洁

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,"::"}}, 

由于configuration了SSL,因此应该在/etc/rabbitmq.configconfiguration端口5671。 一旦messagebroker服务器重新启动,ssl端口5671开始监听,问题就解决了:

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

我的rabbitmqconfiguration是:

 [ {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}]} ]} ]. 

当我在rabbitmq.json中设置正确的SSLconfiguration时,我首先得到了RabbitMQ,它在Sensu网站上显示了一个例子。 之后它只说:“错误”:“没有连接到redis”

然后,我通过从sensuconfiguration中的“localhost”更改为“127.0.0.1”来使Redis工作。 由于Redis没有在IPv6上进行监听,并且“localhost”同时解决了:: 1&127.0.0.1,所以无法正常工作。

这是Debian 8的全新安装。

确认sensu-api已configuration并正在运行。 在centos-7.x systemctl status sensu-api
启动服务系统, systemctl start sensu-api