Sha256: 2654f3d9cd1ce124eca923f7af979bf4b77218928e3770a0be718d2acc359e46
Contents?: true
Size: 796 Bytes
Versions: 1
Compression:
Stored size: 796 Bytes
Contents
require 'ganymed/collector' module Ganymed class Collector class CPU < Base def collect! File.open('/proc/stat') do |f| cpu = f.readline.chomp.split[1,7].map do |x| x.to_i / hz end @sampler.emit(:derive, "os.cpu.user", cpu[0]) @sampler.emit(:derive, "os.cpu.nice", cpu[1]) @sampler.emit(:derive, "os.cpu.system", cpu[2]) @sampler.emit(:derive, "os.cpu.idle", cpu[3]) @sampler.emit(:derive, "os.cpu.iowait", cpu[4]) @sampler.emit(:derive, "os.cpu.irq", cpu[5]) @sampler.emit(:derive, "os.cpu.softirq", cpu[6]) end end def interval @config.interval.tap{} or 0.2 end def hz @config.hz.tap{} or 100 end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ganymed-0.1.0 | lib/ganymed/collector/cpu.rb |