Skip to content

Commit 2f48571

Browse files
authored
Merge pull request #305 from HeRaNO/use-peak
cgroups2: export memory max usage and swap max usage
2 parents 5475f28 + a1235a5 commit 2f48571

File tree

4 files changed

+83
-45
lines changed

4 files changed

+83
-45
lines changed

cgroup2/manager.go

+2
Original file line numberDiff line numberDiff line change
@@ -594,8 +594,10 @@ func (c *Manager) Stat() (*stats.Metrics, error) {
594594
ThpCollapseAlloc: out["thp_collapse_alloc"],
595595
Usage: getStatFileContentUint64(filepath.Join(c.path, "memory.current")),
596596
UsageLimit: getStatFileContentUint64(filepath.Join(c.path, "memory.max")),
597+
MaxUsage: getStatFileContentUint64(filepath.Join(c.path, "memory.peak")),
597598
SwapUsage: getStatFileContentUint64(filepath.Join(c.path, "memory.swap.current")),
598599
SwapLimit: getStatFileContentUint64(filepath.Join(c.path, "memory.swap.max")),
600+
SwapMaxUsage: getStatFileContentUint64(filepath.Join(c.path, "memory.swap.peak")),
599601
}
600602
if len(memoryEvents) > 0 {
601603
metrics.MemoryEvents = &stats.MemoryEvents{

cgroup2/stats/metrics.pb.go

+65-45
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cgroup2/stats/metrics.pb.txt

+14
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,20 @@ file {
369369
type: TYPE_UINT64
370370
json_name: "swapLimit"
371371
}
372+
field {
373+
name: "max_usage"
374+
number: 36
375+
label: LABEL_OPTIONAL
376+
type: TYPE_UINT64
377+
json_name: "maxUsage"
378+
}
379+
field {
380+
name: "swap_max_usage"
381+
number: 37
382+
label: LABEL_OPTIONAL
383+
type: TYPE_UINT64
384+
json_name: "swapMaxUsage"
385+
}
372386
}
373387
message_type {
374388
name: "MemoryEvents"

cgroup2/stats/metrics.proto

+2
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ message MemoryStat {
6464
uint64 usage_limit = 33;
6565
uint64 swap_usage = 34;
6666
uint64 swap_limit = 35;
67+
uint64 max_usage = 36;
68+
uint64 swap_max_usage = 37;
6769
}
6870

6971
message MemoryEvents {

0 commit comments

Comments
 (0)