Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/okeuday/cgroups
Erlang native cgroups interface
https://github.com/okeuday/cgroups
cgroups erlang linux
Last synced: 3 months ago
JSON representation
Erlang native cgroups interface
- Host: GitHub
- URL: https://github.com/okeuday/cgroups
- Owner: okeuday
- License: mit
- Created: 2016-09-14T03:15:55.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-10-26T18:24:32.000Z (about 1 year ago)
- Last Synced: 2024-10-14T03:29:55.761Z (3 months ago)
- Topics: cgroups, erlang, linux
- Language: Erlang
- Size: 90.8 KB
- Stars: 13
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.markdown
- License: LICENSE
Awesome Lists containing this project
README
Erlang cgroups interface
========================An interface for cgroups manipulation that handles cgroup version details
(i.e., differences between [v1](https://www.kernel.org/doc/Documentation/cgroup-v1/cgroups.txt) and [v2](https://github.com/torvalds/linux/blob/master/Documentation/admin-guide/cgroup-v2.rst))
and provides safe usage of the cgroups filesystem mount.Build
-----rebar compile
Example
-------Update or create the cgroup "group1/nested1" with the OS pid 19368,
then delete the cgroup path after moving the OS pid back to the root cgroup
(executed as root).# erl -pz ebin
1> application:start(cgroups).
2> OSPid0 = 19368.
3> CGroupPath = "group1/nested1".
4> {ok, CGroups} = cgroups:new().
5> MemoryLimit = case cgroups:version(CGroups) of 1 -> "memory.limit_in_bytes"; 2 -> "memory.high" end.
6> cgroups:update_or_create(CGroupPath,
[OSPid0],
[{MemoryLimit, "10000000"}],
CGroups).
7> cgroups:update("", [OSPid0], [], CGroups).
8> cgroups:delete_recursive(CGroupPath, CGroups).
9> cgroups:destroy(CGroups).Troubleshooting
---------------**`cgroups:update/4` and `cgroups:update_or_create/4` Errors:**
* Either root execution of beam.smp or
`setcap cap_sys_admin=+ep /path/to/beam.smp` before execution is required
for most usage of cgroups
* A Linux/systemd setup may have the control group setup mode set to `hybrid`
due to it being the [recommended default](https://github.com/systemd/systemd/blob/v239/NEWS#L1365)
for distributions. However, that mode blocks the use of cgroup controllers
(the file `/sys/fs/cgroup/unified/cgroup.controllers` is empty)
because the cgroup controllers can only be [mounted in one hierarchy](https://www.kernel.org/doc/html/latest/admin-guide/cgroup-v2.html#mounting)
(v1 or v2). If cgroup v1 should be used, the Linux kernel argument
`systemd.legacy_systemd_cgroup_controller=1` can be used.
If cgroup v2 should be used, the Linux kernel argument
`systemd.unified_cgroup_hierarchy=1` can be used
(with systemd >= `v226` and kernel >= `4.2`) or
`cgroup_no_v1=all` can be used (with kernel >= `4.6`).
* Any non-root use should only use `cgroups:update/4` with more limited
controllers (memory, pids, possibly cpu and/or io) and all OS pids added
elsewhere as rootAuthor
------Michael Truog (mjtruog at protonmail dot com)
License
-------MIT License