简体   繁体   English

Sensu 处理程序给出未定义的方法错误

[英]Sensu Handler Gives Undefined Method Error

We've recently updated our OpsGenie handler ( opsgenie.rb ) to the current community version, found here .我们最近将 OpsGenie 处理程序 ( opsgenie.rb ) 更新为当前社区版本,可在此处找到。

Our handler is defined as:我们的处理程序定义为:

"opsgenie-pager" : {
  "type": "pipe",
  "command": "/etc/sensu/handlers/opsgenie.rb -j opsgenie-pager"
}

And our json config for opsgenie-pager is:我们用于opsgenie-pager json 配置是:

{
  "opsgenie-pager": {
  "customerKey": "<Our API Key>",
  "recipients": "<Our Schedule>,<Our Escalation>",
  "source": "Admiral Ackbar",
  "overwrite_quiet_hours": false,
  "tags": [ "admAckbar", "live", "pager" ]
  }
}

When a check returns as 'CRITICAL' and the opsgenie handler is called, the sensu-server.log reports:当检查返回“CRITICAL”并调用opsgenie处理程序时,sensu-server.log 报告:

{"timestamp":"2015-02-03T06:16:17.804061-0700","level":"info","message":"handler output","handler":{"type":"pipe","command":"/etc/sensu/handlers/opsgenie.rb -j opsgenie-pager","name":"opsgenie-pager"},"output":"/etc/sensu/handlers/opsgenie.rb:15:in `<class:Opsgenie>': undefined method `option' for Opsgenie:Class (NoMethodError)\n"}
{"timestamp":"2015-02-03T06:16:17.804210-0700","level":"info","message":"handler output","handler":{"type":"pipe","command":"/etc/sensu/handlers/opsgenie.rb -j opsgenie-pager","name":"opsgenie-pager"},"output":"\tfrom /etc/sensu/handlers/opsgenie.rb:13:in `<main>'\n"}

In our "dev instance" (vagrant box), we're able to successfully use the OpsGenie handler to create alerts.在我们的“开发实例”(流浪箱)中,我们能够成功地使用 OpsGenie 处理程序来创建警报。

Any ideas what would be causing the undefined method 'option' for Opsgenie:Class (NoMethodError) error?任何想法会导致undefined method 'option' for Opsgenie:Class (NoMethodError)错误的undefined method 'option' for Opsgenie:Class (NoMethodError)

Looks like this was the result of an outdated gem.看起来这是一个过时的宝石的结果。

Out of chance I checked the installed packages (rpms and gems) between our "dev instance" and "production".出于偶然,我检查了“开发实例”和“生产”之间已安装的软件包(rpms 和 gems)。

The sensu-pluign gem in our dev instance (installed during a vagrant up ) was the current version (1.1.0) whereas the version installed on Production was an older version (0.6.3).我们开发实例中的sensu-pluign gem(在vagrant up期间安装)是当前版本(1.1.0),而在 Production 上安装的版本是旧版本(0.6.3)。

Updating this gem with更新这个宝石

gem update sensu-plugin

solved this issue!解决了这个问题!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM