github.com/zhuohuang-hust/src-cbuild@v0.0.0-20230105071821-c7aab3e7c840/mergeCode/containerd/runtime/stats.go (about) 1 package runtime 2 3 import "time" 4 5 // Stat holds a container statistics 6 type Stat struct { 7 // Timestamp is the time that the statistics where collected 8 Timestamp time.Time 9 CPU CPU `json:"cpu"` 10 Memory Memory `json:"memory"` 11 Pids Pids `json:"pids"` 12 Blkio Blkio `json:"blkio"` 13 Hugetlb map[string]Hugetlb `json:"hugetlb"` 14 } 15 16 // Hugetlb holds information regarding a container huge tlb usage 17 type Hugetlb struct { 18 Usage uint64 `json:"usage,omitempty"` 19 Max uint64 `json:"max,omitempty"` 20 Failcnt uint64 `json:"failcnt"` 21 } 22 23 // BlkioEntry represents a single record for a Blkio stat 24 type BlkioEntry struct { 25 Major uint64 `json:"major,omitempty"` 26 Minor uint64 `json:"minor,omitempty"` 27 Op string `json:"op,omitempty"` 28 Value uint64 `json:"value,omitempty"` 29 } 30 31 // Blkio regroups all the Blkio related stats 32 type Blkio struct { 33 IoServiceBytesRecursive []BlkioEntry `json:"ioServiceBytesRecursive,omitempty"` 34 IoServicedRecursive []BlkioEntry `json:"ioServicedRecursive,omitempty"` 35 IoQueuedRecursive []BlkioEntry `json:"ioQueueRecursive,omitempty"` 36 IoServiceTimeRecursive []BlkioEntry `json:"ioServiceTimeRecursive,omitempty"` 37 IoWaitTimeRecursive []BlkioEntry `json:"ioWaitTimeRecursive,omitempty"` 38 IoMergedRecursive []BlkioEntry `json:"ioMergedRecursive,omitempty"` 39 IoTimeRecursive []BlkioEntry `json:"ioTimeRecursive,omitempty"` 40 SectorsRecursive []BlkioEntry `json:"sectorsRecursive,omitempty"` 41 } 42 43 // Pids holds the stat of the pid usage of the machine 44 type Pids struct { 45 Current uint64 `json:"current,omitempty"` 46 Limit uint64 `json:"limit,omitempty"` 47 } 48 49 // Throttling holds a cpu throttling information 50 type Throttling struct { 51 Periods uint64 `json:"periods,omitempty"` 52 ThrottledPeriods uint64 `json:"throttledPeriods,omitempty"` 53 ThrottledTime uint64 `json:"throttledTime,omitempty"` 54 } 55 56 // CPUUsage holds information regarding cpu usage 57 type CPUUsage struct { 58 // Units: nanoseconds. 59 Total uint64 `json:"total,omitempty"` 60 Percpu []uint64 `json:"percpu,omitempty"` 61 Kernel uint64 `json:"kernel"` 62 User uint64 `json:"user"` 63 } 64 65 // CPU regroups both a CPU usage and throttling information 66 type CPU struct { 67 Usage CPUUsage `json:"usage,omitempty"` 68 Throttling Throttling `json:"throttling,omitempty"` 69 } 70 71 // MemoryEntry regroups statistic about a given type of memory 72 type MemoryEntry struct { 73 Limit uint64 `json:"limit"` 74 Usage uint64 `json:"usage,omitempty"` 75 Max uint64 `json:"max,omitempty"` 76 Failcnt uint64 `json:"failcnt"` 77 } 78 79 // Memory holds information regarding the different type of memories available 80 type Memory struct { 81 Cache uint64 `json:"cache,omitempty"` 82 Usage MemoryEntry `json:"usage,omitempty"` 83 Swap MemoryEntry `json:"swap,omitempty"` 84 Kernel MemoryEntry `json:"kernel,omitempty"` 85 KernelTCP MemoryEntry `json:"kernelTCP,omitempty"` 86 Raw map[string]uint64 `json:"raw,omitempty"` 87 }