bin/metrics-marathon.rb in sensu-plugins-mesos-0.1.1 vs bin/metrics-marathon.rb in sensu-plugins-mesos-1.0.0

- old
+ new

@@ -52,31 +52,44 @@ short: '-p PORT', long: '--port PORT', required: false, default: '8080' + option :protocol, + description: 'Marathon protocol [http/https]', + short: '-P PROTOCOL', + long: '--protocol PROTOCOL', + required: false, + default: 'http' + + option :uri, + description: 'Endpoint URI', + short: '-u URI', + long: '--uri URI', + default: '/metrics' + option :timeout, description: 'timeout in seconds', short: '-t TIMEOUT', long: '--timeout TIMEOUT', proc: proc(&:to_i), default: 5 def run - r = RestClient::Resource.new("http://#{config[:server]}:#{config[:port]}/metrics", timeout: config[:timeout]).get + r = RestClient::Resource.new("#{config[:protocol]}://#{config[:server]}:#{config[:port]}#{config[:uri]}", timeout: config[:timeout]).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| output([config[:scheme], metric_groups_key, metric_key, metric_hash_key].join('.'), metric_hash_value) \ - if metric_hash_value.is_a?(Numeric) && metric_hash_key == 'count' + if metric_hash_value.is_a?(Numeric) && (metric_hash_key == 'count' || metric_hash_key == 'value') end end end ok rescue Errno::ECONNREFUSED - critical 'Marathon is not responding' + unknown 'Marathon is not responding' rescue RestClient::RequestTimeout - critical 'Marathon Connection timed out' + unknown 'Marathon Connection timed out' end end