# File lib/vmstat/solaris.rb, line 4 def cpu kstat = `kstat -p "cpu_stat:::/idle|kernel|user/"` cpus = Hash.new { |h, k| h[k] = Hash.new } kstat.lines.each do |line| _, cpu, _, key, value = line.strip.split(/:|\s+/) cpus[cpu.to_i][key] = value end cpus.map do |num, v| Cpu.new(num, v["user"].to_i, v["kernel"].to_i, 0, v["idle"].to_i) end end