bin/metrics-beanstalkd-tubes.rb in sensu-plugins-beanstalk-1.0.0 vs bin/metrics-beanstalkd-tubes.rb in sensu-plugins-beanstalk-1.1.0
- old
+ new
@@ -71,16 +71,26 @@
private
INGORED_KEYS = ['name'].freeze
+ def tube_age(tube)
+ job = tube.peek(:ready)
+ if !job.nil?
+ job.stats.age
+ else
+ 0
+ end
+ end
+
def output_stats(tube)
stats = tube.stats
stats.keys.sort.each do |key|
next unless matches_filter?(:stats, key)
next if INGORED_KEYS.include?(key)
output "#{config[:scheme]}.#{tube.name}.#{key}", stats[key]
end
+ output "#{config[:scheme]}.#{tube.name}.age", tube_age(tube) if matches_filter?(:stats, 'age')
end
def tubes
connection.tubes.all.select { |tube| matches_filter?(:tubes, tube.name) }
end