bin/metrics-marathon.rb in sensu-plugins-mesos-0.1.0 vs bin/metrics-marathon.rb in sensu-plugins-mesos-0.1.1
- old
+ new
@@ -32,11 +32,11 @@
require 'rest-client'
require 'socket'
require 'json'
class MarathonMetrics < Sensu::Plugin::Metric::CLI::Graphite
- SKIP_ROOT_KEYS = %w(version)
+ SKIP_ROOT_KEYS = %w(version).freeze
option :scheme,
description: 'Metric naming scheme',
short: '-s SCHEME',
long: '--scheme SCHEME',
default: "#{Socket.gethostname}.marathon"
@@ -45,18 +45,25 @@
description: 'Marathon Host',
short: '-h SERVER',
long: '--host SERVER',
default: 'localhost'
+ option :port,
+ description: 'Marathon port',
+ short: '-p PORT',
+ long: '--port PORT',
+ required: false,
+ default: '8080'
+
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]}:8080/metrics", timeout: config[:timeout]).get
+ r = RestClient::Resource.new("http://#{config[:server]}:#{config[:port]}/metrics", 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|