bin/metrics-jenkins.rb in sensu-plugins-jenkins-1.5.0 vs bin/metrics-jenkins.rb in sensu-plugins-jenkins-1.6.0
- old
+ new
@@ -69,10 +69,17 @@
long: '--https',
boolean: true,
description: 'Enabling https connections',
default: false
+ option :insecure,
+ short: '-k',
+ long: '--insecure',
+ boolean: true,
+ description: 'Perform "insecure" SSL connections and transfers.',
+ default: false
+
option :timeout,
short: '-t SECONDS',
long: '--timeout SECONDS',
description: 'Timeout for REST request',
proc: proc(&:to_i),
@@ -94,10 +101,19 @@
def run
@start = DateTime.now
@stop = nil
begin
https ||= config[:https] ? 'https' : 'http'
- r = RestClient::Resource.new("#{https}://#{config[:server]}:#{config[:port]}#{config[:uri]}", timeout: config[:timeout]).get
+ testurl = "#{https}://#{config[:server]}:#{config[:port]}#{config[:uri]}"
+
+ r = if config[:https] && config[:insecure]
+ RestClient::Resource.new(testurl, timeout: config[:timeout], verify_ssl: false).get
+ elsif config[:https]
+ RestClient::Resource.new(testurl, timeout: config[:timeout], verify_ssl: true).get
+ else
+ RestClient::Resource.new(testurl, timeout: config[:timeout]).get
+ end
+
@stop = DateTime.now
all_metrics = JSON.parse(r)
metric_groups = all_metrics.keys - SKIP_ROOT_KEYS
metric_groups.each do |metric_groups_key|
all_metrics[metric_groups_key].each do |metric_key, metric_value|