Documentation
¶
Overview ¶
Package cgroup provices builder to create multiple different cgroup-v1 sub groups under systemd defined path (i.e. /sys/fs/cgroup).
current avaliable cgroups are cpuacct, memory, pids not avaliable: cpu, cpuset, devices, freezer, net_cls, blkio, perf_event, net_prio, huge_tlb, rdma
Index ¶
- Variables
- func CreateSubCGroupPath(group, prefix string) (string, error)
- func EnsureDirExists(path string) error
- func GetAllSubCgroup() (map[string]bool, error)
- type Builder
- type CGroup
- func (c *CGroup) AddProc(pid int) error
- func (c *CGroup) CpuacctUsage() (uint64, error)
- func (c *CGroup) Destroy() error
- func (c *CGroup) FindMemoryStatProperty(prop string) (uint64, error)
- func (c *CGroup) MemoryMaxUsageInBytes() (uint64, error)
- func (c *CGroup) SetCpuacctUsage(i uint64) error
- func (c *CGroup) SetMemoryLimitInBytes(i uint64) error
- func (c *CGroup) SetMemoryMaxUsageInBytes(i uint64) error
- func (c *CGroup) SetPidsMax(i uint64) error
- type SubCGroup
Constants ¶
This section is empty.
Variables ¶
var ErrNotInitialized = errors.New("cgroup was not initialized")
ErrNotInitialized returned when trying to read from not initialized cgroup
Functions ¶
func CreateSubCGroupPath ¶
CreateSubCGroupPath creates path for sub-cgroup
func EnsureDirExists ¶
EnsureDirExists creates dir if not exists
func GetAllSubCgroup ¶
GetAllSubCgroup reads /proc/cgroups and get all avaliable sub-cgroup as set
Types ¶
type Builder ¶
Builder builds cgroup directories avaliable: cpuacct, memory, pids
func NewBuilder ¶
NewBuilder return a dumb builder without any sub-cgroup
func (*Builder) FilterByEnv ¶
FilterByEnv reads /proc/cgroups and filter out non-exists ones
func (*Builder) WithCPUAcct ¶
WithCPUAcct includes cpuacct cgroup
func (*Builder) WithMemory ¶
WithMemory includes memory cgroup
type CGroup ¶
type CGroup struct {
// contains filtered or unexported fields
}
CGroup is the combination of sub-cgroups
func (*CGroup) CpuacctUsage ¶
CpuacctUsage read cpuacct.usage in ns
func (*CGroup) Destroy ¶
Destroy removes dir for sub-cggroup, errors are ignored if remove one failed
func (*CGroup) FindMemoryStatProperty ¶ added in v0.1.3
FindMemoryStatProperty find certain property from memory.stat
func (*CGroup) MemoryMaxUsageInBytes ¶
MemoryMaxUsageInBytes read memory.max_usage_in_bytes
func (*CGroup) SetCpuacctUsage ¶ added in v0.1.2
SetCpuacctUsage write cpuacct.usage in ns
func (*CGroup) SetMemoryLimitInBytes ¶
SetMemoryLimitInBytes write memory.limit_in_bytes
func (*CGroup) SetMemoryMaxUsageInBytes ¶ added in v0.1.2
SetMemoryMaxUsageInBytes write cpuacct.usage in ns
type SubCGroup ¶
type SubCGroup struct {
// contains filtered or unexported fields
}
SubCGroup is the sub-cgroup
func (*SubCGroup) ReadFile ¶ added in v0.1.3
ReadFile reads cgroup file and handles potential EINTR error while read to the slow device (cgroup)