sensu-plugins / sensu-plugin

A framework for writing Sensu plugins & handlers with Ruby.
http://sensuapp.org
MIT License
126 stars 117 forks source link

Require json in utils.rb. #141

Closed zroger closed 8 years ago

zroger commented 8 years ago

Without it, load_config simply returns an empty hash for everything, which in turn makes it so that settings is always empty.

You can see this behavior in a minimal check plugin that attempts to include utils without also requiring json.

require 'sensu-plugin/check/cli'
require 'sensu-plugin/utils'

class JsonCheck < Sensu::Plugin::Check::CLI
  include Sensu::Plugin::Utils

  def run
    if settings['api'].nil?
      critical 'Settings not loaded.'
    else
      ok settings['api']
    end
  end
end
cwjohnston commented 8 years ago

@zroger makes sense to me, thanks!