Coder Social home page Coder Social logo

levex / cgroups-rs Goto Github PK

View Code? Open in Web Editor NEW
75.0 8.0 57.0 153 KB

Native Rust library for managing control groups under Linux

License: Other

Rust 99.29% Shell 0.71%
rust control-group cgroup linux resource-mangement controlgroup system-administration systemd

cgroups-rs's Introduction

No Longer Maintained

This repository is no longer actively maintained.

Several forks of cgroups-rs exist:

None of these forks are endorsed by the authors of this crate, and are listed for informational purposes only.


cgroups-rs Build

Native Rust library for managing control groups under Linux

Right now the crate only support the original, V1 hierarchy, however support is planned for the Unified hierarchy.

Examples

Create a control group using the builder pattern

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

// 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", &v1)
	.cpu()
		.shares(85)
		.done()
	.build();

// 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: &CpuController = cg.controller_of().unwrap();
cpus.add_task(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.

Disclaimer

This crate is licensed under:

  • MIT License (see LICENSE-MIT); or
  • Apache 2.0 License (see LICENSE-Apache-2.0),

at your option.

Please note that this crate is under heavy development, we will use sematic versioning, but during the 0.0.* phase, no guarantees are made about backwards compatibility.

Regardless, check back often and thanks for taking a look!

cgroups-rs's People

Contributors

levex avatar ordovicia avatar tecywiz121 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cgroups-rs's Issues

Status of the repository?

Hi,

Thank you for writing such a useful project!

Kata Containers wants to use cgroups-rs for the rust-agent subproject. However it seems that the cgroups-rs repository has not been updated for a long time and does not respond to issues and PRs.

So we took the liberty to fork it in Kata Containers organization to apply bugfixes and new features. If the repository comes back to normal maintenance, we'll be more than happy to contribute all the enhancements back. Thanks!

Systemd incompatibility ?

I can't seem to make it work on a Debian possibly because of Systemd.
On which systems has this lib been tested ?

Builder pattern for creating control groups

I've started working on an API that looks like this:

let cgroup: Cgroup = CgroupBuilder::new("hello", V1)
    .memory()
        .kernel_memory_limit(1024 * 1024)
        .memory_hard_limit(1024 * 1024)
        .done()
    .cpu()
        .shares(100)
        .done()
    .build();

Thoughts?

In particular, I'd prefer to leave out an API that adds a pid to the control group. That's racy and it might introduce subtle race conditions into applications depending on this crate. Instead, the API will likely include an include_command() build that starts the Command in the control group. This would be done via a trait ideally, so people can extend it.

Some question about blkio Cgroup

Hello everyone,I am a gree hand of Cgroup!About blkio Cgroup.I learned that the blkio Cgroup only controls the direct io of process.But,my question is that how the blkio Cgroup limit the iops of processes?How the blkio Cgroup caculate the iops of a process?How the blkio Cgroup collection the information about iops of processes?If I want to read the source code of blkio Cgroup and understand it,where is the location?I would be grateful if you could give me some suggestion!Thans a lot!

Force push to master

Our Cargo.lock file pointed to commit 675d59d since those changes weren't released yet.

That commit seems to have disappeared from the repository, possibly as a result of a rebase and force push.

While it definitely isn't required, I'd really appreciate avoiding force pushes to master. It makes git pull less painful, and we can pin unreleased commits.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.