2015-01-19 18:29:42 -05:00
|
|
|
// This package is used for API stability in the types and response to the
|
|
|
|
// 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
|
|
|
|
|
|
|
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-01-07 21:02:08 -05:00
|
|
|
// All CPU stats are aggregated since container inception.
|
2015-01-07 19:22:42 -05:00
|
|
|
type CpuUsage struct {
|
|
|
|
// 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"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type CpuStats struct {
|
2015-01-26 14:16:29 -05:00
|
|
|
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"`
|
|
|
|
}
|
|
|
|
|
|
|
|
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-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-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-05-15 18:02:11 -04:00
|
|
|
// TODO Windows: This will require refactoring
|
2015-01-07 19:22:42 -05:00
|
|
|
type Network struct {
|
|
|
|
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"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type Stats struct {
|
|
|
|
Read time.Time `json:"read"`
|
|
|
|
Network Network `json:"network,omitempty"`
|
2015-05-30 13:25:51 -04:00
|
|
|
PreCpuStats CpuStats `json:"precpu_stats,omitempty"`
|
2015-01-07 19:22:42 -05:00
|
|
|
CpuStats CpuStats `json:"cpu_stats,omitempty"`
|
|
|
|
MemoryStats MemoryStats `json:"memory_stats,omitempty"`
|
|
|
|
BlkioStats BlkioStats `json:"blkio_stats,omitempty"`
|
|
|
|
}
|