Sensu 仅处理每 180 次发生的情况

Sensu 仅处理每 180 次发生的情况

我安装了最新的 sensu-core,并使用 omnibus 包安装了 sensu-plugin gem。

Sensu 正常运行,但我遇到了处理程序方面的重大问题。我已设置了社区插件中的标准 ruby​​ mailer.rb 以及 pagerduty 处理程序。

当我将处理程序添加到我知道在日志中失败的检查时,我看到了以下内容:

{\"id\":\"a1e807d2-425f-4891-b291-ed5bda5b6105\",\"client\":{\"name\":\"mfp\",\"address\":\"25.147.26.157\",\"subscriptions\":[\"test\"],\"version\":\"0.20.0\",\"timestamp\":1437673191},\"check\":{\"command\":\"/etc/sensu/plugins/check-disk.sh -d /dev/md1 -w 80 -c 90\",\"interval\":10,\"handlers\":[\"default\",\"pagerduty\",\"mailer\"],\"occurrences\":3,\"subscribers\":[\"test\"],\"name\":\"disk\",\"issued\":1437673279,\"executed\":1437673201,\"duration\":0.01,\"output\":\"CRITICAL - /dev/md1 space used=94% | '/dev/md1 usage'=94%;80;90;\\n\",\"status\":2,\"history\":[\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\"],\"total_state_change\":0},\"occurrences\":513,\"action\":\"create\"}"]}
{"timestamp":"2015-07-23T12:41:20.873279-0500","level":"info","message":"handler output","handler":{"type":"pipe","command":"/etc/sensu/handlers/pagerduty.rb","api_key":"2e24c101ef754ff6add39aaaffa846c9","name":"pagerduty"},"output":["only handling every 180 occurrences: ws/disk\n"]}
{"timestamp":"2015-07-23T12:41:20.873561-0500","level":"info","message":"handler output","handler":{"type":"pipe","command":"/etc/sensu/handlers/pagerduty.rb","api_key":"2e24c101ef754ff6add39aaaffa846c9","name":"pagerduty"},"output":["only handling every 180 occurrences: wwv/disk\n"]}
{"timestamp":"2015-07-23T12:41:21.055407-0500","level":"info","message":"handler output","handler":{"type":"pipe","command":"/etc/sensu/handlers/pagerduty.rb","api_key":"2e24c101ef754ff6add39aaaffa846c9","name":"pagerduty"},"output":["only handling every 180 occurrences: mfp/disk\n"]}

因此看起来处理程序正在触发,但被 sensu-handler.rb gem 过滤,并且不会创建电子邮件或 pagerduty 事件。

以下是令人反感的台词

only handling every 180 occurrences

有人知道问题是什么吗?这是个 bug 吗?我需要覆盖某些东西吗?我在 sensu 中发现了很多针对此特定检查 (check_disk) 的事件,因此它应该触发 pagerduty 和邮件程序。

答案1

我在尝试集成 Slack 处理程序时遇到了同样的问题。您必须添加刷新处理程序配置文件中的参数。例如:

{
  "checks": {
    "memory": {
      "command": "/etc/sensu/plugins/check-memory.sh -w 700 -c 64",
      "interval": 10,
      "subscribers": [
        "test"
      ],
      "handlers": [
        "slack",
        "default"
      ],
      "occurrences": 5,
      "refresh": 60
    }
  }
}

本教程中找到的解决方案:http://www.whiteboardcoder.com/2014/11/getting-sensu-to-talk-to-hipchat.html

答案2

这是 sensu-plugin 中的一个错误,不一定是错误,而是缺少文档。问题在于,在 config.json 中,您需要为 API 块指定主机声明,sensu-plugin 需要这个,否则您会遇到这些过滤问题。

  "api": {
    "host": "localhost",
    "port": 4567
  }

相关内容