Fixed memory reporting for Linux systems
/proc/meminfo reports memory in KiloBytes and so needs a multiplier of 1024 instead of 1000. The kernel reports in terms of pages and the proc filesystem is left shifting by 2 for 4KB pages to get KB. Since this is a binary shift, Bytes will need to shift by 10 and so get multiplied by 1024. From the kernel code. PAGE_SHIFT = 12 for 4KB pages "MemTotal: %8lu kB\n", K(i.totalram)
This commit is contained in:
parent
a3c846b73e
commit
13ee9ff37b
|
@ -30,17 +30,17 @@ func VirtualMemory() (*VirtualMemoryStat, error) {
|
||||||
}
|
}
|
||||||
switch key {
|
switch key {
|
||||||
case "MemTotal":
|
case "MemTotal":
|
||||||
ret.Total = t * 1000
|
ret.Total = t * 1024
|
||||||
case "MemFree":
|
case "MemFree":
|
||||||
ret.Free = t * 1000
|
ret.Free = t * 1024
|
||||||
case "Buffers":
|
case "Buffers":
|
||||||
ret.Buffers = t * 1000
|
ret.Buffers = t * 1024
|
||||||
case "Cached":
|
case "Cached":
|
||||||
ret.Cached = t * 1000
|
ret.Cached = t * 1024
|
||||||
case "Active":
|
case "Active":
|
||||||
ret.Active = t * 1000
|
ret.Active = t * 1024
|
||||||
case "Inactive":
|
case "Inactive":
|
||||||
ret.Inactive = t * 1000
|
ret.Inactive = t * 1024
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ret.Available = ret.Free + ret.Buffers + ret.Cached
|
ret.Available = ret.Free + ret.Buffers + ret.Cached
|
||||||
|
|
Loading…
Reference in New Issue