diff --git a/mem/mem.go b/mem/mem.go index 3255890..a6c0123 100644 --- a/mem/mem.go +++ b/mem/mem.go @@ -48,8 +48,12 @@ type VirtualMemoryStat struct { // Linux specific numbers // https://www.centos.org/docs/5/html/5.1/Deployment_Guide/s2-proc-meminfo.html - Buffers uint64 `json:"buffers"` - Cached uint64 `json:"cached"` + // https://www.kernel.org/doc/Documentation/filesystems/proc.txt + Buffers uint64 `json:"buffers"` + Cached uint64 `json:"cached"` + Writeback uint64 `json:"writeback"` + Dirty uint64 `json:"dirty"` + WritebackTmp uint64 `json:"writebacktmp"` } type SwapMemoryStat struct { diff --git a/mem/mem_linux.go b/mem/mem_linux.go index 899da83..7df4c3e 100644 --- a/mem/mem_linux.go +++ b/mem/mem_linux.go @@ -46,6 +46,12 @@ func VirtualMemory() (*VirtualMemoryStat, error) { ret.Active = t * 1024 case "Inactive": ret.Inactive = t * 1024 + case "Writeback": + ret.Writeback = t * 1024 + case "WritebackTmp": + ret.WritebackTmp = t * 1024 + case "Dirty": + ret.Dirty = t * 1024 } } if !memavail { diff --git a/mem/mem_test.go b/mem/mem_test.go index f7074d8..21582b9 100644 --- a/mem/mem_test.go +++ b/mem/mem_test.go @@ -52,7 +52,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,"buffers":0,"cached":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}` if e != fmt.Sprintf("%v", v) { t.Errorf("VirtualMemoryStat string is invalid: %v", v) }