container

package
v0.0.0-...-0c39cf3 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2022 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetShortID

func GetShortID(dockerID string) (string, error)

GetShortID returns short container ID (12 chars)

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 Cgroups

type Cgroups struct {
	CpuStats     CpuStats                `json:"cpu_stats,omitempty"`
	MemoryStats  MemoryStats             `json:"memory_stats,omitempty"`
	BlkioStats   BlkioStats              `json:"blkio_stats, omitempty"`
	HugetlbStats map[string]HugetlbStats `json:"hugetlb_stats,omitempty"`
	PidsStats    PidsStats               `json:"pids_stats,omitempty"`
	CpuSetStats  CpuSetStats             `json:"cpuset_stats,omitempty"`
}

type ContainerData

type ContainerData struct {
	ID string `json:"-"`
	// Basic info about the container (status, creation time, image name, etc.)
	Specification Specification `json:"spec,omitempty"`

	// Container's statistics (cpu usage, memory usage, network stats, etc.)
	Stats *Statistics `json:"stats,omitempty"`
}

type CpuSetStats

type CpuSetStats struct {
	Cpus            string `json:"cpus,omitempty"`
	Mems            string `json:"mems,omitempty"`
	MemoryMigrate   uint64 `json:"memory_migrate,omitempty"`
	CpuExclusive    uint64 `json:"cpu_exclusive,omitempty"`
	MemoryExclusive uint64 `json:"memory_exclusive,omitempty"`
}

CpuSet stores information regarding subsystem assignment of individual CPUs and memory nodes

type CpuStats

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

type CpuUsage

type CpuUsage struct {
	Total      uint64   `json:"total,omitempty"`
	UserMode   uint64   `json:"user_mode,omitempty"`
	KernelMode uint64   `json:"kernel_mode,omitempty"`
	PerCpu     []uint64 `json:"per_cpu,omitempty"`
}

type DockerClient

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

DockerClient holds go-dockerclient instance ready for communication with the server endpoint `unix:///var/run/docker.sock`, cache instance which is used to store output from docker container inspect (to avoid execute inspect request multiply times, it is called only once per container)

func NewDockerClient

func NewDockerClient(endpoint string) (*DockerClient, error)

NewDockerClient returns dockerClient instance ready for communication with the server endpoint `unix:///var/run/docker.sock`

func (*DockerClient) FindCgroupMountpoint

func (dc *DockerClient) FindCgroupMountpoint(procfs string, subsystem string) (string, error)

FindCgroupMountpoint returns cgroup mountpoint of a given subsystem

func (*DockerClient) FindControllerMountpoint

func (dc *DockerClient) FindControllerMountpoint(subsystem, pid, procfs string) (string, error)

FindControllerMountpoint returns mountpoints of a given controller and container PID

func (*DockerClient) GetDockerParams

func (dc *DockerClient) GetDockerParams(params ...string) (map[string]string, error)

GetDockerParam returns given map of parameter/value from running docker engine

func (*DockerClient) InspectContainer

func (dc *DockerClient) InspectContainer(id string) (*docker.Container, error)

InspectContainer returns details information about running container

func (*DockerClient) ListContainersAsMap

func (dc *DockerClient) ListContainersAsMap() (map[string]*ContainerData, error)

ListContainersAsMap returns list of all available docker containers and base information about them (status, uptime, etc.)

type DockerClientInterface

type DockerClientInterface interface {
	ListContainersAsMap() (map[string]*ContainerData, error)
	InspectContainer(string) (*docker.Container, error)
	FindCgroupMountpoint(string, string) (string, error)
	FindControllerMountpoint(string, string, string) (string, error)
	GetDockerParams(...string) (map[string]string, error)
}

DockerClientInterface provides methods i.a. for interaction with the docker API.

type FilesystemInterface

type FilesystemInterface struct {
	// The block device name associated with the filesystem
	Device string `json:"device_name,omitempty"`

	// Type of the filesystem
	Type string `json:"type,omitempty"`

	// Number of bytes that can be consumed on this filesystem
	Limit uint64 `json:"capacity,omitempty"`

	// Number of bytes that is consumed on this filesystem
	Usage uint64 `json:"usage,omitempty"`

	// Base Usage that is consumed by the container's writable layer
	BaseUsage uint64 `json:"base_usage,omitempty"`

	// Number of bytes available for non-root user
	Available uint64 `json:"available,omitempty"`

	// Number of available Inodes
	InodesFree uint64 `json:"inodes_free,omitempty"`

	// This is the total number of reads completed successfully
	ReadsCompleted uint64 `json:"reads_completed,omitempty"`

	// This is the total number of reads merged successfully. This field lets you know how often this was done
	ReadsMerged uint64 `json:"reads_merged,omitempty"`

	// This is the total number of sectors read successfully
	SectorsRead uint64 `json:"sectors_read,omitempty"`

	// This is the total number of milliseconds spent reading
	ReadTime uint64 `json:"read_time,omitempty"`

	// This is the total number of writes completed successfully
	WritesCompleted uint64 `json:"writes_completed,omitempty"`

	// This is the total number of writes merged successfully
	WritesMerged uint64 `json:"writes_merged,omitempty"`

	// This is the total number of sectors written successfully
	SectorsWritten uint64 `json:"sectors_written,omitempty"`

	// This is the total number of milliseconds spent writing
	WriteTime uint64 `json:"write_time,omitempty"`

	// Number of I/Os currently in progress
	IoInProgress uint64 `json:"io_in_progress,omitempty"`

	// Number of milliseconds spent doing I/Os
	IoTime uint64 `json:"io_time,omitempty"`

	// weighted number of milliseconds spent doing I/Os
	// This field is incremented at each I/O start, I/O completion, I/O
	// merge, or read of these stats by the number of I/Os in progress
	// (field 9) times the number of milliseconds spent doing I/O since the
	// last update of this field.  This can provide an easy measure of both
	// I/O completion time and the backlog that may be accumulating.
	WeightedIoTime uint64 `json:"weighted_io_time,omitempty"`
}

