cgroups

package
v2.2.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2015 License: Apache-2.0 Imports: 12 Imported by: 1,516

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnterPid added in v1.2.0

func EnterPid(cgroupPaths map[string]string, pid int) error

func FindCgroupMountpointDir

func FindCgroupMountpointDir() (string, error)

func GetAllSubsystems added in v1.0.1

func GetAllSubsystems() ([]string, error)

Returns all the cgroup subsystems supported by the kernel

func GetHugePageSize

func GetHugePageSize() ([]string, error)

func GetInitCgroupDir

func GetInitCgroupDir(subsystem string) (string, error)

func GetThisCgroupDir

func GetThisCgroupDir(subsystem string) (string, error)

Returns the relative path to the cgroup docker is running in.

func IsNotFound added in v1.2.0

func IsNotFound(err error) bool

func NewNotFoundError added in v1.2.0

func NewNotFoundError(sub string) error

func ParseCgroupFile added in v1.4.0

func ParseCgroupFile(subsystem string, r io.Reader) (string, error)

func PathExists

func PathExists(path string) bool

func ReadProcsFile

func ReadProcsFile(dir string) ([]int, error)

func RemovePaths added in v1.4.0

func RemovePaths(paths map[string]string) (err error)

RemovePaths iterates over the provided paths removing them. We trying to remove all paths five times with increasing delay between tries. If after all there are not removed cgroups - appropriate error will be returned.

Types

type BlkioStatEntry

type BlkioStatEntry struct {
	Major uint64 `json:"major,omitempty"`
	Minor uint64 `json:"minor,omitempty"`
	Op    string `json:"op,omitempty"`
	Value uint64 `json:"value,omitempty"`
}

type BlkioStats

type BlkioStats struct {
	// number of bytes tranferred to and from the block device
	IoServiceBytesRecursive []BlkioStatEntry `json:"io_service_bytes_recursive,omitempty"`
	IoServicedRecursive     []BlkioStatEntry `json:"io_serviced_recursive,omitempty"`
	IoQueuedRecursive       []BlkioStatEntry `json:"io_queue_recursive,omitempty"`
	IoServiceTimeRecursive  []BlkioStatEntry `json:"io_service_time_recursive,omitempty"`
	IoWaitTimeRecursive     []BlkioStatEntry `json:"io_wait_time_recursive,omitempty"`
	IoMergedRecursive       []BlkioStatEntry `json:"io_merged_recursive,omitempty"`
	IoTimeRecursive         []BlkioStatEntry `json:"io_time_recursive,omitempty"`
	SectorsRecursive        []BlkioStatEntry `json:"sectors_recursive,omitempty"`
}

type CpuStats

type CpuStats struct {
	CpuUsage       CpuUsage       `json:"cpu_usage,omitempty"`
	ThrottlingData ThrottlingData `json:"throttling_data,omitempty"`
}

type CpuUsage

type CpuUsage struct {
	// Total CPU time consumed.
	// Units: nanoseconds.
	TotalUsage uint64 `json:"total_usage,omitempty"`
	// Total CPU time consumed per core.
	// Units: nanoseconds.
	PercpuUsage []uint64 `json:"percpu_usage,omitempty"`
	// Time spent by tasks of the cgroup in kernel mode.
	// Units: nanoseconds.
	UsageInKernelmode uint64 `json:"usage_in_kernelmode"`
	// Time spent by tasks of the cgroup in user mode.
	// Units: nanoseconds.
	UsageInUsermode uint64 `json:"usage_in_usermode"`
}

All CPU stats are aggregate since container inception.

type HugetlbStats

type HugetlbStats struct {
	// current res_counter usage for hugetlb
	Usage uint64 `json:"usage,omitempty"`
	// maximum usage ever recorded.
	MaxUsage uint64 `json:"max_usage,omitempty"`
	// number of times htgetlb usage allocation failure.
	Failcnt uint64 `json:"failcnt"`
}

type Manager

type Manager interface {
	// Apply cgroup configuration to the process with the specified pid
	Apply(pid int) error

	// Returns the PIDs inside the cgroup set
	GetPids() ([]int, error)

	// Returns statistics for the cgroup set
	GetStats() (*Stats, error)

	// Toggles the freezer cgroup according with specified state
	Freeze(state configs.FreezerState) error

	// Destroys the cgroup set
	Destroy() error

	// Returns cgroup paths to save in a state file and to be able to
	// restore the object later.
	GetPaths() map[string]string

	// Set the cgroup as configured.
	Set(container *configs.Config) error
}

type MemoryData

type MemoryData struct {
	Usage    uint64 `json:"usage,omitempty"`
	MaxUsage uint64 `json:"max_usage,omitempty"`
	Failcnt  uint64 `json:"failcnt"`
}

type MemoryStats

type MemoryStats struct {
	// memory used for cache
	Cache uint64 `json:"cache,omitempty"`
	// usage of memory
	Usage MemoryData `json:"usage,omitempty"`
	// usage of memory + swap
	SwapUsage MemoryData `json:"swap_usage,omitempty"`
	// usafe of kernel memory
	KernelUsage MemoryData        `json:"kernel_usage,omitempty"`
	Stats       map[string]uint64 `json:"stats,omitempty"`
}

type Mount added in v1.0.1

type Mount struct {
	Mountpoint string
	Subsystems []string
}

func GetCgroupMounts added in v1.0.1

func GetCgroupMounts() ([]Mount, error)

func (Mount) GetThisCgroupDir added in v1.0.1

func (m Mount) GetThisCgroupDir() (string, error)

type NotFoundError added in v1.2.0

type NotFoundError struct {
	Subsystem string
}

func (*NotFoundError) Error added in v1.2.0

func (e *NotFoundError) Error() string

type Stats

type Stats struct {
	CpuStats    CpuStats    `json:"cpu_stats,omitempty"`
	MemoryStats MemoryStats `json:"memory_stats,omitempty"`
	BlkioStats  BlkioStats  `json:"blkio_stats,omitempty"`
	// the map is in the format "size of hugepage: stats of the hugepage"
	HugetlbStats map[string]HugetlbStats `json:"hugetlb_stats,omitempty"`
}

func NewStats

func NewStats() *Stats

type ThrottlingData

type ThrottlingData struct {
	// Number of periods with throttling active
	Periods uint64 `json:"periods,omitempty"`
	// Number of periods when the container hit its throttling limit.
	ThrottledPeriods uint64 `json:"throttled_periods,omitempty"`
	// Aggregate time the container was throttled for in nanoseconds.
	ThrottledTime uint64 `json:"throttled_time,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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