[fix] mem_used_perc returns percentage of used mem

This commit is contained in:
Cédric Menassa 2015-09-15 12:58:51 +02:00
parent bd00f46d8b
commit 4d6f11b61f
3 changed files with 4 additions and 4 deletions

View File

@ -61,7 +61,7 @@ func VirtualMemory() (*VirtualMemoryStat, error) {
ret.Available = ret.Free + ret.Buffers + ret.Cached
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
}

View File

@ -81,7 +81,7 @@ func VirtualMemory() (*VirtualMemoryStat, error) {
ret.Available = ret.Free + ret.Buffers + ret.Cached
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
}

View File

@ -45,7 +45,7 @@ func VirtualMemory() (*VirtualMemoryStat, error) {
}
ret.Available = ret.Free + ret.Buffers + ret.Cached
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
}
@ -63,7 +63,7 @@ func SwapMemory() (*SwapMemoryStat, error) {
ret.Used = ret.Total - ret.Free
//check Infinity
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 {
ret.UsedPercent = 0
}