Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DockerHealthStrings = map[string]DockerHealth{ "none": DockerHealthNone, "starting": DockerHealthStarting, "healthy": DockerHealthHealthy, "unhealthy": DockerHealthUnhealthy, }
Functions ¶
This section is empty.
Types ¶
type ApiInfo ¶
type ApiInfo struct {
Id string
IdShort string
Names []string
Status string
State string
Image string
Health struct {
Status string
}
Ports []struct {
// PrivatePort uint16
PublicPort uint16
IP string
}
// Set by the agent, not part of the Docker response.
// Labels is only filled when CONTAINER_NAME_LABEL is set, read in the same decode pass as the rest.
Labels map[string]string `json:"-"`
// DisplayName is the name reported to the hub.
DisplayName string `json:"-"`
}
Docker container info from /containers/json
type ApiStats ¶
type ApiStats struct {
Read time.Time `json:"read"` // Time of stats generation
NumProcs uint32 `json:"num_procs,omitzero"` // Windows specific, not populated on Linux.
Networks map[string]NetworkStats
CPUStats CPUStats `json:"cpu_stats"`
MemoryStats MemoryStats `json:"memory_stats"`
}
Docker container resources from /containers/{id}/stats
func (*ApiStats) CalculateCpuPercentLinux ¶
func (*ApiStats) CalculateCpuPercentPodman ¶ added in v0.19.0
CalculateCpuPercentPodman calculates CPU percentage for Podman containers. Podman populates system_cpu_usage from cgroup cpu.stat rather than /proc/stat, so it represents only cgroup-accounted activity, not total host CPU capacity. Using it as a denominator inflates the result. Instead we use elapsed wall-clock time × online_cpus, matching the approach used for Windows and recommended in: https://github.com/henrygd/beszel/issues/2049
type CPUStats ¶
type CPUStats struct {
// CPU Usage. Linux and Windows.
CPUUsage CPUUsage `json:"cpu_usage"`
// System Usage. Linux only. Populated from /proc/stat on Docker; from cgroup cpu.stat on Podman.
SystemUsage uint64 `json:"system_cpu_usage,omitzero"`
// Number of online CPUs. Linux only. Used by Podman for time-based CPU calculation.
OnlineCPUs uint32 `json:"online_cpus,omitzero"`
}
type CPUUsage ¶
type CPUUsage struct {
// Total CPU time consumed.
// Units: nanoseconds (Linux)
// Units: 100's of nanoseconds (Windows)
TotalUsage uint64 `json:"total_usage"`
}
type DockerHealth ¶ added in v0.14.0
type DockerHealth = uint8
const ( DockerHealthNone DockerHealth = iota DockerHealthStarting DockerHealthHealthy DockerHealthUnhealthy )
type HostInfo ¶ added in v0.18.0
type HostInfo struct {
OperatingSystem string `json:"OperatingSystem"`
KernelVersion string `json:"KernelVersion"`
NCPU int `json:"NCPU"`
MemTotal uint64 `json:"MemTotal"`
}
Docker system info from /info API endpoint
type MemoryStats ¶
type MemoryStats struct {
// current res_counter usage for memory
Usage uint64 `json:"usage,omitzero"`
// all the stats exported via memory.stat.
Stats MemoryStatsStats `json:"stats"`
// private working set (Windows only)
PrivateWorkingSet uint64 `json:"privateworkingset,omitzero"`
}
type MemoryStatsStats ¶
type NetworkStats ¶
type Stats ¶
type Stats struct {
Name string `json:"n" cbor:"0,keyasint"`
Cpu float64 `json:"c" cbor:"1,keyasint"`
Mem float64 `json:"m" cbor:"2,keyasint"`
NetworkSent float64 `json:"ns,omitzero" cbor:"3,keyasint,omitzero"` // deprecated 0.18.3 (MB) - keep field for old agents/records
NetworkRecv float64 `json:"nr,omitzero" cbor:"4,keyasint,omitzero"` // deprecated 0.18.3 (MB) - keep field for old agents/records
Bandwidth [2]uint64 `json:"b,omitzero" cbor:"9,keyasint,omitzero"` // [sent bytes, recv bytes]
Health DockerHealth `json:"-" cbor:"5,keyasint"`
Status string `json:"-" cbor:"6,keyasint"`
Id string `json:"-" cbor:"7,keyasint"`
Image string `json:"-" cbor:"8,keyasint"`
Ports string `json:"-" cbor:"10,keyasint"`
UpdateAvailable bool `json:"u,omitzero" cbor:"11,keyasint,omitzero"`
// PrevCpu [2]uint64 `json:"-"`
CpuSystem uint64 `json:"-"`
CpuContainer uint64 `json:"-"`
PrevNet prevNetStats `json:"-"`
PrevReadTime time.Time `json:"-"`
}
Docker container stats
Click to show internal directories.
Click to hide internal directories.