I am attempting to write a a few plugins for AWS that will check various services we have set up and would like to push a set of credentials out with the Sensu checks that are used by all plugins. The easiest way to me seems like it would be to use settings method that is part of the Sensu::Plugin::Utils module similar to what the Sensu::Handler class does.
The code I’m testing with is:
class SQSMsgs < Sensu::Plugin::Check::CLI
:short => ‘-a PARAM’,
:long => ‘–abcd PARAM’,
:description => “Stuff”,
:default => settings[‘abcd’][‘something’]
puts “do something neat”
Running it results in:
$ ruby check-test.rb
Sensu::Plugin::CLI: Not implemented! You should override Sensu::Plugin::CLI#run.
check-test.rb:12: undefined method `’ for nil:NilClass (NoMethodError)
I am obviously overriding the run method, and removing the :default parameter in my test code works as expected. I can’t figure out why including the util module is either a) not including the utility module’s methods, or b) somehow breaking the Check::Cli class. Any thoughts?
Snipets of the code I was using to generate this:
class Graphite < Sensu::Handler
graphite_server = settings[‘graphite’][‘server’]
graphite_port = settings[‘graphite’][‘port’]