Skip to content

Commit 18b73dd

Browse files
authored
Merge pull request #27 from heptalium/master
Read more values from /proc/meminfo on Linux.
2 parents 1c0960e + b349d18 commit 18b73dd

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

memory/memory_linux.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ func Get() (*Stats, error) {
2525
// Stats represents memory statistics for linux
2626
type Stats struct {
2727
Total, Used, Buffers, Cached, Free, Available, Active, Inactive,
28-
SwapTotal, SwapUsed, SwapCached, SwapFree uint64
28+
SwapTotal, SwapUsed, SwapCached, SwapFree, Mapped, Shmem, Slab,
29+
PageTables, Committed, VmallocUsed uint64
2930
MemAvailableEnabled bool
3031
}
3132

@@ -43,6 +44,12 @@ func collectMemoryStats(out io.Reader) (*Stats, error) {
4344
"SwapCached": &memory.SwapCached,
4445
"SwapTotal": &memory.SwapTotal,
4546
"SwapFree": &memory.SwapFree,
47+
"Mapped": &memory.Mapped,
48+
"Shmem": &memory.Shmem,
49+
"Slab": &memory.Slab,
50+
"PageTables": &memory.PageTables,
51+
"Committed_AS": &memory.Committed,
52+
"VmallocUsed": &memory.VmallocUsed,
4653
}
4754
for scanner.Scan() {
4855
line := scanner.Text()

memory/memory_linux_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ DirectMap2M: 888832 kB
8686
SwapUsed: uint64(2432 * 1024),
8787
SwapCached: uint64(504 * 1024),
8888
SwapFree: uint64(1957500 * 1024),
89+
Mapped: uint64(151408 * 1024),
90+
Shmem: uint64(163548 * 1024),
91+
Slab: uint64(202768 * 1024),
92+
PageTables: uint64(15944 * 1024),
93+
Committed: uint64(7238800 * 1024),
94+
VmallocUsed: uint64(16344 * 1024),
8995
MemAvailableEnabled: false,
9096
},
9197
},
@@ -152,6 +158,12 @@ DirectMap2M: 888832 kB
152158
SwapUsed: uint64(2432 * 1024),
153159
SwapCached: uint64(504 * 1024),
154160
SwapFree: uint64(1957500 * 1024),
161+
Mapped: uint64(151408 * 1024),
162+
Shmem: uint64(163548 * 1024),
163+
Slab: uint64(202768 * 1024),
164+
PageTables: uint64(15944 * 1024),
165+
Committed: uint64(7238800 * 1024),
166+
VmallocUsed: uint64(16344 * 1024),
155167
MemAvailableEnabled: true,
156168
},
157169
},

0 commit comments

Comments
 (0)