mirror of
https://github.com/mii443/izoli.git
synced 2025-08-22 16:05:40 +00:00
add get cpu.max
This commit is contained in:
@ -15,6 +15,7 @@ fn main() {
|
|||||||
println!("{:?}", cgroup.get_stat());
|
println!("{:?}", cgroup.get_stat());
|
||||||
println!("{:?}", cgroup.get_max_depth());
|
println!("{:?}", cgroup.get_max_depth());
|
||||||
println!("{:?}", cgroup.get_max_descendants());
|
println!("{:?}", cgroup.get_max_descendants());
|
||||||
|
println!("{:?}", cgroup.get_cpu_max());
|
||||||
|
|
||||||
cgroup
|
cgroup
|
||||||
.add_subtree_control(cgroup.get_controllers().unwrap())
|
.add_subtree_control(cgroup.get_controllers().unwrap())
|
||||||
|
@ -6,7 +6,10 @@ use std::{
|
|||||||
str::FromStr,
|
str::FromStr,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{cgroup_stat::CGroupStat, controller::Controller, limit_value::CGroupLimitValue};
|
use super::{
|
||||||
|
cgroup_stat::CGroupStat, controller::Controller, cpu_limit::CpuLimit,
|
||||||
|
limit_value::CGroupLimitValue,
|
||||||
|
};
|
||||||
|
|
||||||
pub struct CGroup {
|
pub struct CGroup {
|
||||||
pub path: PathBuf,
|
pub path: PathBuf,
|
||||||
@ -167,6 +170,14 @@ impl CGroup {
|
|||||||
self.write_list("cgroup.threads", threads)
|
self.write_list("cgroup.threads", threads)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cpu read
|
||||||
|
|
||||||
|
pub fn get_cpu_max(&self) -> Result<CpuLimit, std::io::Error> {
|
||||||
|
let max = self.read("cpu.max")?;
|
||||||
|
|
||||||
|
Ok(CpuLimit::from_str(&max).unwrap())
|
||||||
|
}
|
||||||
|
|
||||||
fn write_value<T>(&self, name: &str, value: T) -> Result<(), std::io::Error>
|
fn write_value<T>(&self, name: &str, value: T) -> Result<(), std::io::Error>
|
||||||
where
|
where
|
||||||
T: fmt::Display,
|
T: fmt::Display,
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
pub mod cgroup;
|
pub mod cgroup;
|
||||||
pub mod cgroup_stat;
|
pub mod cgroup_stat;
|
||||||
pub mod controller;
|
pub mod controller;
|
||||||
|
pub mod cpu_limit;
|
||||||
pub mod limit_value;
|
pub mod limit_value;
|
||||||
|
Reference in New Issue
Block a user