--- kvm.rb.orig 2011-12-07 14:12:43.645042688 +0100 +++ kvm.rb.new 2011-12-07 14:28:27.969009500 +0100 @@ -16,6 +16,7 @@ # limitations under the License. # #--------------------------------------------------------------------------- # + def print_info(name, value) value = "0" if value.nil? or value.to_s.strip.empty? puts "#{name}=#{value}" @@ -51,9 +52,9 @@ top_text.gsub!(/^top.*^top.*?$/m, "") # Strip first top output top_text.split(/\n/).each{|line| - if line.match('^Cpu') + if line.match('^%Cpu') line[7..-1].split(",").each{|elemento| - temp = elemento.strip.split("%") + temp = elemento.strip.split(" ") if temp[1]=="id" idle = temp[0] $free_cpu = idle.to_f * $total_cpu.to_f / 100