github.com/a4a881d4/docker@v1.9.0-rc2/api/types/stats.go (about) 1 // Package types is used for API stability in the types and response to the 2 // consumers of the API stats endpoint. 3 package types 4 5 import "time" 6 7 // ThrottlingData stores CPU throttling stats of one running container 8 type ThrottlingData struct { 9 // Number of periods with throttling active 10 Periods uint64 `json:"periods"` 11 // Number of periods when the container hit its throttling limit. 12 ThrottledPeriods uint64 `json:"throttled_periods"` 13 // Aggregate time the container was throttled for in nanoseconds. 14 ThrottledTime uint64 `json:"throttled_time"` 15 } 16 17 // CPUUsage stores All CPU stats aggregated since container inception. 18 type CPUUsage struct { 19 // Total CPU time consumed. 20 // Units: nanoseconds. 21 TotalUsage uint64 `json:"total_usage"` 22 // Total CPU time consumed per core. 23 // Units: nanoseconds. 24 PercpuUsage []uint64 `json:"percpu_usage"` 25 // Time spent by tasks of the cgroup in kernel mode. 26 // Units: nanoseconds. 27 UsageInKernelmode uint64 `json:"usage_in_kernelmode"` 28 // Time spent by tasks of the cgroup in user mode. 29 // Units: nanoseconds. 30 UsageInUsermode uint64 `json:"usage_in_usermode"` 31 } 32 33 // CPUStats aggregates and wraps all CPU related info of container 34 type CPUStats struct { 35 CPUUsage CPUUsage `json:"cpu_usage"` 36 SystemUsage uint64 `json:"system_cpu_usage"` 37 ThrottlingData ThrottlingData `json:"throttling_data,omitempty"` 38 } 39 40 // MemoryStats aggregates All memory stats since container inception 41 type MemoryStats struct { 42 // current res_counter usage for memory 43 Usage uint64 `json:"usage"` 44 // maximum usage ever recorded. 45 MaxUsage uint64 `json:"max_usage"` 46 // TODO(vishh): Export these as stronger types. 47 // all the stats exported via memory.stat. 48 Stats map[string]uint64 `json:"stats"` 49 // number of times memory usage hits limits. 50 Failcnt uint64 `json:"failcnt"` 51 Limit uint64 `json:"limit"` 52 } 53 54 // BlkioStatEntry is one small entity to store a piece of Blkio stats 55 // TODO Windows: This can be factored out 56 type BlkioStatEntry struct { 57 Major uint64 `json:"major"` 58 Minor uint64 `json:"minor"` 59 Op string `json:"op"` 60 Value uint64 `json:"value"` 61 } 62 63 // BlkioStats stores All IO service stats for data read and write 64 // TODO Windows: This can be factored out 65 type BlkioStats struct { 66 // number of bytes tranferred to and from the block device 67 IoServiceBytesRecursive []BlkioStatEntry `json:"io_service_bytes_recursive"` 68 IoServicedRecursive []BlkioStatEntry `json:"io_serviced_recursive"` 69 IoQueuedRecursive []BlkioStatEntry `json:"io_queue_recursive"` 70 IoServiceTimeRecursive []BlkioStatEntry `json:"io_service_time_recursive"` 71 IoWaitTimeRecursive []BlkioStatEntry `json:"io_wait_time_recursive"` 72 IoMergedRecursive []BlkioStatEntry `json:"io_merged_recursive"` 73 IoTimeRecursive []BlkioStatEntry `json:"io_time_recursive"` 74 SectorsRecursive []BlkioStatEntry `json:"sectors_recursive"` 75 } 76 77 // NetworkStats aggregates All network stats of one container 78 // TODO Windows: This will require refactoring 79 type NetworkStats struct { 80 RxBytes uint64 `json:"rx_bytes"` 81 RxPackets uint64 `json:"rx_packets"` 82 RxErrors uint64 `json:"rx_errors"` 83 RxDropped uint64 `json:"rx_dropped"` 84 TxBytes uint64 `json:"tx_bytes"` 85 TxPackets uint64 `json:"tx_packets"` 86 TxErrors uint64 `json:"tx_errors"` 87 TxDropped uint64 `json:"tx_dropped"` 88 } 89 90 // Stats is Ultimate struct aggregating all types of stats of one container 91 type Stats struct { 92 Read time.Time `json:"read"` 93 PreCPUStats CPUStats `json:"precpu_stats,omitempty"` 94 CPUStats CPUStats `json:"cpu_stats,omitempty"` 95 MemoryStats MemoryStats `json:"memory_stats,omitempty"` 96 BlkioStats BlkioStats `json:"blkio_stats,omitempty"` 97 } 98 99 // StatsJSON is newly used Networks 100 type StatsJSON struct { 101 Stats 102 103 // Networks request version >=1.21 104 Networks map[string]NetworkStats `json:"networks,omitempty"` 105 }