Skip to content

Commit

Permalink
Added support for slice discovery with cgroups version 2
Browse files Browse the repository at this point in the history
  • Loading branch information
egertak committed Jan 15, 2025
1 parent 260a345 commit 633679a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/lc_lib.erl
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,14 @@ get_cgroup2_memory_usage() ->

do_get_cgroup2_memory_usage() ->
try
CgroupUsed = read_int_fs(filename:join(["/sys/fs/cgroup/",
Cgroup = "/sys/fs/cgroup",
Paths = [filename:join(Cgroup, get_cgroup_path(<<>>)),
Cgroup],
CgroupPath = first_existing(Paths),
CgroupUsed = read_int_fs(filename:join([CgroupPath,
"memory.current"])
),
CgroupTotal = read_int_fs(filename:join(["/sys/fs/cgroup/",
CgroupTotal = read_int_fs(filename:join([CgroupPath,
"memory.max"])),
{CgroupUsed/CgroupTotal, CgroupTotal}
catch error:_ ->
Expand Down

0 comments on commit 633679a

Please sign in to comment.