pub struct Subsystem { /* private fields */ }Expand description
Handler of a Cpuacct subsystem.
Implementations§
Source§impl Subsystem
impl Subsystem
Sourcepub fn stat(&self) -> Result<Stat>
pub fn stat(&self) -> Result<Stat>
Reads the statistics about how much CPU time is consumed by this cgroup (in USER_HZ unit) from cpuacct.stat file. The CPU time is further divided into user and system times.
See the kernel’s documentation for more information about this field.
§Errors
Returns an error if failed to read and parse cpuacct.stat file of this cgroup.
§Examples
use std::path::PathBuf;
use controlgroup::v1::{cpuacct, Cgroup, CgroupPath, SubsystemKind};
let cgroup = cpuacct::Subsystem::new(
CgroupPath::new(SubsystemKind::Cpuacct, PathBuf::from("students/charlie")));
let stat = cgroup.stat()?;Sourcepub fn usage(&self) -> Result<u64>
pub fn usage(&self) -> Result<u64>
Reads the total CPU time consumed by this cgroup (in nanoseconds) from cpuacct.usage file.
See the kernel’s documentation for more information about this field.
§Errors
Returns an error if failed to read and parse cpuacct.usage file of this cgroup.
§Examples
use std::path::PathBuf;
use controlgroup::v1::{cpuacct, Cgroup, CgroupPath, SubsystemKind};
let cgroup = cpuacct::Subsystem::new(
CgroupPath::new(SubsystemKind::Cpuacct, PathBuf::from("students/charlie")));
let usage = cgroup.usage()?;Sourcepub fn usage_all(&self) -> Result<Vec<Stat>>
pub fn usage_all(&self) -> Result<Vec<Stat>>
Reads the per-CPU total CPU time consumed by this cgroup (in nanoseconds) from cpuacct.usage_all file. The CPU time is further divided into user and system times.
See the kernel’s documentation for more information about this field.
§Errors
Returns an error if failed to read and parse cpuacct.usage_all file of this cgroup.
§Examples
use std::path::PathBuf;
use controlgroup::v1::{cpuacct, Cgroup, CgroupPath, SubsystemKind};
let cgroup = cpuacct::Subsystem::new(
CgroupPath::new(SubsystemKind::Cpuacct, PathBuf::from("students/charlie")));
let usage_all = cgroup.usage_all()?;Sourcepub fn usage_percpu(&self) -> Result<Vec<u64>>
pub fn usage_percpu(&self) -> Result<Vec<u64>>
Reads the per-CPU total CPU times consumed by this cgroup (in nanoseconds) from cpuacct.usage_percpu file.
See the kernel’s documentation for more information about this field.
§Errors
Returns an error if failed to read and parse cpuacct.usage_percpu file of this cgroup.
§Examples
use std::path::PathBuf;
use controlgroup::v1::{cpuacct, Cgroup, CgroupPath, SubsystemKind};
let cgroup = cpuacct::Subsystem::new(
CgroupPath::new(SubsystemKind::Cpuacct, PathBuf::from("students/charlie")));
let usage_percpu = cgroup.usage_percpu()?;Sourcepub fn usage_percpu_sys(&self) -> Result<Vec<u64>>
pub fn usage_percpu_sys(&self) -> Result<Vec<u64>>
Reads the per-CPU total CPU times consumed by this cgroup
in the system (kernel) mode (in nanoseconds) from cpuacct.usage_percpu_sys file.
See the kernel’s documentation for more information about this field.
§Errors
Returns an error if failed to read and parse cpuacct.usage_percpu_sys file of this cgroup.
§Examples
use std::path::PathBuf;
use controlgroup::v1::{cpuacct, Cgroup, CgroupPath, SubsystemKind};
let cgroup = cpuacct::Subsystem::new(
CgroupPath::new(SubsystemKind::Cpuacct, PathBuf::from("students/charlie")));
let usage_percpu_sys = cgroup.usage_percpu_sys()?;Sourcepub fn usage_percpu_user(&self) -> Result<Vec<u64>>
pub fn usage_percpu_user(&self) -> Result<Vec<u64>>
Reads the per-CPU total CPU times consumed by this cgroup in the user mode (in nanoseconds) from cpuacct.usage_percpu_user file.
See the kernel’s documentation for more information about this field.
§Errors
Returns an error if failed to read and parse cpuacct.usage_percpu_user file of this cgroup.
§Examples
use std::path::PathBuf;
use controlgroup::v1::{cpuacct, Cgroup, CgroupPath, SubsystemKind};
let cgroup = cpuacct::Subsystem::new(
CgroupPath::new(SubsystemKind::Cpuacct, PathBuf::from("students/charlie")));
let usage_percpu_user = cgroup.usage_percpu_user()?;Sourcepub fn usage_sys(&self) -> Result<u64>
pub fn usage_sys(&self) -> Result<u64>
Reads the total CPU time consumed by this cgroup in the system (kernel) mode (in nanoseconds) from cpuacct.usage_sys file.
See the kernel’s documentation for more information about this field.
§Errors
Returns an error if failed to read and parse cpuacct.usage_sys file of this cgroup.
§Examples
use std::path::PathBuf;
use controlgroup::v1::{cpuacct, Cgroup, CgroupPath, SubsystemKind};
let cgroup = cpuacct::Subsystem::new(
CgroupPath::new(SubsystemKind::Cpuacct, PathBuf::from("students/charlie")));
let usage_sys = cgroup.usage_sys()?;Sourcepub fn usage_user(&self) -> Result<u64>
pub fn usage_user(&self) -> Result<u64>
Reads the total CPU time consumed by this cgroup in the user mode (in nanoseconds) from cpuacct.usage_user file.
See the kernel’s documentation for more information about this field.
§Errors
Returns an error if failed to read and parse cpuacct.usage_user file of this cgroup.
§Examples
use std::path::PathBuf;
use controlgroup::v1::{cpuacct, Cgroup, CgroupPath, SubsystemKind};
let cgroup = cpuacct::Subsystem::new(
CgroupPath::new(SubsystemKind::Cpuacct, PathBuf::from("students/charlie")));
let usage_user = cgroup.usage_user()?;Sourcepub fn reset(&mut self) -> Result<()>
pub fn reset(&mut self) -> Result<()>
Resets the accounted CPU time of this cgroup by writing to cpuacct.usage file.
§Errors
Returns an error if failed to write to cpuacct.usage file of this cgroup.
§Examples
use std::path::PathBuf;
use controlgroup::v1::{cpuacct, Cgroup, CgroupPath, SubsystemKind};
let mut cgroup = cpuacct::Subsystem::new(
CgroupPath::new(SubsystemKind::Cpuacct, PathBuf::from("students/charlie")));
cgroup.reset()?;Trait Implementations§
Source§impl Cgroup for Subsystem
impl Cgroup for Subsystem
Source§fn apply(&mut self, _resources: &Resources) -> Result<()>
fn apply(&mut self, _resources: &Resources) -> Result<()>
Does nothing as a Cpuacct subsystem is basically read-only.
Source§fn new(path: CgroupPath) -> Self
fn new(path: CgroupPath) -> Self
Source§fn subsystem(&self) -> SubsystemKind
fn subsystem(&self) -> SubsystemKind
Source§fn is_root(&self) -> bool
fn is_root(&self) -> bool
Source§fn root_cgroup(&self) -> Box<Self>
fn root_cgroup(&self) -> Box<Self>
Source§fn tasks(&self) -> Result<Vec<Pid>>
fn tasks(&self) -> Result<Vec<Pid>>
tasks file. The resulting tasks are represented by their thread IDs. Read moreSource§fn add_task(&mut self, pid: impl Into<Pid>) -> Result<()>
fn add_task(&mut self, pid: impl Into<Pid>) -> Result<()>
tasks file. Read moreSource§fn remove_task(&mut self, pid: impl Into<Pid>) -> Result<()>
fn remove_task(&mut self, pid: impl Into<Pid>) -> Result<()>
tasks file of the root cgroup. Read moreSource§fn procs(&self) -> Result<Vec<Pid>>
fn procs(&self) -> Result<Vec<Pid>>
cgroup.procs file. The resulting tasks are represented by their PIDs. Read moreSource§fn add_proc(&mut self, pid: impl Into<Pid>) -> Result<()>
fn add_proc(&mut self, pid: impl Into<Pid>) -> Result<()>
cgroup.procs file. Read moreSource§fn remove_proc(&mut self, pid: impl Into<Pid>) -> Result<()>
fn remove_proc(&mut self, pid: impl Into<Pid>) -> Result<()>
cgroup.procs file of the root cgroup. Read moreSource§fn notify_on_release(&self) -> Result<bool>
fn notify_on_release(&self) -> Result<bool>
release_agent file
when this cgroup no longer has any task, from notify_on_release file. Read moreSource§fn set_notify_on_release(&mut self, enable: bool) -> Result<()>
fn set_notify_on_release(&mut self, enable: bool) -> Result<()>
release_agent file
when this cgroup no longer has any task, by writing to notify_on_release file. Read moreSource§fn release_agent(&self) -> Result<String>
fn release_agent(&self) -> Result<String>
release_agent file. Read moreSource§fn set_release_agent(&mut self, agent_path: impl AsRef<[u8]>) -> Result<()>
fn set_release_agent(&mut self, agent_path: impl AsRef<[u8]>) -> Result<()>
release_agent file. Read moreSource§fn sane_behavior(&self) -> Result<bool>
fn sane_behavior(&self) -> Result<bool>
cgroup.sane_behavior file. Read more