bin/check-es-heap.rb in sensu-plugins-elasticsearch-2.0.1 vs bin/check-es-heap.rb in sensu-plugins-elasticsearch-2.1.0

- old
+ new

@@ -88,10 +88,14 @@ option :https, description: 'Enables HTTPS', short: '-e', long: '--https' + option :cert_file, + description: 'Cert file to use', + long: '--cert-file CERT' + option :all, description: 'Check all nodes in the ES cluster', short: '-a', long: '--all', default: false @@ -112,10 +116,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'