Merge pull request #478 from DataDog/olivielpeau/commit-vm-stats

[mem] Add commit-related stats to VirtualMemoryStat on Linux
pull/508/head
shirou 7 years ago committed by GitHub
commit a1564d2e89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -54,6 +54,8 @@ type VirtualMemoryStat struct {
Slab uint64 `json:"slab"` Slab uint64 `json:"slab"`
PageTables uint64 `json:"pagetables"` PageTables uint64 `json:"pagetables"`
SwapCached uint64 `json:"swapcached"` SwapCached uint64 `json:"swapcached"`
CommitLimit uint64 `json:"commitlimit"`
CommittedAS uint64 `json:"committedas"`
} }
type SwapMemoryStat struct { type SwapMemoryStat struct {

@ -65,6 +65,10 @@ func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) {
ret.PageTables = t * 1024 ret.PageTables = t * 1024
case "SwapCached": case "SwapCached":
ret.SwapCached = t * 1024 ret.SwapCached = t * 1024
case "CommitLimit":
ret.CommitLimit = t * 1024
case "Committed_AS":
ret.CommittedAS = t * 1024
} }
} }
if !memavail { if !memavail {

@ -57,7 +57,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,"buffers":0,"cached":0,"writeback":0,"dirty":0,"writebacktmp":0,"shared":0,"slab":0,"pagetables":0,"swapcached":0}` e := `{"total":10,"available":20,"used":30,"usedPercent":30.1,"free":40,"active":0,"inactive":0,"wired":0,"buffers":0,"cached":0,"writeback":0,"dirty":0,"writebacktmp":0,"shared":0,"slab":0,"pagetables":0,"swapcached":0,"commitlimit":0,"committedas":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…
Cancel
Save