class RorVsWild::Metrics::Cpu::Stat
Attributes
guest[R]
guest_nice[R]
idle[R]
iowait[R]
irq[R]
nice[R]
softirq[R]
steal[R]
system[R]
total[R]
user[R]
Public Class Methods
new(user, nice, system, idle, iowait, irq, softirq, steal, guest, guest_nice)
click to toggle 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
parse(string)
click to toggle 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
read()
click to toggle source
# File lib/rorvswild/metrics/cpu.rb, line 56 def self.read parse(File.read("/proc/stat")) if File.readable?("/proc/stat") end