github.com/rentongzhang/docker@v1.8.2-rc1/api/types/stats.go (about) 1 // This package 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 type ThrottlingData struct { 8 // Number of periods with throttling active 9 Periods uint64 `json:"periods"` 10 // Number of periods when the container hit its throttling limit. 11 ThrottledPeriods uint64 `json:"throttled_periods"` 12 // Aggregate time the container was throttled for in nanoseconds. 13 ThrottledTime uint64 `json:"throttled_time"` 14 } 15 16 // All CPU stats are aggregated since container inception. 17 type CpuUsage struct { 18 // Total CPU time consumed. 19 // Units: nanoseconds. 20 TotalUsage uint64 `json:"total_usage"` 21 // Total CPU time consumed per core. 22 // Units: nanoseconds. 23 PercpuUsage []uint64 `json:"percpu_usage"` 24 // Time spent by tasks of the cgroup in kernel mode. 25 // Units: nanoseconds. 26 UsageInKernelmode uint64 `json:"usage_in_kernelmode"` 27 // Time spent by tasks of the cgroup in user mode. 28 // Units: nanoseconds. 29 UsageInUsermode uint64 `json:"usage_in_usermode"` 30 } 31 32 type CpuStats struct { 33 CpuUsage CpuUsage `json:"cpu_usage"` 34 SystemUsage uint64 `json:"system_cpu_usage"` 35 ThrottlingData ThrottlingData `json:"throttling_data,omitempty"` 36 } 37 38 type MemoryStats struct { 39 // current res_counter usage for memory 40 Usage uint64 `json:"usage"` 41 // maximum usage ever recorded. 42 MaxUsage uint64 `json:"max_usage"` 43 // TODO(vishh): Export these as stronger types. 44 // all the stats exported via memory.stat. 45 Stats map[string]uint64 `json:"stats"` 46 // number of times memory usage hits limits. 47 Failcnt uint64 `json:"failcnt"` 48 Limit uint64 `json:"limit"` 49 } 50 51 // TODO Windows: This can be factored out 52 type BlkioStatEntry struct { 53 Major uint64 `json:"major"` 54 Minor uint64 `json:"minor"` 55 Op string `json:"op"` 56 Value uint64 `json:"value"` 57 } 58 59 // TODO Windows: This can be factored out 60 type BlkioStats struct { 61 // number of bytes tranferred to and from the block device 62 IoServiceBytesRecursive []BlkioStatEntry `json:"io_service_bytes_recursive"` 63 IoServicedRecursive []BlkioStatEntry `json:"io_serviced_recursive"` 64 IoQueuedRecursive []BlkioStatEntry `json:"io_queue_recursive"` 65 IoServiceTimeRecursive []BlkioStatEntry `json:"io_service_time_recursive"` 66 IoWaitTimeRecursive []BlkioStatEntry `json:"io_wait_time_recursive"` 67 IoMergedRecursive []BlkioStatEntry `json:"io_merged_recursive"` 68 IoTimeRecursive []BlkioStatEntry `json:"io_time_recursive"` 69 SectorsRecursive []BlkioStatEntry `json:"sectors_recursive"` 70 } 71 72 // TODO Windows: This will require refactoring 73 type Network struct { 74 RxBytes uint64 `json:"rx_bytes"` 75 RxPackets uint64 `json:"rx_packets"` 76 RxErrors uint64 `json:"rx_errors"` 77 RxDropped uint64 `json:"rx_dropped"` 78 TxBytes uint64 `json:"tx_bytes"` 79 TxPackets uint64 `json:"tx_packets"` 80 TxErrors uint64 `json:"tx_errors"` 81 TxDropped uint64 `json:"tx_dropped"` 82 } 83 84 type Stats struct { 85 Read time.Time `json:"read"` 86 Network Network `json:"network,omitempty"` 87 PreCpuStats CpuStats `json:"precpu_stats,omitempty"` 88 CpuStats CpuStats `json:"cpu_stats,omitempty"` 89 MemoryStats MemoryStats `json:"memory_stats,omitempty"` 90 BlkioStats BlkioStats `json:"blkio_stats,omitempty"` 91 }