我一直试图安装Sensu一段时间,我一直关注installation guide,安装过程中一切顺利,但是当我添加示例检查时从文档中,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"}
答案 0 :(得分: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。