FilesystemInterface holds statistics about filesystem device, capacity, usage, etc.

type GetStatOpt

type GetStatOpt map[string]interface{}

func (GetStatOpt) GetBoolValue

func (opt GetStatOpt) GetBoolValue(key string) (bool, error)

func (GetStatOpt) GetIntValue

func (opt GetStatOpt) GetIntValue(key string) (int, error)

func (GetStatOpt) GetStringValue

func (opt GetStatOpt) GetStringValue(key string) (string, error)

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,omitempty"`
}

type MemoryData

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

type MemoryStats

type MemoryStats struct {
	Cache       uint64            `json:"cache,omitempty"`
	Usage       MemoryData        `json:"usage,omitempty"`
	SwapUsage   MemoryData        `json:"swap_usage,omitempty"`
	KernelUsage MemoryData        `json:"kernel_usage,omitempty"`
	Stats       map[string]uint64 `json:"statistics,omitempty"`
}

type NetworkInterface

type NetworkInterface struct {
	// Name is the name of the network interface.
	Name string `json:"-"`

	RxBytes   uint64 `json:"rx_bytes,omitempty"`
	RxPackets uint64 `json:"rx_packets,omitempty"`
	RxErrors  uint64 `json:"rx_errors,omitempty"`
	RxDropped uint64 `json:"rx_dropped,omitempty"`
	TxBytes   uint64 `json:"tx_bytes,omitempty"`
	TxPackets uint64 `json:"tx_packets,omitempty"`
	TxErrors  uint64 `json:"tx_errors,omitempty"`
	TxDropped uint64 `json:"tx_dropped,omitempty"`
}

NetworkInterface holds name of network interface and its statistics (rx_bytes, tx_bytes, etc.)

type PidsStats

type PidsStats struct {
	Current uint64 `json:"current,omitempty"`
	Limit   uint64 `json:"limit,omitempty"`
}

type Specification

type Specification struct {
	Status     string            `json:"status,omitempty"`
	Created    string            `json:"creation_time,omitempty"`
	Image      string            `json:"image_name,omitempty"`
	SizeRw     int64             `json:"size_rw,omitempty"`
	SizeRootFs int64             `json:"size_root_fs,omitempty"`
	Labels     map[string]string `json:"labels,omitempty"`
}

Specification holds docker container specification

type StatGetter

type StatGetter interface {
	GetStats(*Statistics, GetStatOpt) error
}

type Statistics

type Statistics struct {
	Cgroups    *Cgroups                       `json:"cgroups,omitempty"`
	Network    []NetworkInterface             `json:"network,omitempty"`
	Connection TcpInterface                   `json:"connection,omitempty"`
	Filesystem map[string]FilesystemInterface `json:"filesystem,omitempty"`
}

func NewStatistics

func NewStatistics() *Statistics

NewStatistics returns pointer to initialized Statistics

type TcpInterface

type TcpInterface struct {
	Tcp  TcpStat `json:"tcp,omitempty"`  // TCP connection stats (Established, Listen, etc.)
	Tcp6 TcpStat `json:"tcp6,omitempty"` // TCP6 connection stats (Established, Listen, etc.)
}

TcpInterface holds tcp and tcp6 statistics

type TcpStat

type TcpStat struct {
	//Count of TCP connections in state "Established"
	Established uint64 `json:"established,omitempty"`
	//Count of TCP connections in state "Syn_Sent"
	SynSent uint64 `json:"syn_sent,omitempty"`
	//Count of TCP connections in state "Syn_Recv"
	SynRecv uint64 `json:"syn_recv,omitempty"`
	//Count of TCP connections in state "Fin_Wait1"
	FinWait1 uint64 `json:"fin_wait1,omitempty"`
	//Count of TCP connections in state "Fin_Wait2"
	FinWait2 uint64 `json:"fin_wait2,omitempty"`
	//Count of TCP connections in state "Time_Wait
	TimeWait uint64 `json:"time_wait,omitempty"`
	//Count of TCP connections in state "Close"
	Close uint64 `json:"close,omitempty"`
	//Count of TCP connections in state "Close_Wait"
	CloseWait uint64 `json:"close_wait,omitempty"`
	//Count of TCP connections in state "Listen_Ack"
	LastAck uint64 `json:"last_ack,omitempty"`
	//Count of TCP connections in state "Listen"
	Listen uint64 `json:"listen,omitempty"`
	//Count of TCP connections in state "Closing"
	Closing uint64 `json:"closing,omitempty"`
}

TcpStat holds statistics about count of connections in different states

type ThrottlingData

type ThrottlingData struct {
	NrPeriods     uint64 `json:"nr_periods,omitempty"`
	NrThrottled   uint64 `json:"nr_throttled,omitempty"`
	ThrottledTime uint64 `json:"throttled_time,omitempty"`
}

Directories

Path Synopsis
Package fs provides filesystem statistics
Package fs provides filesystem statistics
Package network provides network statistics
Package network provides network statistics

Jump to

Keyboard shortcuts

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