简体   繁体   中英

Sensu Handler Gives Undefined Method Error

We've recently updated our OpsGenie handler ( opsgenie.rb ) to the current community version, found here .

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": {
  "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:

{"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.

Any ideas what would be causing the undefined method 'option' for Opsgenie:Class (NoMethodError) error?

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".

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).

Updating this gem with

gem update sensu-plugin

solved this issue!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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