mirror of
https://github.com/shirou/gopsutil.git
synced 2025-04-29 13:49:21 +08:00
SReclaimable should be added to Cached Memory
This commit is contained in:
parent
cce2d16538
commit
f9e238c38b
@ -44,7 +44,7 @@ type VirtualMemoryStat struct {
|
|||||||
|
|
||||||
// FreeBSD specific numbers:
|
// FreeBSD specific numbers:
|
||||||
// https://reviews.freebsd.org/D8467
|
// https://reviews.freebsd.org/D8467
|
||||||
Laundry uint64 `json:"laundry"`
|
Laundry uint64 `json:"laundry"`
|
||||||
|
|
||||||
// Linux specific numbers
|
// Linux specific numbers
|
||||||
// https://www.centos.org/docs/5/html/5.1/Deployment_Guide/s2-proc-meminfo.html
|
// https://www.centos.org/docs/5/html/5.1/Deployment_Guide/s2-proc-meminfo.html
|
||||||
@ -57,6 +57,7 @@ type VirtualMemoryStat struct {
|
|||||||
WritebackTmp uint64 `json:"writebacktmp"`
|
WritebackTmp uint64 `json:"writebacktmp"`
|
||||||
Shared uint64 `json:"shared"`
|
Shared uint64 `json:"shared"`
|
||||||
Slab uint64 `json:"slab"`
|
Slab uint64 `json:"slab"`
|
||||||
|
SReclaimable uint64 `json:"sreclaimable"`
|
||||||
PageTables uint64 `json:"pagetables"`
|
PageTables uint64 `json:"pagetables"`
|
||||||
SwapCached uint64 `json:"swapcached"`
|
SwapCached uint64 `json:"swapcached"`
|
||||||
CommitLimit uint64 `json:"commitlimit"`
|
CommitLimit uint64 `json:"commitlimit"`
|
||||||
|
@ -61,6 +61,8 @@ func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) {
|
|||||||
ret.Shared = t * 1024
|
ret.Shared = t * 1024
|
||||||
case "Slab":
|
case "Slab":
|
||||||
ret.Slab = t * 1024
|
ret.Slab = t * 1024
|
||||||
|
case "SReclaimable":
|
||||||
|
ret.SReclaimable = t * 1024
|
||||||
case "PageTables":
|
case "PageTables":
|
||||||
ret.PageTables = t * 1024
|
ret.PageTables = t * 1024
|
||||||
case "SwapCached":
|
case "SwapCached":
|
||||||
@ -97,6 +99,9 @@ func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) {
|
|||||||
ret.HugePageSize = t * 1024
|
ret.HugePageSize = t * 1024
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret.Cached += ret.SReclaimable
|
||||||
|
|
||||||
if !memavail {
|
if !memavail {
|
||||||
ret.Available = ret.Free + ret.Buffers + ret.Cached
|
ret.Available = ret.Free + ret.Buffers + ret.Cached
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ func TestVirtualMemoryStat_String(t *testing.T) {
|
|||||||
UsedPercent: 30.1,
|
UsedPercent: 30.1,
|
||||||
Free: 40,
|
Free: 40,
|
||||||
}
|
}
|
||||||
e := `{"total":10,"available":20,"used":30,"usedPercent":30.1,"free":40,"active":0,"inactive":0,"wired":0,"laundry":0,"buffers":0,"cached":0,"writeback":0,"dirty":0,"writebacktmp":0,"shared":0,"slab":0,"pagetables":0,"swapcached":0,"commitlimit":0,"committedas":0,"hightotal":0,"highfree":0,"lowtotal":0,"lowfree":0,"swaptotal":0,"swapfree":0,"mapped":0,"vmalloctotal":0,"vmallocused":0,"vmallocchunk":0,"hugepagestotal":0,"hugepagesfree":0,"hugepagesize":0}`
|
e := `{"total":10,"available":20,"used":30,"usedPercent":30.1,"free":40,"active":0,"inactive":0,"wired":0,"laundry":0,"buffers":0,"cached":0,"writeback":0,"dirty":0,"writebacktmp":0,"shared":0,"slab":0,"sreclaimable":0,"pagetables":0,"swapcached":0,"commitlimit":0,"committedas":0,"hightotal":0,"highfree":0,"lowtotal":0,"lowfree":0,"swaptotal":0,"swapfree":0,"mapped":0,"vmalloctotal":0,"vmallocused":0,"vmallocchunk":0,"hugepagestotal":0,"hugepagesfree":0,"hugepagesize":0}`
|
||||||
if e != fmt.Sprintf("%v", v) {
|
if e != fmt.Sprintf("%v", v) {
|
||||||
t.Errorf("VirtualMemoryStat string is invalid: %v", v)
|
t.Errorf("VirtualMemoryStat string is invalid: %v", v)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user