bin/check-jenkins-health.rb in sensu-plugins-jenkins-0.0.2 vs bin/check-jenkins-health.rb in sensu-plugins-jenkins-0.0.3

- old
+ new

@@ -39,17 +39,31 @@ description: 'Jenkins Host', short: '-s SERVER', long: '--server SERVER', default: 'localhost' + option :port, + description: 'Jenkins Port', + short: 'p PORT', + long: '--port PORT', + default: '8080' + option :uri, description: 'Jenkins Metrics Healthcheck URI', short: '-u URI', long: '--uri URI', default: '/metrics/currentUser/healthcheck' + option :https, + short: '-h', + long: '--https', + boolean: true, + description: 'Enabling https connections', + default: false + def run - r = RestClient::Resource.new("http://#{config[:server]}:8080#{config[:uri]}", timeout: 5).get + https ||= config[:https] ? 'https' : 'http' + r = RestClient::Resource.new("#{https}://#{config[:server]}:#{config[:port]}#{config[:uri]}", timeout: 5).get if r.code == 200 healthchecks = JSON.parse(r) healthchecks.each do |_, healthcheck_hash_value| if healthcheck_hash_value['healthy'] != true critical 'Jenkins Health Parameters not OK'