Skip to content

Commit 8f660d1

Browse files
wangqingfreewangqing
and
wangqing
authored
meminfo: add Percpu field (prometheus#588)
Signed-off-by: wangqing <[email protected]> Co-authored-by: wangqing <[email protected]>
1 parent 732ca0f commit 8f660d1

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

meminfo.go

+5
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ type Meminfo struct {
126126
VmallocUsed *uint64
127127
// largest contiguous block of vmalloc area which is free
128128
VmallocChunk *uint64
129+
Percpu *uint64
129130
HardwareCorrupted *uint64
130131
AnonHugePages *uint64
131132
ShmemHugePages *uint64
@@ -178,6 +179,7 @@ type Meminfo struct {
178179
VmallocTotalBytes *uint64
179180
VmallocUsedBytes *uint64
180181
VmallocChunkBytes *uint64
182+
PercpuBytes *uint64
181183
HardwareCorruptedBytes *uint64
182184
AnonHugePagesBytes *uint64
183185
ShmemHugePagesBytes *uint64
@@ -339,6 +341,9 @@ func parseMemInfo(r io.Reader) (*Meminfo, error) {
339341
case "VmallocChunk:":
340342
m.VmallocChunk = &val
341343
m.VmallocChunkBytes = &valBytes
344+
case "Percpu:":
345+
m.Percpu = &val
346+
m.PercpuBytes = &valBytes
342347
case "HardwareCorrupted:":
343348
m.HardwareCorrupted = &val
344349
m.HardwareCorruptedBytes = &valBytes

meminfo_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ func TestMeminfo(t *testing.T) {
5353
VmallocTotal: newuint64(34359738367),
5454
VmallocUsed: newuint64(36596),
5555
VmallocChunk: newuint64(34359637840),
56+
Percpu: newuint64(26176),
5657
HardwareCorrupted: newuint64(0),
5758
AnonHugePages: newuint64(12288),
5859
HugePagesTotal: newuint64(0),
@@ -96,6 +97,7 @@ func TestMeminfo(t *testing.T) {
9697
VmallocTotalBytes: newuint64(35184372087808),
9798
VmallocUsedBytes: newuint64(37474304),
9899
VmallocChunkBytes: newuint64(35184269148160),
100+
PercpuBytes: newuint64(26804224),
99101
HardwareCorruptedBytes: newuint64(0),
100102
AnonHugePagesBytes: newuint64(12582912),
101103
HugepagesizeBytes: newuint64(2097152),

testdata/fixtures.ttar

+2-1
Original file line numberDiff line numberDiff line change
@@ -2317,7 +2317,7 @@ unused devices: <none>
23172317
Mode: 644
23182318
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
23192319
Path: fixtures/proc/meminfo
2320-
Lines: 42
2320+
Lines: 43
23212321
MemTotal: 15666184 kB
23222322
MemFree: 440324 kB
23232323
Buffers: 1020128 kB
@@ -2351,6 +2351,7 @@ Committed_AS: 530844 kB
23512351
VmallocTotal: 34359738367 kB
23522352
VmallocUsed: 36596 kB
23532353
VmallocChunk: 34359637840 kB
2354+
Percpu: 26176 kB
23542355
HardwareCorrupted: 0 kB
23552356
AnonHugePages: 12288 kB
23562357
HugePages_Total: 0

0 commit comments

Comments
 (0)