# File lib/sensu-plugin/utils.rb, line 5 def config_files if ENV['SENSU_CONFIG_FILES'] ENV['SENSU_CONFIG_FILES'].split(':') else ['/etc/sensu/config.json'] + Dir['/etc/sensu/conf.d/**/*.json'] end end
# File lib/sensu-plugin/utils.rb, line 13 def load_config(filename) JSON.parse(File.open(filename, 'r').read) rescue Hash.new end
# File lib/sensu-plugin/utils.rb, line 33 def net_http_req_class(method) case method.to_s.upcase when 'GET' Net::HTTP::Get when 'POST' Net::HTTP::Post when 'DELETE' Net::HTTP::Delete when 'PUT' Net::HTTP::Put end end
# File lib/sensu-plugin/utils.rb, line 21 def read_event(file) begin @event = ::JSON.parse(file.read) @event['occurrences'] ||= 1 @event['check'] ||= Hash.new @event['client'] ||= Hash.new rescue => e puts 'error reading event: ' + e.message exit 0 end end
# File lib/sensu-plugin/utils.rb, line 17 def settings @settings ||= config_files.map {|f| load_config(f) }.reduce {|a, b| a.deep_merge(b) } end