Sha256: 4cac7a90b6297b3abc6f0089056734f06894051aebc5e5a8dd6d424f28c0f174

Contents?: true

Size: 594 Bytes

Versions: 3

Compression:

Stored size: 594 Bytes

Contents

collect do
  next if not File.readable?('/proc/stat')

  File.open('/proc/stat') do |file|
    file.each do |line|
      next if not line =~ /^cpu /

      cpu = line.chomp.split[1,7].map do |x|
        x.to_i / 100
      end

      Metriks.derive("os.cpu.user").mark(cpu[0])
      Metriks.derive("os.cpu.nice").mark(cpu[1])
      Metriks.derive("os.cpu.system").mark(cpu[2])
      Metriks.derive("os.cpu.idle").mark(cpu[3])
      Metriks.derive("os.cpu.iowait").mark(cpu[4])
      Metriks.derive("os.cpu.irq").mark(cpu[5])
      Metriks.derive("os.cpu.softirq").mark(cpu[6])
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ganymed-0.4.2 lib/ganymed/collectors/cpu.rb
ganymed-0.4.1 lib/ganymed/collectors/cpu.rb
ganymed-0.4.0 lib/ganymed/collectors/cpu.rb