Skip to content

Commit

Permalink
cgroups2: export memory max usage and swap max usage
Browse files Browse the repository at this point in the history
Signed-off-by: Heran Yang <heran55@126.com>
  • Loading branch information
HeRaNO committed Oct 13, 2023
1 parent a0ae1c2 commit a1235a5
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 45 deletions.
2 changes: 2 additions & 0 deletions cgroup2/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -594,8 +594,10 @@ func (c *Manager) Stat() (*stats.Metrics, error) {
ThpCollapseAlloc: out["thp_collapse_alloc"],
Usage: getStatFileContentUint64(filepath.Join(c.path, "memory.current")),
UsageLimit: getStatFileContentUint64(filepath.Join(c.path, "memory.max")),
MaxUsage: getStatFileContentUint64(filepath.Join(c.path, "memory.peak")),
SwapUsage: getStatFileContentUint64(filepath.Join(c.path, "memory.swap.current")),
SwapLimit: getStatFileContentUint64(filepath.Join(c.path, "memory.swap.max")),
SwapMaxUsage: getStatFileContentUint64(filepath.Join(c.path, "memory.swap.peak")),
}
if len(memoryEvents) > 0 {
metrics.MemoryEvents = &stats.MemoryEvents{
Expand Down
110 changes: 65 additions & 45 deletions cgroup2/stats/metrics.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions cgroup2/stats/metrics.pb.txt
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,20 @@ file {
type: TYPE_UINT64
json_name: "swapLimit"
}
field {
name: "max_usage"
number: 36
label: LABEL_OPTIONAL
type: TYPE_UINT64
json_name: "maxUsage"
}
field {
name: "swap_max_usage"
number: 37
label: LABEL_OPTIONAL
type: TYPE_UINT64
json_name: "swapMaxUsage"
}
}
message_type {
name: "MemoryEvents"
Expand Down
2 changes: 2 additions & 0 deletions cgroup2/stats/metrics.proto
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ message MemoryStat {
uint64 usage_limit = 33;
uint64 swap_usage = 34;
uint64 swap_limit = 35;
uint64 max_usage = 36;
uint64 swap_max_usage = 37;
}

message MemoryEvents {
Expand Down

0 comments on commit a1235a5

Please sign in to comment.