2016-09-06 14:18:12 -04:00
|
|
|
// Package types is used for API stability in the types and response to the
|
|
|
|
// consumers of the API stats endpoint.
|
2018-02-05 16:05:59 -05:00
|
|
|
package types // import "github.com/docker/docker/api/types"
|
2016-09-06 14:18:12 -04:00
|
|
|
|
|
|
|
import "time"
|
|
|
|
|
2016-09-07 19:08:51 -04:00
|
|
|
// ThrottlingData stores CPU throttling stats of one running container.
|
|
|
|
// Not used on Windows.
|
2016-09-06 14:18:12 -04:00
|
|
|
type ThrottlingData struct {
|
|
|
|
// Number of periods with throttling active
|
|
|
|
Periods uint64 `json:"periods"`
|
|
|
|
// Number of periods when the container hits its throttling limit.
|
|
|
|
ThrottledPeriods uint64 `json:"throttled_periods"`
|
|
|
|
// Aggregate time the container was throttled for in nanoseconds.
|
|
|
|
ThrottledTime uint64 `json:"throttled_time"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// CPUUsage stores All CPU stats aggregated since container inception.
|
|
|
|
type CPUUsage struct {
|
|
|
|
// Total CPU time consumed.
|
2016-09-07 19:08:51 -04:00
|
|
|
// Units: nanoseconds (Linux)
|
|
|
|
// Units: 100's of nanoseconds (Windows)
|
2016-09-06 14:18:12 -04:00
|
|
|
TotalUsage uint64 `json:"total_usage"`
|
2016-09-07 19:08:51 -04:00
|
|
|
|
|
|
|
// Total CPU time consumed per core (Linux). Not used on Windows.
|
2016-09-06 14:18:12 -04:00
|
|
|
// Units: nanoseconds.
|
2016-09-07 19:08:51 -04:00
|
|
|
PercpuUsage []uint64 `json:"percpu_usage,omitempty"`
|
|
|
|
|
|
|
|
// Time spent by tasks of the cgroup in kernel mode (Linux).
|
|
|
|
// Time spent by all container processes in kernel mode (Windows).
|
|
|
|
// Units: nanoseconds (Linux).
|
|
|
|
// Units: 100's of nanoseconds (Windows). Not populated for Hyper-V Containers.
|
2016-09-06 14:18:12 -04:00
|
|
|
UsageInKernelmode uint64 `json:"usage_in_kernelmode"`
|
2016-09-07 19:08:51 -04:00
|
|
|
|
|
|
|
// Time spent by tasks of the cgroup in user mode (Linux).
|
|
|
|
// Time spent by all container processes in user mode (Windows).
|
|
|
|
// Units: nanoseconds (Linux).
|
|
|
|
// Units: 100's of nanoseconds (Windows). Not populated for Hyper-V Containers
|
2016-09-06 14:18:12 -04:00
|
|
|
UsageInUsermode uint64 `json:"usage_in_usermode"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// CPUStats aggregates and wraps all CPU related info of container
|
|
|
|
type CPUStats struct {
|
2016-09-07 19:08:51 -04:00
|
|
|
// CPU Usage. Linux and Windows.
|
|
|
|
CPUUsage CPUUsage `json:"cpu_usage"`
|
|
|
|
|
|
|
|
// System Usage. Linux only.
|
|
|
|
SystemUsage uint64 `json:"system_cpu_usage,omitempty"`
|
|
|
|
|
2017-03-06 12:29:09 -05:00
|
|
|
// Online CPUs. Linux only.
|
|
|
|
OnlineCPUs uint32 `json:"online_cpus,omitempty"`
|
|
|
|
|
2016-09-07 19:08:51 -04:00
|
|
|
// Throttling Data. Linux only.
|
2016-09-06 14:18:12 -04:00
|
|
|
ThrottlingData ThrottlingData `json:"throttling_data,omitempty"`
|
|
|
|
}
|
|
|
|
|
2016-09-07 19:08:51 -04:00
|
|
|
// MemoryStats aggregates all memory stats since container inception on Linux.
|
|
|
|
// Windows returns stats for commit and private working set only.
|
2016-09-06 14:18:12 -04:00
|
|
|
type MemoryStats struct {
|
2016-09-07 19:08:51 -04:00
|
|
|
// Linux Memory Stats
|
|
|
|
|
2016-09-06 14:18:12 -04:00
|
|
|
// current res_counter usage for memory
|
2016-09-07 19:08:51 -04:00
|
|
|
Usage uint64 `json:"usage,omitempty"`
|
2016-09-06 14:18:12 -04:00
|
|
|
// maximum usage ever recorded.
|
2016-09-07 19:08:51 -04:00
|
|
|
MaxUsage uint64 `json:"max_usage,omitempty"`
|
2016-09-06 14:18:12 -04:00
|
|
|
// TODO(vishh): Export these as stronger types.
|
|
|
|
// all the stats exported via memory.stat.
|
2016-09-07 19:08:51 -04:00
|
|
|
Stats map[string]uint64 `json:"stats,omitempty"`
|
2016-09-06 14:18:12 -04:00
|
|
|
// number of times memory usage hits limits.
|
2016-09-07 19:08:51 -04:00
|
|
|
Failcnt uint64 `json:"failcnt,omitempty"`
|
|
|
|
Limit uint64 `json:"limit,omitempty"`
|
|
|
|
|
|
|
|
// Windows Memory Stats
|
|
|
|
// See https://technet.microsoft.com/en-us/magazine/ff382715.aspx
|
|
|
|
|
|
|
|
// committed bytes
|
|
|
|
Commit uint64 `json:"commitbytes,omitempty"`
|
|
|
|
// peak committed bytes
|
|
|
|
CommitPeak uint64 `json:"commitpeakbytes,omitempty"`
|
|
|
|
// private working set
|
|
|
|
PrivateWorkingSet uint64 `json:"privateworkingset,omitempty"`
|
2016-09-06 14:18:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// BlkioStatEntry is one small entity to store a piece of Blkio stats
|
2016-09-07 19:08:51 -04:00
|
|
|
// Not used on Windows.
|
2016-09-06 14:18:12 -04:00
|
|
|
type BlkioStatEntry struct {
|
|
|
|
Major uint64 `json:"major"`
|
|
|
|
Minor uint64 `json:"minor"`
|
|
|
|
Op string `json:"op"`
|
|
|
|
Value uint64 `json:"value"`
|
|
|
|
}
|
|
|
|
|
2016-09-07 19:08:51 -04:00
|
|
|
// BlkioStats stores All IO service stats for data read and write.
|
|
|
|
// This is a Linux specific structure as the differences between expressing
|
|
|
|
// block I/O on Windows and Linux are sufficiently significant to make
|
|
|
|
// little sense attempting to morph into a combined structure.
|
2016-09-06 14:18:12 -04:00
|
|
|
type BlkioStats struct {
|
|
|
|
// number of bytes transferred to and from the block device
|
|
|
|
IoServiceBytesRecursive []BlkioStatEntry `json:"io_service_bytes_recursive"`
|
|
|
|
IoServicedRecursive []BlkioStatEntry `json:"io_serviced_recursive"`
|
|
|
|
IoQueuedRecursive []BlkioStatEntry `json:"io_queue_recursive"`
|
|
|
|
IoServiceTimeRecursive []BlkioStatEntry `json:"io_service_time_recursive"`
|
|
|
|
IoWaitTimeRecursive []BlkioStatEntry `json:"io_wait_time_recursive"`
|
|
|
|
IoMergedRecursive []BlkioStatEntry `json:"io_merged_recursive"`
|
|
|
|
IoTimeRecursive []BlkioStatEntry `json:"io_time_recursive"`
|
|
|
|
SectorsRecursive []BlkioStatEntry `json:"sectors_recursive"`
|
|
|
|
}
|
|
|
|
|
2016-09-07 19:08:51 -04:00
|
|
|
// StorageStats is the disk I/O stats for read/write on Windows.
|
|
|
|
type StorageStats struct {
|
|
|
|
ReadCountNormalized uint64 `json:"read_count_normalized,omitempty"`
|
|
|
|
ReadSizeBytes uint64 `json:"read_size_bytes,omitempty"`
|
|
|
|
WriteCountNormalized uint64 `json:"write_count_normalized,omitempty"`
|
|
|
|
WriteSizeBytes uint64 `json:"write_size_bytes,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// NetworkStats aggregates the network stats of one container
|
2016-09-06 14:18:12 -04:00
|
|
|
type NetworkStats struct {
|
2016-09-07 19:08:51 -04:00
|
|
|
// Bytes received. Windows and Linux.
|
|
|
|
RxBytes uint64 `json:"rx_bytes"`
|
|
|
|
// Packets received. Windows and Linux.
|
2016-09-06 14:18:12 -04:00
|
|
|
RxPackets uint64 `json:"rx_packets"`
|
2018-09-06 23:26:04 -04:00
|
|
|
// Received errors. Not used on Windows. Note that we don't `omitempty` this
|
2016-09-07 19:08:51 -04:00
|
|
|
// field as it is expected in the >=v1.21 API stats structure.
|
|
|
|
RxErrors uint64 `json:"rx_errors"`
|
|
|
|
// Incoming packets dropped. Windows and Linux.
|
2016-09-06 14:18:12 -04:00
|
|
|
RxDropped uint64 `json:"rx_dropped"`
|
2016-09-07 19:08:51 -04:00
|
|
|
// Bytes sent. Windows and Linux.
|
|
|
|
TxBytes uint64 `json:"tx_bytes"`
|
|
|
|
// Packets sent. Windows and Linux.
|
2016-09-06 14:18:12 -04:00
|
|
|
TxPackets uint64 `json:"tx_packets"`
|
2018-09-08 04:56:01 -04:00
|
|
|
// Sent errors. Not used on Windows. Note that we don't `omitempty` this
|
2016-09-07 19:08:51 -04:00
|
|
|
// field as it is expected in the >=v1.21 API stats structure.
|
|
|
|
TxErrors uint64 `json:"tx_errors"`
|
|
|
|
// Outgoing packets dropped. Windows and Linux.
|
2016-09-06 14:18:12 -04:00
|
|
|
TxDropped uint64 `json:"tx_dropped"`
|
2016-09-07 19:08:51 -04:00
|
|
|
// Endpoint ID. Not used on Linux.
|
|
|
|
EndpointID string `json:"endpoint_id,omitempty"`
|
|
|
|
// Instance ID. Not used on Linux.
|
|
|
|
InstanceID string `json:"instance_id,omitempty"`
|
2016-09-06 14:18:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// PidsStats contains the stats of a container's pids
|
|
|
|
type PidsStats struct {
|
|
|
|
// Current is the number of pids in the cgroup
|
|
|
|
Current uint64 `json:"current,omitempty"`
|
|
|
|
// Limit is the hard limit on the number of pids in the cgroup.
|
|
|
|
// A "Limit" of 0 means that there is no limit.
|
|
|
|
Limit uint64 `json:"limit,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// Stats is Ultimate struct aggregating all types of stats of one container
|
|
|
|
type Stats struct {
|
2016-09-07 19:08:51 -04:00
|
|
|
// Common stats
|
|
|
|
Read time.Time `json:"read"`
|
|
|
|
PreRead time.Time `json:"preread"`
|
|
|
|
|
|
|
|
// Linux specific stats, not populated on Windows.
|
|
|
|
PidsStats PidsStats `json:"pids_stats,omitempty"`
|
|
|
|
BlkioStats BlkioStats `json:"blkio_stats,omitempty"`
|
|
|
|
|
|
|
|
// Windows specific stats, not populated on Linux.
|
|
|
|
NumProcs uint32 `json:"num_procs"`
|
|
|
|
StorageStats StorageStats `json:"storage_stats,omitempty"`
|
|
|
|
|
|
|
|
// Shared stats
|
2016-09-06 14:18:12 -04:00
|
|
|
CPUStats CPUStats `json:"cpu_stats,omitempty"`
|
2016-09-07 19:08:51 -04:00
|
|
|
PreCPUStats CPUStats `json:"precpu_stats,omitempty"` // "Pre"="Previous"
|
2016-09-06 14:18:12 -04:00
|
|
|
MemoryStats MemoryStats `json:"memory_stats,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// StatsJSON is newly used Networks
|
|
|
|
type StatsJSON struct {
|
|
|
|
Stats
|
|
|
|
|
2016-11-03 02:20:46 -04:00
|
|
|
Name string `json:"name,omitempty"`
|
|
|
|
ID string `json:"id,omitempty"`
|
|
|
|
|
2016-09-06 14:18:12 -04:00
|
|
|
// Networks request version >=1.21
|
|
|
|
Networks map[string]NetworkStats `json:"networks,omitempty"`
|
|
|
|
}
|