class RorVsWild::Metrics::Cpu::Stat
Attributes
Public Class Methods
Source
# File lib/rorvswild/metrics/cpu.rb, line 31 def initialize(user, nice, system, idle, iowait, irq, softirq, steal, guest, guest_nice) @user = user @nice = nice @system = system @idle = idle @iowait = iowait @irq = irq @softirq = softirq @steal = steal @guest = guest @guest_nice = guest_nice @total = user + nice + system + idle + iowait + irq + softirq + steal + guest + guest_nice end
Source
# File lib/rorvswild/metrics/cpu.rb, line 45 def self.parse(string) for row in string.lines if row.start_with?("cpu ") array = row.split[1..-1].map(&:to_i)[0,10] array.fill(0, array.size, 10 - array.size) if array.size < 10 return new(*array) end end nil end
Source
# File lib/rorvswild/metrics/cpu.rb, line 56 def self.read parse(File.read("/proc/stat")) if File.readable?("/proc/stat") end