在我的 Sensu 服务器(非企业版)上,我首先通过sudo sensu-install -p slack
.
我的 sensu 服务器上的配置文件如下。
/etc/sensu/conf.d/handler_config_slack.json
:
{
"handlers": {
"slack": {
"type": "pipe",
"command": "/usr/local/bin/handler-slack.rb",
"severites": ["critical", "unknown"]
}
},
"slack": {
"webhook_url": "https://hooks.slack.com/services/...",
"username": "sensu",
"channel": "#ops",
"timeout": 10
}
}
/etc/sensu/conf.d/client.json
:
{
"client": {
"name": "sensu-server-client-test",
"address": "x.x.x.x",
"subscriptions": [
"test"
],
"keepalive": {
"thresholds": {
"warning": 30,
"critical": 40
},
"handlers": ["slack"],
"refresh": 300
}
}
}
以及 sensu 远程客户端服务器文件/etc/sensu/conf.d/client.json
:
{
"client": {
"name": "sensu-client-test",
"address": "x.x.x.x",
"subscriptions": [
"test"
],
"keepalive": {
"thresholds": {
"warning": 30,
"critical": 40
},
"handlers": ["slack"],
"refresh": 300
}
}
}
/var/log/sensu/sensu-srver.log
:
{"timestamp":"2016-02-21T15:04:59.771989+0000","level":"info","message":"handler output","handler":{"type":"pipe","command":"handler-slack.rb","severites":["critical","unknown"],"name":"slack"},"output":["only handling every 180 occurrences: sensu-server-client-test/disk\n"]}
我让远程 sensu 客户端运行并连接,然后我故意停止远程客户端服务器从检查中生成warning
和critical
事件。keepalive
我想向我的松弛频道发送一条消息,但没有发送任何内容。
我究竟做错了什么?