#linux #cgroup #cgroups #containers

cgroups-fs

Rust bindings to Linux Control Groups (cgroups)

8 stable releases

1.1.3 Jun 12, 2022
1.1.2 Jun 3, 2020
1.1.1 Aug 14, 2019
1.0.3 May 5, 2019
1.0.0 Dec 27, 2018

#88 in Unix APIs

Download history 26/week @ 2022-03-13 21/week @ 2022-03-20 1/week @ 2022-04-03 1/week @ 2022-04-17 8/week @ 2022-04-24 22/week @ 2022-05-01 42/week @ 2022-05-08 120/week @ 2022-05-15 30/week @ 2022-05-22 57/week @ 2022-05-29 40/week @ 2022-06-05 25/week @ 2022-06-12 3/week @ 2022-06-19 3/week @ 2022-06-26

78 downloads per month

MIT/Apache

15KB
212 lines

cgroups-fs crates.io Documentation Build Status

Native Rust library for managing Linux Control Groups (cgroups).

This crate, curently, only supports the original, V1 hierarchy. You are welcome to contribute Cgroups V2 support.

Prior art

  • cgroups - it does too many things (e.g. creates cgroups in the subsystems that I don't plan to use, parses control files that I don't plan to use).

Usage

First, add the following to your Cargo.toml:

[dependencies]
cgroups-fs = "1.0"

Next, use it in your crate:

use cgroups_fs;

Examples

use cgroups_fs;

let my_cgroup = cgroups_fs::CgroupName("my-cgroup");
let my_cpu_cgroup = cgroups_fs::Cgroup::init(&my_cgroup, "cpu")?;
println!(
    "The current CPU shares in `my-cgroup` control group is {}",
    my_cpu_cgroup.get_value::<u64>("cpu.shares")
);

Please, find more examples in the documentation.

License

This project is licensed under either of

at your option.

Dependencies

~1.5MB
~27K SLoC