2

在我的 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 客户端运行并连接,然后我故意停止远程客户端服务器从检查中生成warningcritical事件。keepalive我想向我的松弛频道发送一条消息,但没有发送任何内容。

我究竟做错了什么?

4

1 回答 1

1

简单的错误,更改了以下内容:

"command": "/usr/local/bin/handler-slack.rb",

到以下:

"command": "handler-slack.rb",
于 2016-02-21T21:37:57.337 回答