stats.go 3.0 KB

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