Skip to content

Commit

Permalink
Merge pull request #27 from heptalium/master
Browse files Browse the repository at this point in the history
Read more values from /proc/meminfo on Linux.
  • Loading branch information
pyto86pri authored May 6, 2021
2 parents 1c0960e + b349d18 commit 18b73dd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
9 changes: 8 additions & 1 deletion memory/memory_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ func Get() (*Stats, error) {
// Stats represents memory statistics for linux
type Stats struct {
Total, Used, Buffers, Cached, Free, Available, Active, Inactive,
SwapTotal, SwapUsed, SwapCached, SwapFree uint64
SwapTotal, SwapUsed, SwapCached, SwapFree, Mapped, Shmem, Slab,
PageTables, Committed, VmallocUsed uint64
MemAvailableEnabled bool
}

Expand All @@ -43,6 +44,12 @@ func collectMemoryStats(out io.Reader) (*Stats, error) {
"SwapCached": &memory.SwapCached,
"SwapTotal": &memory.SwapTotal,
"SwapFree": &memory.SwapFree,
"Mapped": &memory.Mapped,
"Shmem": &memory.Shmem,
"Slab": &memory.Slab,
"PageTables": &memory.PageTables,
"Committed_AS": &memory.Committed,
"VmallocUsed": &memory.VmallocUsed,
}
for scanner.Scan() {
line := scanner.Text()
Expand Down
12 changes: 12 additions & 0 deletions memory/memory_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ DirectMap2M: 888832 kB
SwapUsed: uint64(2432 * 1024),
SwapCached: uint64(504 * 1024),
SwapFree: uint64(1957500 * 1024),
Mapped: uint64(151408 * 1024),
Shmem: uint64(163548 * 1024),
Slab: uint64(202768 * 1024),
PageTables: uint64(15944 * 1024),
Committed: uint64(7238800 * 1024),
VmallocUsed: uint64(16344 * 1024),
MemAvailableEnabled: false,
},
},
Expand Down Expand Up @@ -152,6 +158,12 @@ DirectMap2M: 888832 kB
SwapUsed: uint64(2432 * 1024),
SwapCached: uint64(504 * 1024),
SwapFree: uint64(1957500 * 1024),
Mapped: uint64(151408 * 1024),
Shmem: uint64(163548 * 1024),
Slab: uint64(202768 * 1024),
PageTables: uint64(15944 * 1024),
Committed: uint64(7238800 * 1024),
VmallocUsed: uint64(16344 * 1024),
MemAvailableEnabled: true,
},
},
Expand Down

0 comments on commit 18b73dd

Please sign in to comment.