Add 'SwapCached' to the VirtualMemoryStat informations on linux

pull/291/head
Maxime Mouial 9 years ago
parent bc9d8fac2b
commit 4a1d5da977

@ -57,6 +57,7 @@ type VirtualMemoryStat struct {
Shared uint64 `json:"shared"` Shared uint64 `json:"shared"`
Slab uint64 `json:"slab"` Slab uint64 `json:"slab"`
PageTables uint64 `json:"pagetables"` PageTables uint64 `json:"pagetables"`
SwapCached uint64 `json:"swapcached"`
} }
type SwapMemoryStat struct { type SwapMemoryStat struct {

@ -58,6 +58,8 @@ func VirtualMemory() (*VirtualMemoryStat, error) {
ret.Slab = t * 1024 ret.Slab = t * 1024
case "PageTables": case "PageTables":
ret.PageTables = t * 1024 ret.PageTables = t * 1024
case "SwapCached":
ret.SwapCached = t * 1024
} }
} }
if !memavail { if !memavail {

@ -52,7 +52,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}` 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}`
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