docker

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2016 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContainerName          = "docker_container_name"
	ContainerCommand       = "docker_container_command"
	ContainerPorts         = "docker_container_ports"
	ContainerCreated       = "docker_container_created"
	ContainerIPs           = "docker_container_ips"
	ContainerHostname      = "docker_container_hostname"
	ContainerIPsWithScopes = "docker_container_ips_with_scopes"
	ContainerState         = "docker_container_state"
	ContainerUptime        = "docker_container_uptime"
	ContainerRestartCount  = "docker_container_restart_count"
	ContainerNetworkMode   = "docker_container_network_mode"

	NetworkRxDropped = "network_rx_dropped"
	NetworkRxBytes   = "network_rx_bytes"
	NetworkRxErrors  = "network_rx_errors"
	NetworkTxPackets = "network_tx_packets"
	NetworkTxDropped = "network_tx_dropped"
	NetworkRxPackets = "network_rx_packets"
	NetworkTxErrors  = "network_tx_errors"
	NetworkTxBytes   = "network_tx_bytes"

	MemoryMaxUsage = "docker_memory_max_usage"
	MemoryUsage    = "docker_memory_usage"
	MemoryFailcnt  = "docker_memory_failcnt"
	MemoryLimit    = "docker_memory_limit"

	CPUPercpuUsage       = "docker_cpu_per_cpu_usage"
	CPUUsageInUsermode   = "docker_cpu_usage_in_usermode"
	CPUTotalUsage        = "docker_cpu_total_usage"
	CPUUsageInKernelmode = "docker_cpu_usage_in_kernelmode"
	CPUSystemCPUUsage    = "docker_cpu_system_cpu_usage"

	StateRunning = "running"
	StateStopped = "stopped"
	StatePaused  = "paused"

	NetworkModeHost = "host"
)

These constants are keys used in node metadata

View Source
const (
	StopContainer    = "docker_stop_container"
	StartContainer   = "docker_start_container"
	RestartContainer = "docker_restart_container"
	PauseContainer   = "docker_pause_container"
	UnpauseContainer = "docker_unpause_container"
	AttachContainer  = "docker_attach_container"
	ExecContainer    = "docker_exec_container"
)

Control IDs used by the docker intergation.

View Source
const (
	CreateEvent  = "create"
	DestroyEvent = "destroy"
	StartEvent   = "start"
	DieEvent     = "die"
	PauseEvent   = "pause"
	UnpauseEvent = "unpause"
)

Consts exported for testing.

View Source
const (
	ImageID   = "docker_image_id"
	ImageName = "docker_image_name"
)

Keys for use in Node

View Source
const (
	ContainerID = "docker_container_id"
	Domain      = "domain" // TODO this is ambiguous, be more specific
	Name        = "name"   // TODO this is ambiguous, be more specific
)

Node metadata keys.

View Source
const LabelPrefix = "docker_label_"

LabelPrefix is the key prefix used for Docker labels in Node (e.g. a Docker label "labelKey"="labelValue" will get encoded as "docker_label_labelKey"="dockerValue" in the metadata)

Variables

View Source
var (
	DialStub          = net.Dial
	NewClientConnStub = newClientConn
)

Exported for testing

View Source
var (
	NewDockerClientStub = newDockerClient
	NewContainerStub    = NewContainer
)

Vars exported for testing.

View Source
var (
	NewProcessTreeStub = process.NewTree
)

These vars are exported for testing.

Functions

func AddLabels added in v0.7.0

func AddLabels(node report.Node, labels map[string]string) report.Node

AddLabels appends Docker labels to the Node from a topology.

func ExtractContainerIPs added in v0.7.0

func ExtractContainerIPs(nmd report.Node) []string

ExtractContainerIPs returns the list of container IPs given a Node from the Container topology.

func ExtractContainerIPsWithScopes added in v0.9.0

func ExtractContainerIPsWithScopes(nmd report.Node) []string

ExtractContainerIPsWithScopes returns the list of container IPs, prepended with scopes, given a Node from the Container topology.

func ExtractLabels added in v0.7.0

func ExtractLabels(node report.Node) map[string]string

ExtractLabels returns the list of Docker labels given a Node from a topology.

Types

type Client

type Client interface {
	ListContainers(docker_client.ListContainersOptions) ([]docker_client.APIContainers, error)
	InspectContainer(string) (*docker_client.Container, error)
	ListImages(docker_client.ListImagesOptions) ([]docker_client.APIImages, error)
	AddEventListener(chan<- *docker_client.APIEvents) error
	RemoveEventListener(chan *docker_client.APIEvents) error

	StopContainer(string, uint) error
	StartContainer(string, *docker_client.HostConfig) error
	RestartContainer(string, uint) error
	PauseContainer(string) error
	UnpauseContainer(string) error
	AttachToContainerNonBlocking(docker_client.AttachToContainerOptions) (docker_client.CloseWaiter, error)
	CreateExec(docker_client.CreateExecOptions) (*docker_client.Exec, error)
	StartExecNonBlocking(string, docker_client.StartExecOptions) (docker_client.CloseWaiter, error)
}

Client interface for mocking.

type ClientConn

type ClientConn interface {
	Do(req *http.Request) (resp *http.Response, err error)
	Close() error
}

ClientConn is exported for testing

type Container

type Container interface {
	UpdateState(*docker.Container)

	ID() string
	Image() string
	PID() int
	Hostname() string
	GetNode(string, []net.IP) report.Node
	State() string
	HasTTY() bool
	Container() *docker.Container
	StartGatheringStats() error
	StopGatheringStats()
}

Container represents a Docker container

func NewContainer

func NewContainer(c *docker.Container) Container

NewContainer creates a new Container

type ContainerUpdateWatcher added in v0.10.0

type ContainerUpdateWatcher func(c Container)

ContainerUpdateWatcher is the type of functions that get called when containers are updated.

type Registry

type Registry interface {
	Stop()
	LockedPIDLookup(f func(func(int) Container))
	WalkContainers(f func(Container))
	WalkImages(f func(*docker_client.APIImages))
	WatchContainerUpdates(ContainerUpdateWatcher)
	GetContainer(string) (Container, bool)
}

Registry keeps track of running docker containers and their images

func NewRegistry

func NewRegistry(interval time.Duration, pipes controls.PipeClient) (Registry, error)

NewRegistry returns a usable Registry. Don't forget to Stop it.

type Reporter

type Reporter struct {
	// contains filtered or unexported fields
}

Reporter generate Reports containing Container and ContainerImage topologies

func NewReporter

func NewReporter(registry Registry, hostID string, probeID string, probe *probe.Probe) *Reporter

NewReporter makes a new Reporter

func (*Reporter) ContainerUpdated added in v0.10.0

func (r *Reporter) ContainerUpdated(c Container)

ContainerUpdated should be called whenever a container is updated.

func (Reporter) Name added in v0.10.0

func (Reporter) Name() string

Name of this reporter, for metrics gathering

func (*Reporter) Report

func (r *Reporter) Report() (report.Report, error)

Report generates a Report containing Container and ContainerImage topologies

type Tagger

type Tagger struct {
	// contains filtered or unexported fields
}

Tagger is a tagger that tags Docker container information to process nodes that have a PID.

func NewTagger

func NewTagger(registry Registry, procWalker process.Walker) *Tagger

NewTagger returns a usable Tagger.

func (Tagger) Name added in v0.10.0

func (Tagger) Name() string

Name of this tagger, for metrics gathering

func (*Tagger) Tag

func (t *Tagger) Tag(r report.Report) (report.Report, error)

Tag implements Tagger.

Jump to

Keyboard shortcuts

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