NewCGroups

package
v0.0.0-...-7685a06 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 30, 2021 License: GPL-3.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Attach

func Attach(pid string, path string) error

Attach pid to cgroups path

Types

type ControlProcSl

type ControlProcSl []*netlink.ProcMessage

func (*ControlProcSl) Attach

func (ctSl *ControlProcSl) Attach(path string) error

Attach pid to new cgroups

func (*ControlProcSl) CheckCtlProcExist

func (ctSl *ControlProcSl) CheckCtlProcExist(proc *netlink.ProcMessage) bool

check if proc already exist

func (*ControlProcSl) CheckCtrlPidExist

func (ctSl *ControlProcSl) CheckCtrlPidExist(ppid string) *netlink.ProcMessage

check if new proc`s parent proc exist

func (*ControlProcSl) Len

func (ctSl *ControlProcSl) Len() int

get len

func (*ControlProcSl) Release

func (ctSl *ControlProcSl) Release() error

Attach pid back to origin cgroup

type Controller

type Controller struct {
	// controller name
	Name define.Scope // main app global

	// Fuzzy Priority
	Priority define.Priority

	// control app exe path
	CtlPathSl []string

	// current control app message
	CtlProcMap map[string]ControlProcSl
	// contains filtered or unexported fields
}

source controller

func (*Controller) AddCtlAppPath

func (c *Controller) AddCtlAppPath(path string)

add control app path

func (*Controller) AddCtrlProc

func (c *Controller) AddCtrlProc(proc *netlink.ProcMessage) error

add current control proc

func (*Controller) CheckCtlPathSl

func (c *Controller) CheckCtlPathSl(path string) bool

check control app path exist

func (*Controller) CheckCtlProcExist

func (c *Controller) CheckCtlProcExist(proc *netlink.ProcMessage) bool

check if current control proc exist

func (*Controller) CheckCtrlPid

func (c *Controller) CheckCtrlPid(ppid string) *netlink.ProcMessage

check if new proc`s parent proc exist

func (*Controller) ClearCtlAppPath

func (c *Controller) ClearCtlAppPath()

clear app ctl path

func (*Controller) DelCtlAppPath

func (c *Controller) DelCtlAppPath(path string)

del app path

func (*Controller) DelCtlProc

func (c *Controller) DelCtlProc(proc *netlink.ProcMessage) error

delete current control proc

func (*Controller) GetCGroupPath

func (c *Controller) GetCGroupPath() string

/sys/fs/cgroup/unified/App.slice

func (*Controller) GetControlPath

func (c *Controller) GetControlPath() string

/sys/fs/cgroup/unified/App.slice/cgroup.procs

func (*Controller) GetName

func (c *Controller) GetName() string

App.slice

func (*Controller) MoveIn

func (c *Controller) MoveIn(path string, inCtSl ControlProcSl) error

move in control procs

func (*Controller) MoveOut

func (c *Controller) MoveOut(path string) ControlProcSl

move out control procs

func (*Controller) MoveToController

func (c *Controller) MoveToController(controller *Controller) error

move to control procs

func (*Controller) ReleaseAll

func (c *Controller) ReleaseAll() error

release all proc from controller, that may happen when stop controller

func (*Controller) ReleaseToManager

func (c *Controller) ReleaseToManager(path string) error

move now proc to lower controller or to default cgroups

func (*Controller) UpdateFromManager

func (c *Controller) UpdateFromManager(path string) error

move lower priority proc in

func (*Controller) UpdateFromManagerAll

func (c *Controller) UpdateFromManagerAll() error

move lower priority proc in

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

func NewManager

func NewManager() *Manager

create manager

func (*Manager) CheckControllerExist

func (m *Manager) CheckControllerExist(name define.Scope, priority define.Priority) bool

check if name controller already exist

func (*Manager) CreatePriorityController

func (m *Manager) CreatePriorityController(name define.Scope, uid int, gid int, priority define.Priority) (*Controller, error)

create controller handler

func (*Manager) GetControllerByCtlPath

func (m *Manager) GetControllerByCtlPath(path string) *Controller

get controller by control app path

func (*Manager) GetControllerByCtrlByPPid

func (m *Manager) GetControllerByCtrlByPPid(ppid string) *Controller

get controller by control pid

func (*Manager) GetControllerCount

func (m *Manager) GetControllerCount() int

get controller count

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL