docker

package
v0.99.32 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2017 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDockerNotAvailable = errors.New("docker not available")
)
View Source
var (
	ErrMissingTarget = errors.New("Missing cgroup target")
)

Functions

func CgroupsForPids

func CgroupsForPids(pids []int32) (map[string]*ContainerCgroup, error)

CgroupsForPids returns ContainerCgroup for every container that's in a Cgroup. We return as a map[containerID]Cgroup for easy look-up.

func ContainersByPID

func ContainersByPID(pids []int32) (map[int32]*Container, error)

Generates a mapping of PIDs to container metadata. Optimized to limit the number of syscalls for each PID for just enough to get the data we need.

Types

type CgroupMemStat

type CgroupMemStat struct {
	ContainerID             string
	Cache                   uint64
	RSS                     uint64
	RSSHuge                 uint64
	MappedFile              uint64
	Pgpgin                  uint64
	Pgpgout                 uint64
	Pgfault                 uint64
	Pgmajfault              uint64
	InactiveAnon            uint64
	ActiveAnon              uint64
	InactiveFile            uint64
	ActiveFile              uint64
	Unevictable             uint64
	HierarchicalMemoryLimit uint64
	TotalCache              uint64
	TotalRSS                uint64
	TotalRSSHuge            uint64
	TotalMappedFile         uint64
	TotalPgpgIn             uint64
	TotalPgpgOut            uint64
	TotalPgFault            uint64
	TotalPgMajFault         uint64
	TotalInactiveAnon       uint64
	TotalActiveAnon         uint64
	TotalInactiveFile       uint64
	TotalActiveFile         uint64
	TotalUnevictable        uint64
	MemUsageInBytes         uint64
	MemMaxUsageInBytes      uint64
	MemLimitInBytes         uint64
	MemFailCnt              uint64
}

type CgroupTimesStat

type CgroupTimesStat struct {
	ContainerID string
	System      float64
	User        float64
}

type Container

type Container struct {
	Type     string
	ID       string
	Name     string
	Image    string
	ImageID  string
	Status   string
	CPULimit float64
	MemLimit uint64
}

func GetDockerContainers

func GetDockerContainers() ([]*Container, error)

GetDockerContainers returns a list of Docker info for active containers using the Docker API. This requires certain permission.

type ContainerCgroup

type ContainerCgroup struct {
	ContainerID string
	Pids        []int32
	Paths       map[string]string
	Mounts      map[string]string
}

func CGroupForPid

func CGroupForPid(pid int32) (*ContainerCgroup, error)

CGroup for pid returns a ContainerCgroup for a single pid

func (ContainerCgroup) CPU

CPU returns the CPU status for this cgroup instance

func (ContainerCgroup) CPULimit

func (c ContainerCgroup) CPULimit() (float64, error)

CPULimit would show CPU limit for this cgroup. It does so by checking the cpu period and cpu quota config if a user does this:

docker run --cpus='0.5' ubuntu:latest

we should return 50% for that container

func (ContainerCgroup) Mem

func (c ContainerCgroup) Mem() (*CgroupMemStat, error)

Jump to

Keyboard shortcuts

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