17个版本

0.3.4 2023年10月25日
0.3.2 2023年3月15日
0.2.11 2022年9月23日
0.2.10 2022年6月29日
0.2.0 2020年12月21日

#37 in Unix APIs

Download history 19269/week @ 2024-04-06 19147/week @ 2024-04-13 21569/week @ 2024-04-20 20379/week @ 2024-04-27 17150/week @ 2024-05-04 17666/week @ 2024-05-11 20307/week @ 2024-05-18 19520/week @ 2024-05-25 21422/week @ 2024-06-01 19809/week @ 2024-06-08 20898/week @ 2024-06-15 20608/week @ 2024-06-22 20512/week @ 2024-06-29 23639/week @ 2024-07-06 22567/week @ 2024-07-13 20150/week @ 2024-07-20

90,152 个月下载量
11 个crate中(9个直接) 使用

MIT/Apache

255KB
5.5K SLoC

cgroups-rs Build

Linux下管理控制组的本地Rust库

cgroups的v1和v2版本均受支持。

示例

使用构建器模式创建控制组



use cgroups_rs::*;
use cgroups_rs::cgroup_builder::*;

// Acquire a handle for the cgroup hierarchy.
let hier = cgroups_rs::hierarchies::auto();

// Use the builder pattern (see the documentation to create the control group)
//
// This creates a control group named "example" in the V1 hierarchy.
    let cg: Cgroup = CgroupBuilder::new("example")
        .cpu()
        .shares(85)
        .done()
        .build(hier);

// Now `cg` is a control group that gets 85% of the CPU time in relative to
// other control groups.

// Get a handle to the CPU controller.
let cpus: &cgroups_rs::cpu::CpuController = cg.controller_of().unwrap();
cpus.add_task(&CgroupPid::from(1234u64));

// [...]

// Finally, clean up and delete the control group.
cg.delete();

// Note that `Cgroup` does not implement `Drop` and therefore when the
// structure is dropped, the Cgroup will stay around. This is because, later
// you can then re-create the `Cgroup` using `load()`. We aren't too set on
// this behavior, so it might change in the feature. Rest assured, it will be a
// major version change.

免责声明

本crate采用

  • MIT许可证(见LICENSE-MIT);或
  • Apache 2.0许可证(见LICENSE-Apache-2.0),

任选其一。

请注意,本crate处于积极开发中,我们将使用语义版本控制,但在 0.0.* 阶段,对向后兼容性不提供任何保证。

无论如何,请经常查看,并感谢您花时间了解!

依赖

~4–5.5MB
~110K SLoC