bin/check-es-heap.rb in sensu-plugins-elasticsearch-0.4.3 vs bin/check-es-heap.rb in sensu-plugins-elasticsearch-0.5.3
- old
+ new
@@ -83,10 +83,15 @@
option :password,
description: 'Elasticsearch Password',
short: '-W PASS',
long: '--password PASS'
+ option :https,
+ description: 'Enables HTTPS',
+ short: '-e',
+ long: '--https'
+
def acquire_es_version
info = acquire_es_resource('/')
info['version']['number']
end
@@ -94,10 +99,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'