0

我一直在尝试安装Sensu,我一直在遵循安装指南,安装时一切顺利,但是当我从文档中添加示例检查时,Sensu 突然无法连接到 RabbitMQ。具体来说,当我添加check_cron.json配置时。我尝试重新启动并删除配置(然后再次重新启动),但 Sensu 一直超时。值得注意的是,RabbitMQ 已安装并正在运行,甚至可以通过管理界面导航,但 Sensu 似乎没有意识到这一点。

以下是我的服务器日志:

{"timestamp":"2014-07-03T11:39:00.254061-0300","level":"warn","message":"config file applied changes","config_file":"/etc/sensu/conf.d/check_cron.json","changes":{"checks":{"cron_check":[null,{"handlers":["default"],"command":"/etc/sensu/plugins/check-proc.rb -p crond -C 1","interval":30,"subscribers":["webservers"]}]}}}
{"timestamp":"2014-07-03T11:39:00.254279-0300","level":"warn","message":"config file applied changes","config_file":"/etc/sensu/conf.d/client.json","changes":{"client":[null,{"name":"sensu-test","address":"127.0.0.1","subscriptions":["test","webservers"]}]}}
{"timestamp":"2014-07-03T11:39:00.262568-0300","level":"info","message":"loaded extension","type":"mutator","name":"only_check_output","description":"returns check output"}
{"timestamp":"2014-07-03T11:39:00.265246-0300","level":"info","message":"loaded extension","type":"handler","name":"debug","description":"outputs json event data"}
{"timestamp":"2014-07-03T11:39:00.313486-0300","level":"info","message":"i am the master"}
{"timestamp":"2014-07-03T11:39:03.326913-0300","level":"warn","message":"reconnecting to rabbitmq"}
{"timestamp":"2014-07-03T11:39:03.327281-0300","level":"warn","message":"unsubscribing from keepalive and result queues"}
{"timestamp":"2014-07-03T11:39:03.327463-0300","level":"warn","message":"resigning as master"}
{"timestamp":"2014-07-03T11:39:03.328908-0300","level":"info","message":"removed master lock"}
{"timestamp":"2014-07-03T11:39:11.343859-0300","level":"warn","message":"reconnecting to rabbitmq"}
{"timestamp":"2014-07-03T11:39:19.366786-0300","level":"warn","message":"reconnecting to rabbitmq"}
{"timestamp":"2014-07-03T11:39:20.294332-0300","level":"fatal","message":"rabbitmq connection error","error":"timed out while attempting to connect"}
{"timestamp":"2014-07-03T11:39:20.294816-0300","level":"warn","message":"stopping"}
{"timestamp":"2014-07-03T11:39:20.294959-0300","level":"warn","message":"unsubscribing from keepalive and result queues"}
{"timestamp":"2014-07-03T11:39:20.295122-0300","level":"info","message":"completing handlers in progress","handlers_in_progress_count":0}
{"timestamp":"2014-07-03T11:39:20.796222-0300","level":"warn","message":"stopping reactor"}
{"timestamp":"2014-07-03T11:50:59.786233-0300","level":"warn","message":"config file applied changes","config_file":"/etc/sensu/conf.d/client.json","changes":{"client":[null,{"name":"sensu-test","address":"127.0.0.1","subscriptions":["test","webservers"]}]}}
{"timestamp":"2014-07-03T11:50:59.808513-0300","level":"info","message":"loaded extension","type":"mutator","name":"only_check_output","description":"returns check output"}
{"timestamp":"2014-07-03T11:50:59.811049-0300","level":"info","message":"loaded extension","type":"handler","name":"debug","description":"outputs json event data"}
{"timestamp":"2014-07-03T11:50:59.858109-0300","level":"info","message":"i am the master"}
{"timestamp":"2014-07-03T11:51:02.867913-0300","level":"warn","message":"reconnecting to rabbitmq"}
{"timestamp":"2014-07-03T11:51:02.868369-0300","level":"warn","message":"unsubscribing from keepalive and result queues"}
{"timestamp":"2014-07-03T11:51:02.868466-0300","level":"warn","message":"resigning as master"}
{"timestamp":"2014-07-03T11:51:02.869157-0300","level":"info","message":"removed master lock"}
{"timestamp":"2014-07-03T11:51:10.889055-0300","level":"warn","message":"reconnecting to rabbitmq"}
{"timestamp":"2014-07-03T11:51:18.910561-0300","level":"warn","message":"reconnecting to rabbitmq"}
{"timestamp":"2014-07-03T11:51:19.842039-0300","level":"fatal","message":"rabbitmq connection error","error":"timed out while attempting to connect"}
{"timestamp":"2014-07-03T11:51:19.842408-0300","level":"warn","message":"stopping"}
{"timestamp":"2014-07-03T11:51:19.842551-0300","level":"warn","message":"unsubscribing from keepalive and result queues"}
{"timestamp":"2014-07-03T11:51:19.842714-0300","level":"info","message":"completing handlers in progress","handlers_in_progress_count":0}
{"timestamp":"2014-07-03T11:51:20.343916-0300","level":"warn","message":"stopping reactor"}
4

1 回答 1

1

如果您在 rabbitmq 服务器上使用 ssl 证书,那么您的证书可能有问题。github上有一个脚本克隆它并运行以下命令:

git clone git://github.com/joemiller/joemiller.me-intro-to-sensu.git
cd joemiller.me-intro-to-sensu/

./ssl_certs.sh clean
./ssl_certs.sh generate

然后配置 Rabbitmq 以使用这些证书:

mkdir /etc/rabbitmq/ssl
cp server_key.pem /etc/rabbitmq/ssl/
cp server_cert.pem /etc/rabbitmq/ssl/
cp testca/cacert.pem /etc/rabbitmq/ssl/

并将此配置添加到 /etc/rabbitmq/rabbitmq.config:

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

在这里你告诉rabbitmq它将使用哪些证书,确保证书的路径与你复制证书的路径相同。

update-rc.d sensu-server defaults
update-rc.d sensu-api defaults
update-rc.d sensu-client defaults
update-rc.d sensu-dashboard defaults

然后像之前使用的那样复制 SSL client_key 和证书:

cp client_key.pem client_cert.pem  /etc/sensu/ssl/

然后将不同的配置添加到 /etc/sensu/config.json。

于 2014-07-21T14:13:23.587 回答