bin/check-sensu-client.rb in sensu-plugins-aws-3.1.0 vs bin/check-sensu-client.rb in sensu-plugins-aws-3.2.0

- old
+ new

@@ -31,11 +31,11 @@ # require 'sensu-plugins-aws' require 'sensu-plugin/check/cli' require 'aws-sdk' -require 'net/http' +require 'rest-client' require 'json' class CheckSensuClient < Sensu::Plugin::Check::CLI include Filter include Common @@ -49,10 +49,16 @@ short: '-h SENSU_HOST', long: '--host SENSU_HOST', description: 'Sensu host to query', default: 'sensu' + option :insecure, + short: '-k', + boolean: true, + description: 'Enabling insecure connections', + default: false + option :sensu_port, short: '-p SENSU_PORT', long: '--port SENSU_PORT', description: 'Sensu API port', proc: proc(&:to_i), @@ -95,11 +101,11 @@ h1, h2 = y.split(':') { h1 => h2 } end.reduce(:merge) filter_list.delete(nil) filter_list.each { |x, y| filter_list[x] = y.strip.gsub(/[\[\]]/, '') } - client = Aws::EC2::Client.new aws_config + client = Aws::EC2::Client.new parsed_filter = Filter.parse(config[:filter]) filter = if parsed_filter.empty? {} @@ -160,11 +166,14 @@ end ok end def client_check - uri = URI("http://#{config[:sensu_host]}:#{config[:sensu_port]}/clients") - response = JSON.parse(Net::HTTP.get(uri)) + verify_mode = OpenSSL::SSL::VERIFY_PEER + verify_mode = OpenSSL::SSL::VERIFY_NONE if config[:insecure] + request = RestClient::Resource.new("#{config[:sensu_host]}:#{config[:sensu_port]}/clients", + verify_ssl: verify_mode) + response = JSON.parse(request.get) clients = Set.new response.each do |client| clients << client['name'] end