bin/metrics-jenkins.rb in sensu-plugins-jenkins-0.0.2 vs bin/metrics-jenkins.rb in sensu-plugins-jenkins-0.0.3
- old
+ new
@@ -46,11 +46,11 @@
long: '--scheme SCHEME',
default: "#{Socket.gethostname}.jenkins"
option :server,
description: 'Jenkins Host',
- short: '-s SERVER',
+ short: '-S SERVER',
long: '--server SERVER',
default: 'localhost'
option :port,
description: 'Jenkins Port',
@@ -62,12 +62,20 @@
description: 'Jenkins Metrics URI',
short: '-u URI',
long: '--uri URI',
default: '/metrics/currentUser/metrics'
+ option :https,
+ short: '-h',
+ long: '--https',
+ boolean: true,
+ description: 'Enabling https connections',
+ default: false
+
def run
begin
- r = RestClient::Resource.new("http://#{config[:server]}:#{config[:port]}#{config[:uri]}", timeout: 5).get
+ https ||= config[:https] ? 'https' : 'http'
+ r = RestClient::Resource.new("#{https}://#{config[:server]}:#{config[:port]}#{config[:uri]}", timeout: 5).get
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|
metric_value.each do |metric_hash_key, metric_hash_value|