mirror of
https://github.com/OpenNebula/one.git
synced 2025-02-22 17:57:46 +03:00
bug #182: Columns with KB units are rounded to MB, GB or TB for readability
This commit is contained in:
parent
8a3f88801c
commit
86c2dad68c
@ -20,6 +20,24 @@ require 'OpenNebula'
|
||||
# CONSOLE UTILITIES #
|
||||
#####################
|
||||
|
||||
BinarySufix = ["K", "M", "G", "T" ]
|
||||
|
||||
def humanize_size(value)
|
||||
i=0
|
||||
|
||||
while value > 1024 && i < 3 do
|
||||
value /= 1024.0
|
||||
i+=1
|
||||
end
|
||||
|
||||
value = (value * 10).round / 10.0
|
||||
|
||||
value = value.to_i if value - value.round == 0
|
||||
st = value.to_s + BinarySufix[i]
|
||||
|
||||
return st
|
||||
end
|
||||
|
||||
# Sets bold font
|
||||
def scr_bold
|
||||
print "\33[1m"
|
||||
@ -122,6 +140,8 @@ class ShowTable
|
||||
dat=d[c]
|
||||
col=@columns[c]
|
||||
|
||||
dat = humanize_size( Float(dat) ) if( @table[col][:kbytes] )
|
||||
|
||||
format_data(col, dat) if @table[col]
|
||||
}.join(' ')
|
||||
}.join("\n")
|
||||
|
@ -87,12 +87,14 @@ ShowTableHost={
|
||||
:name => "TMEM",
|
||||
:desc => "Total memory",
|
||||
:size => 7,
|
||||
:kbytes => true,
|
||||
:proc => lambda {|d,e| d["HOST_SHARE/MAX_MEM"] }
|
||||
},
|
||||
:fmem => {
|
||||
:name => "FMEM",
|
||||
:desc => "Free memory",
|
||||
:size => 7,
|
||||
:kbytes => true,
|
||||
:proc => lambda {|d,e| d["HOST_SHARE/FREE_MEM"] }
|
||||
},
|
||||
:stat => {
|
||||
|
@ -75,6 +75,7 @@ ShowTableVM={
|
||||
:name => "MEM",
|
||||
:desc => "Memory used by the VM",
|
||||
:size => 7,
|
||||
:kbytes => true,
|
||||
:proc => lambda {|d,e| d["MEMORY"] }
|
||||
},
|
||||
:hostname => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user