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