Documentation
      ¶
    
    
  
    
      Index ¶
- Constants
 - Variables
 - func GetSystemCPUUsage() (uint64, error)
 - func GetUserConnection(uid int) (*systemdDbus.Conn, error)
 - func IsCgroup2UnifiedMode() (bool, error)
 - func UserOwnsCurrentSystemdCgroup() (bool, error)
 - type BlkIOEntry
 - type BlkioMetrics
 - type CPUMetrics
 - type CPUUsage
 - 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() (*Metrics, error)
 - func (c *CgroupControl) Update(resources *spec.LinuxResources) error
 
- type MemoryMetrics
 - type MemoryUsage
 - type Metrics
 - type PidsMetrics
 
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 environmen ErrCgroupV1Rootless = errors.New("no support for CGroups V1 in rootless environments") )
Functions ¶
func GetSystemCPUUsage ¶
GetSystemCPUUsage returns the system usage for all the cgroups
func GetUserConnection ¶
func GetUserConnection(uid int) (*systemdDbus.Conn, error)
GetUserConnection returns an user connection to D-BUS
func IsCgroup2UnifiedMode ¶
IsCgroup2UnifiedMode returns whether we are running in cgroup 2 cgroup2 mode.
func UserOwnsCurrentSystemdCgroup ¶
UserOwnsCurrentSystemdCgroup checks whether the current EUID owns the current cgroup.
Types ¶
type BlkIOEntry ¶
BlkIOEntry describes an entry in the blkio stats
type BlkioMetrics ¶
type BlkioMetrics struct {
	IoServiceBytesRecursive []BlkIOEntry
}
    BlkioMetrics keeps usage stats for the blkio cgroup controller
type CPUMetrics ¶
type CPUMetrics struct {
	Usage CPUUsage
}
    CPUMetrics keeps stats for the CPU usage
type CgroupControl ¶
type CgroupControl struct {
	// contains filtered or unexported fields
}
    CgroupControl controls a cgroup hierarchy
func New ¶
func New(path string, resources *spec.LinuxResources) (*CgroupControl, error)
New creates a new cgroup control
func NewSystemd ¶
func NewSystemd(path string) (*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.
func (*CgroupControl) Stat ¶
func (c *CgroupControl) Stat() (*Metrics, error)
Stat returns usage statistics for the cgroup
func (*CgroupControl) Update ¶
func (c *CgroupControl) Update(resources *spec.LinuxResources) error
Update updates the cgroups
type MemoryMetrics ¶
type MemoryMetrics struct {
	Usage MemoryUsage
}
    MemoryMetrics keeps usage stats for the memory cgroup controller
type MemoryUsage ¶
MemoryUsage keeps stats for the memory usage
type Metrics ¶
type Metrics struct {
	CPU    CPUMetrics
	Blkio  BlkioMetrics
	Memory MemoryMetrics
	Pids   PidsMetrics
}
    Metrics keeps usage stats for the cgroup controllers
type PidsMetrics ¶
type PidsMetrics struct {
	Current uint64
}
    PidsMetrics keeps usage stats for the pids cgroup controller