package container

import "github.com/google/cadvisor/container"

Package container defines types for sub-container events and also defines an interface for container operation handlers.

Index

Functions

func ClearContainerHandlerFactories

func ClearContainerHandlerFactories()

Clear the known factories.

func DebugInfo

func DebugInfo() map[string][]string

func HasFactories

func HasFactories() bool

Returns whether there are any container handler factories registered.

func RegisterContainerHandlerFactory

func RegisterContainerHandlerFactory(factory ContainerHandlerFactory, watchTypes []watcher.ContainerWatchSource)

Register a ContainerHandlerFactory. These should be registered from least general to most general as they will be asked in order whether they can handle a particular container.

Types

type ContainerHandler

type ContainerHandler interface {
	// Returns the ContainerReference
	ContainerReference() (info.ContainerReference, error)

	// Returns container's isolation spec.
	GetSpec() (info.ContainerSpec, error)

	// Returns the current stats values of the container.
	GetStats() (*info.ContainerStats, error)

	// Returns the subcontainers of this container.
	ListContainers(listType ListType) ([]info.ContainerReference, error)

	// Returns the processes inside this container.
	ListProcesses(listType ListType) ([]int, error)

	// Returns absolute cgroup path for the requested resource.
	GetCgroupPath(resource string) (string, error)

	// Returns container labels, if available.
	GetContainerLabels() map[string]string

	// Returns the container's ip address, if available
	GetContainerIPAddress() string

	// Returns whether the container still exists.
	Exists() bool

	// Cleanup frees up any resources being held like fds or go routines, etc.
	Cleanup()

	// Start starts any necessary background goroutines - must be cleaned up in Cleanup().
	// It is expected that most implementations will be a no-op.
	Start()

	// Type of handler
	Type() ContainerType
}

Interface for container operation handlers.

func NewContainerHandler

func NewContainerHandler(name string, watchType watcher.ContainerWatchSource, inHostNamespace bool) (ContainerHandler, bool, error)

Create a new ContainerHandler for the specified container.

type ContainerHandlerFactory

type ContainerHandlerFactory interface {
	// Create a new ContainerHandler using this factory. CanHandleAndAccept() must have returned true.
	NewContainerHandler(name string, inHostNamespace bool) (c ContainerHandler, err error)

	// Returns whether this factory can handle and accept the specified container.
	CanHandleAndAccept(name string) (handle bool, accept bool, err error)

	// Name of the factory.
	String() string

	// Returns debugging information. Map of lines per category.
	DebugInfo() map[string][]string
}

type ContainerType

type ContainerType int
const (
	ContainerTypeRaw ContainerType = iota
	ContainerTypeDocker
	ContainerTypeRkt
	ContainerTypeSystemd
	ContainerTypeCrio
	ContainerTypeContainerd
)

type ListType

type ListType int

ListType describes whether listing should be just for a specific container or performed recursively.

const (
	ListSelf ListType = iota
	ListRecursive
)

type MetricKind

type MetricKind string

MetricKind represents the kind of metrics that cAdvisor exposes.

const (
	CpuUsageMetrics        MetricKind = "cpu"
	MemoryUsageMetrics     MetricKind = "memory"
	CpuLoadMetrics         MetricKind = "cpuLoad"
	DiskIOMetrics          MetricKind = "diskIO"
	DiskUsageMetrics       MetricKind = "disk"
	NetworkUsageMetrics    MetricKind = "network"
	NetworkTcpUsageMetrics MetricKind = "tcp"
	NetworkUdpUsageMetrics MetricKind = "udp"
	AppMetrics             MetricKind = "app"
)

func (MetricKind) String

func (mk MetricKind) String() string

type MetricSet

type MetricSet map[MetricKind]struct{}

func (MetricSet) Add

func (ms MetricSet) Add(mk MetricKind)

func (MetricSet) Has

func (ms MetricSet) Has(mk MetricKind) bool

Source Files

container.go factory.go

Directories

PathSynopsis
container/commonUnmarshal's a Containers description json file.
container/containerdThis code has been taken from containerd repo to avoid large library import
container/crioHandler for CRI-O containers.
container/dockerProvides global docker information.
container/libcontainer
container/rawHandler for "raw" containers.
container/rktHandler for "rkt" containers.
container/systemd
container/testing
Version
v0.28.5
Published
Jun 21, 2018
Platform
darwin/amd64
Imports
5 packages
Last checked
1 day ago

Tools for package owners.