Documentation ¶
Index ¶
- Constants
- Variables
- func AvailableControllers(exclude map[string]controllerHandler, cgroup2 bool) ([]string, error)
- func BlkioFiles(cgroupPath string) (wtFile, wtDevFile string)
- func GetCgroupProcess(pid int) (string, error)
- func GetOwnCgroup() (string, error)
- func GetOwnCgroupDisallowRoot() (string, error)
- func IsCgroup2UnifiedMode() (bool, error)
- func MaybeMoveToSubCgroup() error
- func MoveUnderCgroup(cgroup, subtree string, processes []uint32) error
- func MoveUnderCgroupSubtree(subtree string) error
- func OpenFile(dir, file string, flags int) (*os.File, error)
- func ReadFile(dir, file string) (string, error)
- func SetBlkioThrottle(res *configs.Resources, cgroupPath string) error
- func SystemCPUUsage() (uint64, error)
- func UserConnection(uid int) (*systemdDbus.Conn, error)
- func UserOwnsCurrentSystemdCgroup() (bool, error)
- func WriteFile(dir, file, data string) error
- type BlkioDev
- type CgroupControl
- func (c *CgroupControl) AddPid(pid int) error
- func (c *CgroupControl) CreateSystemdUnit(path string) error
- func (c *CgroupControl) CreateSystemdUserUnit(path string, uid int) error
- func (c *CgroupControl) Delete() error
- func (c *CgroupControl) DeleteByPath(path string) error
- func (c *CgroupControl) DeleteByPathConn(path string, conn *systemdDbus.Conn) error
- func (c *CgroupControl) Stat() (*cgroups.Stats, error)
- func (c *CgroupControl) Update(resources *configs.Resources) error
Constants ¶
const ( // CPU is the cpu controller CPU = "cpu" // CPUAcct is the cpuacct controller CPUAcct = "cpuacct" // CPUset is the cpuset controller CPUset = "cpuset" // Memory is the memory controller Memory = "memory" // Pids is the pids controller Pids = "pids" // Blkio is the blkio controller Blkio = "blkio" )
Variables ¶
var ( // ErrCgroupDeleted means the cgroup was deleted ErrCgroupDeleted = errors.New("cgroup deleted") // ErrCgroupV1Rootless means the cgroup v1 were attempted to be used in rootless environment ErrCgroupV1Rootless = errors.New("no support for CGroups V1 in rootless environments") ErrStatCgroup = errors.New("no cgroup available for gathering user statistics") )
var TestMode bool
Functions ¶
func AvailableControllers ¶ added in v0.57.0
AvailableControllers get string:bool map of all the available controllers
func BlkioFiles ¶ added in v0.57.0
BlkioFiles gets the proper files for blkio weights
func GetCgroupProcess ¶ added in v0.58.0
GetCgroupProcess returns the cgroup for the specified process process.
func GetOwnCgroup ¶ added in v0.58.0
GetOwnCgroup returns the cgroup for the current process.
func GetOwnCgroupDisallowRoot ¶ added in v0.58.0
func IsCgroup2UnifiedMode ¶
IsCgroup2UnifiedMode returns whether we are running in cgroup 2 cgroup2 mode.
func MaybeMoveToSubCgroup ¶ added in v0.58.0
func MaybeMoveToSubCgroup() error
MaybeMoveToSubCgroup moves the current process in a sub cgroup when it is running in the root cgroup on a system that uses cgroupv2.
func MoveUnderCgroup ¶ added in v0.58.0
MoveUnderCgroup moves a group of processes to a new cgroup. If cgroup is the empty string, then the current calling process cgroup is used. If processes is empty, then the processes from the current cgroup are moved.
func MoveUnderCgroupSubtree ¶ added in v0.58.0
MoveUnderCgroupSubtree moves the PID under a cgroup subtree.
func ReadFile ¶ added in v0.49.0
ReadFile reads from a cgroup file, opening it with the read only flag
func SetBlkioThrottle ¶ added in v0.49.0
SetBlkioThrottle sets the throttle limits for the cgroup
func SystemCPUUsage ¶ added in v0.57.0
SystemCPUUsage returns the system usage for all the cgroups
func UserConnection ¶ added in v0.57.0
func UserConnection(uid int) (*systemdDbus.Conn, error)
UserConnection returns an user connection to D-BUS
func UserOwnsCurrentSystemdCgroup ¶
UserOwnsCurrentSystemdCgroup checks whether the current EUID owns the current cgroup.
Types ¶
type CgroupControl ¶
type CgroupControl struct {
// contains filtered or unexported fields
}
CgroupControl controls a cgroup hierarchy
func New ¶
func New(path string, resources *configs.Resources) (*CgroupControl, error)
New creates a new cgroup control
func NewSystemd ¶
func NewSystemd(path string, resources *configs.Resources) (*CgroupControl, error)
NewSystemd creates a new cgroup control
func (*CgroupControl) AddPid ¶
func (c *CgroupControl) AddPid(pid int) error
AddPid moves the specified pid to the cgroup
func (*CgroupControl) CreateSystemdUnit ¶
func (c *CgroupControl) CreateSystemdUnit(path string) error
CreateSystemdUnit creates the systemd cgroup
func (*CgroupControl) CreateSystemdUserUnit ¶
func (c *CgroupControl) CreateSystemdUserUnit(path string, uid int) error
CreateSystemdUserUnit creates the systemd cgroup for the specified user
func (*CgroupControl) DeleteByPath ¶
func (c *CgroupControl) DeleteByPath(path string) error
DeleteByPath deletes the specified cgroup path
func (*CgroupControl) DeleteByPathConn ¶
func (c *CgroupControl) DeleteByPathConn(path string, conn *systemdDbus.Conn) error
DeleteByPathConn deletes the specified cgroup path using the specified dbus connection if needed.