mon

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const CheckCleanupLabel string = "mon.checks.cleanup=1"

CheckCleanupLabel is how we detect containers we want to remove if they exit cleanly

View Source
const CheckHealthLabel string = "mon.checks.health=1"

CheckHealthLabel is how we detect containers we want to restart based on health

View Source
const CleanupExitCodeLabelKey string = "mon.checks.cleanup.code"

CleanupExitCodeLabelKey is the label key in which the expected exit code can be overriden

View Source
const DefaultCleanupExitCode int = 0

DefaultCleanupExitCode is the default exit code we expect for cleanup

View Source
const DefaultRestartTimeoutMs int64 = 10 * 1000

DefaultRestartTimeoutMs is the default timeout for restarting

View Source
const ExitedState string = "exited"

ExitedState is the literal "exited"

View Source
const HealthRestartLabelKey string = "mon.checks.health.timeout"

HealthRestartLabelKey is the label key in which the expected restart timeout can be overriden

View Source
const ObserveLabel string = "mon.observe=1"

ObserveLabel is how we detect containers we want to monitor

View Source
const RunningState string = "running"

RunningState is the literal "running"

Variables

This section is empty.

Functions

This section is empty.

Types

type DockerAPI

type DockerAPI interface {
	ExecuteListQuery(filterList []string) ([]types.Container, error)
	Restart(timeoutMs int64, cont types.Container) error
	Remove(types.Container) error
	Inspect(cont types.Container) (types.ContainerJSON, error)
}

DockerAPI is something that implements the docker API

type DockerD

type DockerD struct {
	ControlAddr    string
	TargetVersion  string
	CommandRetries int64
}

DockerD implements the DockerAPI for the docker daemon

func (*DockerD) ExecuteListQuery

func (d *DockerD) ExecuteListQuery(filterList []string) ([]types.Container, error)

ExecuteListQuery to find containers

func (*DockerD) Inspect added in v1.1.0

func (d *DockerD) Inspect(cont types.Container) (types.ContainerJSON, error)

Inspect a container

func (*DockerD) Remove

func (d *DockerD) Remove(cont types.Container) error

Remove a container

func (*DockerD) Restart

func (d *DockerD) Restart(timeoutMs int64, cont types.Container) error

Restart a container

type Monitor

type Monitor struct {
	ContainerPrefix string
	Dockerd         DockerAPI
	Quiet           bool
}

Monitor is the core application controller, to monitor and act on containers

func (*Monitor) Poll

func (m *Monitor) Poll(t time.Time)

Poll checks the dockerd system and executes operations as needed

type PollHandler

type PollHandler interface {
	Poll(time.Time)
}

PollHandler provides a poll method

type Poller

type Poller struct {
	IntervalMs int64
	Handler    PollHandler
	// contains filtered or unexported fields
}

Poller polls the docker socket at an interval, to find containers

func (*Poller) Start

func (p *Poller) Start() error

Start begins polling

func (*Poller) Stop

func (p *Poller) Stop() error

Stop ends polling

Directories

Path Synopsis
Package mock_mon is a generated GoMock package.
Package mock_mon is a generated GoMock package.

Jump to

Keyboard shortcuts

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