1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-14 19:24:10 +03:00

bug #388: Now kvm probe gets correct memory information

(cherry picked from commit bb922c51c74d0ac755e993cb6bedd81873504bb7)
This commit is contained in:
Javi Fontan 2011-01-20 16:40:02 +01:00
parent 4b2265c9fc
commit 2f3efae538

View File

@ -51,15 +51,7 @@ exit(-1) if $?!=0
top_text.gsub!(/^top.*^top.*?$/m, "") # Strip first top output
top_text.split(/\n/).each{|line|
if line.match('^Mem')
line[4..-1].split(",").each{|elemento|
temp = elemento.strip.split("k ")
if temp[1] == "used"
$used_memory = temp[0]
end
}
elsif line.match('^Cpu')
if line.match('^Cpu')
line[7..-1].split(",").each{|elemento|
temp = elemento.strip.split("%")
if temp[1]=="id"
@ -73,8 +65,12 @@ top_text.split(/\n/).each{|line|
end
}
$free_memory=`free -k|grep "buffers\/cache"|awk '{print $4}'`
$total_memory = `free -k|grep "Mem:" | awk '{print $2}'`
tmp=`free -k|grep "buffers\/cache"|awk '{print $3 " " $4}'`.split
$used_memory=tmp[0]
$free_memory=tmp[1]
net_text=`cat /proc/net/dev`
exit(-1) if $?!=0
@ -101,4 +97,3 @@ print_info("USEDCPU",$used_cpu)
print_info("NETRX",$netrx)
print_info("NETTX",$nettx)