From b7f9acbce8e179b5eccdf0bdfd4d1fd2d19ea3a1 Mon Sep 17 00:00:00 2001 From: Minje Park Date: Sat, 20 Jul 2019 23:42:39 +0900 Subject: [PATCH] add unreclaim metric, this closes #719 --- mem/mem.go | 1 + mem/mem_linux.go | 2 ++ mem/mem_test.go | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/mem/mem.go b/mem/mem.go index 8d1c234..8e444ba 100644 --- a/mem/mem.go +++ b/mem/mem.go @@ -58,6 +58,7 @@ type VirtualMemoryStat struct { Shared uint64 `json:"shared"` Slab uint64 `json:"slab"` SReclaimable uint64 `json:"sreclaimable"` + SUnreclaim uint64 `json:"sunreclaim"` PageTables uint64 `json:"pagetables"` SwapCached uint64 `json:"swapcached"` CommitLimit uint64 `json:"commitlimit"` diff --git a/mem/mem_linux.go b/mem/mem_linux.go index 7785c50..92cf143 100644 --- a/mem/mem_linux.go +++ b/mem/mem_linux.go @@ -83,6 +83,8 @@ func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) { case "SReclaimable": sReclaimable = true ret.SReclaimable = t * 1024 + case "SUnreclaim": + ret.SUnreclaim = t * 1024 case "PageTables": ret.PageTables = t * 1024 case "SwapCached": diff --git a/mem/mem_test.go b/mem/mem_test.go index 536508a..29d6c21 100644 --- a/mem/mem_test.go +++ b/mem/mem_test.go @@ -77,7 +77,7 @@ func TestVirtualMemoryStat_String(t *testing.T) { UsedPercent: 30.1, 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,"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}` + 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,"sunreclaim":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) { t.Errorf("VirtualMemoryStat string is invalid: %v", v) }