bin/metrics-es-node.rb in sensu-plugins-elasticsearch-1.9.0 vs bin/metrics-es-node.rb in sensu-plugins-elasticsearch-1.10.0
- old
+ new
@@ -69,10 +69,14 @@
option :https,
description: 'Enables HTTPS',
short: '-e',
long: '--https'
+ option :cert_file,
+ description: 'Cert file to use',
+ long: '--cert CERT_FILE'
+
def acquire_es_version
info = get_es_resource('/')
info['version']['number']
end
@@ -87,10 +91,19 @@
'https'
else
'http'
end
- r = RestClient::Resource.new("#{protocol}://#{config[:host]}:#{config[:port]}#{resource}", timeout: config[:timeout], headers: headers)
+ r = if config[:cert_file]
+ RestClient::Resource.new("#{protocol}://#{config[:host]}:#{config[:port]}#{resource}",
+ ssl_ca_file: config[:cert_file].to_s,
+ timeout: config[:timeout],
+ headers: headers)
+ else
+ RestClient::Resource.new("#{protocol}://#{config[:host]}:#{config[:port]}#{resource}",
+ timeout: config[:timeout],
+ headers: headers)
+ end
JSON.parse(r.get)
rescue Errno::ECONNREFUSED
warning 'Connection refused'
rescue RestClient::RequestTimeout
warning 'Connection timed out'