2015-07-23 05:40:54 -04:00
|
|
|
// Package types is used for API stability in the types and response to the
|
2015-01-19 18:29:42 -05:00
|
|
|
// consumers of the API stats endpoint.
|
2015-02-24 13:47:47 -05:00
|
|
|
package types
|
2015-01-07 19:22:42 -05:00
|
|
|
|
2015-01-19 18:29:42 -05:00
|
|
|
import "time"
|
2015-01-07 19:22:42 -05:00
|
|
|
|
2015-07-23 05:40:54 -04:00
|
|
|
// ThrottlingData stores CPU throttling stats of one running container
|
2015-01-07 19:22:42 -05:00
|
|
|
type ThrottlingData struct {
|
|
|
|
// Number of periods with throttling active
|
2015-01-26 14:16:29 -05:00
|
|
|
Periods uint64 `json:"periods"`
|
2015-01-07 19:22:42 -05:00
|
|
|
// Number of periods when the container hit its throttling limit.
|
2015-01-26 14:16:29 -05:00
|
|
|
ThrottledPeriods uint64 `json:"throttled_periods"`
|
2015-01-07 19:22:42 -05:00
|
|
|
// Aggregate time the container was throttled for in nanoseconds.
|
2015-01-26 14:16:29 -05:00
|
|
|
ThrottledTime uint64 `json:"throttled_time"`
|
2015-01-07 19:22:42 -05:00
|
|
|
}
|
|
|
|
|
2015-07-23 05:40:54 -04:00
|
|
|
// CPUUsage stores All CPU stats aggregated since container inception.
|
|
|
|
type CPUUsage struct {
|
2015-01-07 19:22:42 -05:00
|
|
|
// Total CPU time consumed.
|
|
|
|
// Units: nanoseconds.
|
2015-01-26 14:16:29 -05:00
|
|
|
TotalUsage uint64 `json:"total_usage"`
|
2015-01-07 19:22:42 -05:00
|
|
|
// Total CPU time consumed per core.
|
|
|
|
// Units: nanoseconds.
|
2015-01-26 14:16:29 -05:00
|
|
|
PercpuUsage []uint64 `json:"percpu_usage"`
|
2015-01-07 19:22:42 -05:00
|
|
|
// Time spent by tasks of the cgroup in kernel mode.
|
|
|
|
// Units: nanoseconds.
|
|
|
|
UsageInKernelmode uint64 `json:"usage_in_kernelmode"`
|
|
|
|
// Time spent by tasks of the cgroup in user mode.
|
|
|
|
// Units: nanoseconds.
|
|
|
|
UsageInUsermode uint64 `json:"usage_in_usermode"`
|
|
|
|
}
|
|
|
|
|
2015-07-23 05:40:54 -04:00
|
|
|
// CPUStats aggregates and wraps all CPU related info of container
|
|
|
|
type CPUStats struct {
|
|
|
|
CPUUsage CPUUsage `json:"cpu_usage"`
|
2015-01-07 19:22:42 -05:00
|
|
|
SystemUsage uint64 `json:"system_cpu_usage"`
|
|
|
|
ThrottlingData ThrottlingData `json:"throttling_data,omitempty"`
|
|
|
|
}
|
|
|
|
|
2015-07-23 05:40:54 -04:00
|
|
|
// MemoryStats aggregates All memory stats since container inception
|
2015-01-07 19:22:42 -05:00
|
|
|
type MemoryStats struct {
|
|
|
|
// current res_counter usage for memory
|
2015-01-26 14:16:29 -05:00
|
|
|
Usage uint64 `json:"usage"`
|
2015-01-07 19:22:42 -05:00
|
|
|
// maximum usage ever recorded.
|
2015-01-26 14:16:29 -05:00
|
|
|
MaxUsage uint64 `json:"max_usage"`
|
2015-01-07 19:22:42 -05:00
|
|
|
// TODO(vishh): Export these as stronger types.
|
|
|
|
// all the stats exported via memory.stat.
|
2015-01-26 14:16:29 -05:00
|
|
|
Stats map[string]uint64 `json:"stats"`
|
2015-01-07 19:22:42 -05:00
|
|
|
// number of times memory usage hits limits.
|
|
|
|
Failcnt uint64 `json:"failcnt"`
|
|
|
|
Limit uint64 `json:"limit"`
|
|
|
|
}
|
|
|
|
|
2015-07-23 05:40:54 -04:00
|
|
|
// BlkioStatEntry is one small entity to store a piece of Blkio stats
|
2015-05-15 18:02:11 -04:00
|
|
|
// TODO Windows: This can be factored out
|
2015-01-07 19:22:42 -05:00
|
|
|
type BlkioStatEntry struct {
|
2015-01-26 14:16:29 -05:00
|
|
|
Major uint64 `json:"major"`
|
|
|
|
Minor uint64 `json:"minor"`
|
|
|
|
Op string `json:"op"`
|
|
|
|
Value uint64 `json:"value"`
|
2015-01-07 19:22:42 -05:00
|
|
|
}
|
|
|
|
|
2015-07-23 05:40:54 -04:00
|
|
|
// BlkioStats stores All IO service stats for data read and write
|
2015-05-15 18:02:11 -04:00
|
|
|
// TODO Windows: This can be factored out
|
2015-01-07 19:22:42 -05:00
|
|
|
type BlkioStats struct {
|
|
|
|
// number of bytes tranferred to and from the block device
|
2015-01-26 14:16:29 -05:00
|
|
|
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"`
|
2015-01-07 19:22:42 -05:00
|
|
|
}
|
|
|
|
|
2015-07-23 05:40:54 -04:00
|
|
|
// NetworkStats aggregates All network stats of one container
|
2015-05-15 18:02:11 -04:00
|
|
|
// TODO Windows: This will require refactoring
|
2015-07-23 05:40:54 -04:00
|
|
|
type NetworkStats struct {
|
2015-01-07 19:22:42 -05:00
|
|
|
RxBytes uint64 `json:"rx_bytes"`
|
|
|
|
RxPackets uint64 `json:"rx_packets"`
|
|
|
|
RxErrors uint64 `json:"rx_errors"`
|
|
|
|
RxDropped uint64 `json:"rx_dropped"`
|
|
|
|
TxBytes uint64 `json:"tx_bytes"`
|
|
|
|
TxPackets uint64 `json:"tx_packets"`
|
|
|
|
TxErrors uint64 `json:"tx_errors"`
|
|
|
|
TxDropped uint64 `json:"tx_dropped"`
|
|
|
|
}
|
|
|
|
|
2015-07-23 05:40:54 -04:00
|
|
|
// Stats is Ultimate struct aggregating all types of stats of one container
|
2015-01-07 19:22:42 -05:00
|
|
|
type Stats struct {
|
2015-08-24 05:17:15 -04:00
|
|
|
Read time.Time `json:"read"`
|
|
|
|
PreCPUStats CPUStats `json:"precpu_stats,omitempty"`
|
|
|
|
CPUStats CPUStats `json:"cpu_stats,omitempty"`
|
|
|
|
MemoryStats MemoryStats `json:"memory_stats,omitempty"`
|
|
|
|
BlkioStats BlkioStats `json:"blkio_stats,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// StatsJSON is newly used Networks
|
|
|
|
type StatsJSON struct {
|
|
|
|
Stats
|
|
|
|
|
|
|
|
// Networks request version >=1.21
|
|
|
|
Networks map[string]NetworkStats `json:"networks,omitempty"`
|
2015-01-07 19:22:42 -05:00
|
|
|
}
|