Merge pull request #198 from mced/fix_mem_used_perc

[fix] mem_used_perc returns percentage of used mem
This commit is contained in:
Cameron Sparr 2015-09-15 15:24:48 -07:00
commit 2e68d3cb3c
3 changed files with 3 additions and 3 deletions

View File

@ -61,7 +61,7 @@ func VirtualMemory() (*VirtualMemoryStat, error) {
ret.Available = ret.Free + ret.Buffers + ret.Cached ret.Available = ret.Free + ret.Buffers + ret.Cached
ret.Used = ret.Total - ret.Free ret.Used = ret.Total - ret.Free
ret.UsedPercent = float64(ret.Total-ret.Available) / float64(ret.Total) * 100.0 ret.UsedPercent = float64(ret.Used) / float64(ret.Total) * 100.0
return ret, nil return ret, nil
} }

View File

@ -81,7 +81,7 @@ func VirtualMemory() (*VirtualMemoryStat, error) {
ret.Available = ret.Free + ret.Buffers + ret.Cached ret.Available = ret.Free + ret.Buffers + ret.Cached
ret.Used = ret.Total - ret.Free ret.Used = ret.Total - ret.Free
ret.UsedPercent = float64(ret.Total-ret.Available) / float64(ret.Total) * 100.0 ret.UsedPercent = float64(ret.Used) / float64(ret.Total) * 100.0
return ret, nil return ret, nil
} }

View File

@ -63,7 +63,7 @@ func SwapMemory() (*SwapMemoryStat, error) {
ret.Used = ret.Total - ret.Free ret.Used = ret.Total - ret.Free
//check Infinity //check Infinity
if ret.Total != 0 { if ret.Total != 0 {
ret.UsedPercent = float64(ret.Total-ret.Free) / float64(ret.Total) * 100.0 ret.UsedPercent = float64(ret.Used) / float64(ret.Total) * 100.0
} else { } else {
ret.UsedPercent = 0 ret.UsedPercent = 0
} }