Sha256: 00f91551bc18c3292a12da0562fdad6812b240ebe2c685604fd3bc7f72bb1b5d
Contents?: true
Size: 1.91 KB
Versions: 9
Compression:
Stored size: 1.91 KB
Contents
require 'json' module Rearview class StatsTask class StatsTaskError < StandardError; end; include Celluloid include Rearview::Logger attr_reader :delay, :statsd def initialize(delay=120,start=true) @delay = delay @statsd = Rearview::Statsd.new # This number is not documented well. The batch size is actually the max # number of batch calls allowed, before the UDP message is sent. Anything # after this value is quietly dropped. However, keep in mind that the # safest max UDP message size is 512. # # So make sure that batch_size * 8bytes/per int < 512 @statsd.batch_size = 12 schedule if start end def schedule logger.debug "#{self} schedule" @timer = after(@delay) { self.run } end def run logger.debug "#{self} run" vm = Rearview::Vm.new @statsd.batch do |batch| batch.gauge('vm.total_memory',vm.total_memory.bytes_to_kilobytes) batch.gauge('vm.free_memory',vm.free_memory.bytes_to_kilobytes) batch.gauge('vm.max_memory',vm.max_memory.bytes_to_kilobytes) batch.gauge('vm.heap.committed',vm.heap.committed.bytes_to_kilobytes) batch.gauge('vm.heap.init',vm.heap.init.bytes_to_kilobytes) batch.gauge('vm.heap.max',vm.heap.max.bytes_to_kilobytes) batch.gauge('vm.heap.used',vm.heap.used.bytes_to_kilobytes) batch.gauge('vm.non_heap.committed',vm.non_heap.committed.bytes_to_kilobytes) batch.gauge('vm.non_heap.init',vm.non_heap.init.bytes_to_kilobytes) batch.gauge('vm.non_heap.max',vm.non_heap.max.bytes_to_kilobytes) batch.gauge('vm.non_heap.used',vm.non_heap.used.bytes_to_kilobytes) batch.gauge('monitor.total',( Rearview.config.monitor_enabled? ? Rearview.monitor_service.jobs.keys.count : 0 )) end rescue logger.error "#{self} run failed: #{$!}\n#{$@.join("\n")}" ensure schedule end end end
Version data entries
9 entries across 9 versions & 1 rubygems