bin/metrics-mesos.rb in sensu-plugins-mesos-0.0.2 vs bin/metrics-mesos.rb in sensu-plugins-mesos-0.0.3
- old
+ new
@@ -50,10 +50,17 @@
description: 'Mesos Host',
short: '-h SERVER',
long: '--host SERVER',
default: 'localhost'
+ option :timeout,
+ description: 'timeout in seconds',
+ short: '-t TIMEOUT',
+ long: '--timeout TIMEOUT',
+ proc: proc(&:to_i),
+ default: 5
+
def run
case config[:mode]
when 'master'
port = '5050'
uri = '/master/stats.json'
@@ -61,10 +68,10 @@
port = '5051'
uri = '/slave(1)/stats.json'
end
scheme = "#{config[:scheme]}.mesos-#{config[:mode]}"
begin
- r = RestClient::Resource.new("http://#{config[:server]}:#{port}#{uri}", timeout: 5).get
+ r = RestClient::Resource.new("http://#{config[:server]}:#{port}#{uri}", timeout: config[:timeout]).get
JSON.parse(r).each do |k, v|
k_copy = k.tr('/', '.')
output([scheme, k_copy].join('.'), v)
end
rescue Errno::ECONNREFUSED