Documentation ¶
Index ¶
- Variables
- func DestroyCgroup(path string) error
- func GetCgroupPathByPid(pid int, subsystem string) (string, error)
- func GetEnabledSubsystems() (map[string]int, error)
- func GetProcessCgroups(pid int) (map[string]string, error)
- func GetSubsystemMountpoint(subsystem string) (string, error)
- func IsCgroupsNotFoundError(err error) bool
- func IsMountpointError(err error) bool
- func IsNotInSubsystemError(err error) bool
- func IsUnsupportedError(err error) bool
- func NewCgroupsNotFoundError(pid int) error
- func NewMountpointError(subsystem string) error
- func NewNotInSubsystemError(pid int, subsystem string) error
- func NewUnsupportedError(subsystem string) error
- type Cgroup
- type CgroupsNotFoundError
- type Config
- type CpuGroup
- type CpuStats
- type CpuUsage
- type Manager
- type MountpointError
- type NotInSubsystemError
- type Stats
- type ThrottlingData
- type UnsupportedError
Constants ¶
This section is empty.
Variables ¶
var ( ErrCfsNotEnabled = errors.New("Make sure that CONFIG_CFS_BANDWIDTH option is enabled in your kernel") ErrRtNotEnabled = errors.New("Make sure that CONFIG_RT_GROUP_SCHED option is enabled in your kernel") )
var (
ErrCgroupRemoved = errors.New("Unable to continue. Control group already removed")
)
Functions ¶
func DestroyCgroup ¶
DestroyCgroup destroys the cgroup located on the given path.
func GetCgroupPathByPid ¶
GetCgroupPathByPid returns a path to the cgroup containing the specified pid.
func GetEnabledSubsystems ¶
GetEnabledSubsystems returns a map with all the subsystems supported by the kernel.
func GetProcessCgroups ¶
GetProcessCgroups returns a map with the all cgroup subsystems and their relative paths to which the specified pid belongs.
func GetSubsystemMountpoint ¶
GetSubsystemMountpoint returns a path where a given subsystem is mounted.
func IsCgroupsNotFoundError ¶
func IsMountpointError ¶
func IsNotInSubsystemError ¶
func IsUnsupportedError ¶
func NewCgroupsNotFoundError ¶
func NewMountpointError ¶
func NewNotInSubsystemError ¶
func NewUnsupportedError ¶
Types ¶
type Cgroup ¶
type Cgroup interface { // Sets the cgroup parameters represented by *Config variable Set(*Config) error // Gets the actual cgroup parameters and stores them to the pointer of *Config Get(*Config) error // Gets the cgroup stat information and store its to the pointer of *Stats GetStats(*Stats) error // Returns full path of the cgroup relative to the filesystem root GetPath() string }
Cgroup is an uniform interface for the cgroups.
func LookupCgroupByPid ¶
LookupCgroupByPid tries to find the group containing the specified pid.
If the specified subsystem is not supported by this package, an error of type *UnsupportedSubsystemError will be returned.
type CgroupsNotFoundError ¶
type CgroupsNotFoundError struct {
// contains filtered or unexported fields
}
func (*CgroupsNotFoundError) Error ¶
func (e *CgroupsNotFoundError) Error() string
type Config ¶
type Config struct { int64 `json:"cpu_shares"` // CPU hardcap limit (in usecs). Allowed cpu time in a given period. CpuQuota int64 `json:"cpu_quota"` // CPU period to be used for hardcapping (in usecs). CpuPeriod int64 `json:"cpu_period"` // How many time CPU will use in realtime scheduling (in usecs). CpuRtRuntime int64 `json:"cpu_rt_runtime"` // CPU period to be used for realtime scheduling (in usecs). CpuRtPeriod int64 `json:"cpu_rt_period"` }CpuShares
Config specifies parameters for the various subsystems.
type CpuGroup ¶
type CpuGroup struct {
// contains filtered or unexported fields
}
CpuGroup is an implementation of the common Cgroup interface.
type CpuStats ¶
type CpuStats struct { CpuUsage CpuUsage `json:"cpu_usage,omitempty"` ThrottlingData ThrottlingData `json:"throttling_data,omitempty"` }
CpuStats contains various CPU statistics and accounting information associated with a cgroup.
type CpuUsage ¶
type CpuUsage struct { // Total CPU time consumed (in nanoseconds). TotalUsage uint64 `json:"total_usage,omitempty"` // Total CPU time consumed per core (in nanoseconds). PercpuUsage []uint64 `json:"percpu_usage,omitempty"` // Time spent by tasks of the cgroup in kernel mode (in nanoseconds). UsageInKernelmode uint64 `json:"usage_in_kernelmode"` // Time spent by tasks of the cgroup in user mode (in nanoseconds). UsageInUsermode uint64 `json:"usage_in_usermode"` }
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is a wrapper around the several cgroups to more convenient using.
func LoadManager ¶
LoadManager tries to find all cgroup in which the specified pid is placed and returns a new Manager on success to manage them.
func NewManager ¶
NewManager creates a new cgroup for the specified pid in each of the included subsystems (determined using the /proc/cgroups file).
The function returns a new Manager object to manage the cgroup set.
type MountpointError ¶
type MountpointError struct {
// contains filtered or unexported fields
}
func (*MountpointError) Error ¶
func (e *MountpointError) Error() string
type NotInSubsystemError ¶
type NotInSubsystemError struct {
// contains filtered or unexported fields
}
func (*NotInSubsystemError) Error ¶
func (e *NotInSubsystemError) Error() string
type Stats ¶
type Stats struct {
CpuStats CpuStats `json:"cpu_stats,omitempty"`
}
Stats contains metrics and limits from each of the cgroup subsystems.
type ThrottlingData ¶
type ThrottlingData struct { // Number of periods with throttling active. Periods uint64 `json:"nr_periods,omitempty"` // Number of times when the tasks have been throttled. ThrottledPeriods uint64 `json:"nr_throttled,omitempty"` // Aggregate time when the tasks have been throttled (in nanoseconds). ThrottledTime uint64 `json:"throttled_time,omitempty"` }
type UnsupportedError ¶
type UnsupportedError struct {
Subsystem string
}
func (*UnsupportedError) Error ¶
func (e *UnsupportedError) Error() string