events.go 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. Copyright The containerd Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package runc
  14. // Event is a struct to pass runc event information
  15. type Event struct {
  16. // Type are the event type generated by runc
  17. // If the type is "error" then check the Err field on the event for
  18. // the actual error
  19. Type string `json:"type"`
  20. ID string `json:"id"`
  21. Stats *Stats `json:"data,omitempty"`
  22. // Err has a read error if we were unable to decode the event from runc
  23. Err error `json:"-"`
  24. }
  25. // Stats is statistical information from the runc process
  26. type Stats struct {
  27. Cpu Cpu `json:"cpu"` //revive:disable
  28. Memory Memory `json:"memory"`
  29. Pids Pids `json:"pids"`
  30. Blkio Blkio `json:"blkio"`
  31. Hugetlb map[string]Hugetlb `json:"hugetlb"`
  32. }
  33. // Hugetlb represents the detailed hugetlb component of the statistics data
  34. type Hugetlb struct {
  35. Usage uint64 `json:"usage,omitempty"`
  36. Max uint64 `json:"max,omitempty"`
  37. Failcnt uint64 `json:"failcnt"`
  38. }
  39. // BlkioEntry represents a block IO entry in the IO stats
  40. type BlkioEntry struct {
  41. Major uint64 `json:"major,omitempty"`
  42. Minor uint64 `json:"minor,omitempty"`
  43. Op string `json:"op,omitempty"`
  44. Value uint64 `json:"value,omitempty"`
  45. }
  46. // Blkio represents the statistical information from block IO devices
  47. type Blkio struct {
  48. IoServiceBytesRecursive []BlkioEntry `json:"ioServiceBytesRecursive,omitempty"`
  49. IoServicedRecursive []BlkioEntry `json:"ioServicedRecursive,omitempty"`
  50. IoQueuedRecursive []BlkioEntry `json:"ioQueueRecursive,omitempty"`
  51. IoServiceTimeRecursive []BlkioEntry `json:"ioServiceTimeRecursive,omitempty"`
  52. IoWaitTimeRecursive []BlkioEntry `json:"ioWaitTimeRecursive,omitempty"`
  53. IoMergedRecursive []BlkioEntry `json:"ioMergedRecursive,omitempty"`
  54. IoTimeRecursive []BlkioEntry `json:"ioTimeRecursive,omitempty"`
  55. SectorsRecursive []BlkioEntry `json:"sectorsRecursive,omitempty"`
  56. }
  57. // Pids represents the process ID information
  58. type Pids struct {
  59. Current uint64 `json:"current,omitempty"`
  60. Limit uint64 `json:"limit,omitempty"`
  61. }
  62. // Throttling represents the throttling statistics
  63. type Throttling struct {
  64. Periods uint64 `json:"periods,omitempty"`
  65. ThrottledPeriods uint64 `json:"throttledPeriods,omitempty"`
  66. ThrottledTime uint64 `json:"throttledTime,omitempty"`
  67. }
  68. // CpuUsage represents the CPU usage statistics
  69. //
  70. //revive:disable-next-line
  71. type CpuUsage struct {
  72. // Units: nanoseconds.
  73. Total uint64 `json:"total,omitempty"`
  74. Percpu []uint64 `json:"percpu,omitempty"`
  75. Kernel uint64 `json:"kernel"`
  76. User uint64 `json:"user"`
  77. }
  78. // Cpu represents the CPU usage and throttling statistics
  79. //
  80. //revive:disable-next-line
  81. type Cpu struct {
  82. Usage CpuUsage `json:"usage,omitempty"`
  83. Throttling Throttling `json:"throttling,omitempty"`
  84. }
  85. // MemoryEntry represents an item in the memory use/statistics
  86. type MemoryEntry struct {
  87. Limit uint64 `json:"limit"`
  88. Usage uint64 `json:"usage,omitempty"`
  89. Max uint64 `json:"max,omitempty"`
  90. Failcnt uint64 `json:"failcnt"`
  91. }
  92. // Memory represents the collection of memory statistics from the process
  93. type Memory struct {
  94. Cache uint64 `json:"cache,omitempty"`
  95. Usage MemoryEntry `json:"usage,omitempty"`
  96. Swap MemoryEntry `json:"swap,omitempty"`
  97. Kernel MemoryEntry `json:"kernel,omitempty"`
  98. KernelTCP MemoryEntry `json:"kernelTCP,omitempty"`
  99. Raw map[string]uint64 `json:"raw,omitempty"`
  100. }