class RorVsWild::Metrics::Cpu

def initialize

def initialize
  @old_stat = Stat.read
end

def update

def update
  if @old_stat && (new_stat = Stat.read)
    if (total = new_stat.total - @old_stat.total) > 0
      @user = (new_stat.user - @old_stat.user) * 100 / total
      @system = (new_stat.system - @old_stat.system) * 100 / total
      @idle = (new_stat.idle - @old_stat.idle) * 100 / total
      @waiting = (new_stat.iowait - @old_stat.iowait) * 100 / total
      @stolen = (new_stat.steal - @old_stat.steal) * 100 / total
      @old_stat = new_stat
    end
  end
  @load_average = File.read("/proc/loadavg").to_f if File.readable?("/proc/loadavg")
  @count = `nproc`.to_i rescue nil
end