bin/metrics-es-node.rb in sensu-plugins-elasticsearch-0.4.3 vs bin/metrics-es-node.rb in sensu-plugins-elasticsearch-0.5.3

- old
+ new

@@ -64,10 +64,15 @@ option :password, description: 'Elasticsearch Password', short: '-P PASS', long: '--password PASS' + option :https, + description: 'Enables HTTPS', + short: '-e', + long: '--https' + def acquire_es_version info = get_es_resource('/') info['version']['number'] end @@ -75,10 +80,17 @@ headers = {} if config[:user] && config[:password] auth = 'Basic ' + Base64.encode64("#{config[:user]}:#{config[:password]}").chomp headers = { 'Authorization' => auth } end - r = RestClient::Resource.new("http://#{config[:host]}:#{config[:port]}#{resource}", timeout: config[:timeout], headers: headers) + + protocol = if config[:https] + 'https' + else + 'http' + end + + r = RestClient::Resource.new("#{protocol}://#{config[:host]}:#{config[:port]}#{resource}", timeout: config[:timeout], headers: headers) JSON.parse(r.get) rescue Errno::ECONNREFUSED warning 'Connection refused' rescue RestClient::RequestTimeout warning 'Connection timed out'