bin/check-jenkins-health.rb in sensu-plugins-jenkins-1.4.0 vs bin/check-jenkins-health.rb in sensu-plugins-jenkins-1.5.0
- old
+ new
@@ -59,19 +59,35 @@
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 SECS',
long: '--timeout SECS',
description: 'Request timeout in seconds',
proc: proc(&:to_i),
default: 5
def run
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
+
if [200, 500].include? r.code
healthchecks = JSON.parse(r)
healthchecks.each do |healthcheck, healthcheck_hash_value|
if healthcheck_hash_value['healthy'] != true
critical "Jenkins health check '#{healthcheck}' reported unhealthy state. Message: #{healthcheck_hash_value['message']}"