...

Source file src/github.com/opencontainers/runc/libcontainer/cgroups/stats.go

Documentation: github.com/opencontainers/runc/libcontainer/cgroups

     1  package cgroups
     2  
     3  type ThrottlingData struct {
     4  	// Number of periods with throttling active
     5  	Periods uint64 `json:"periods,omitempty"`
     6  	// Number of periods when the container hit its throttling limit.
     7  	ThrottledPeriods uint64 `json:"throttled_periods,omitempty"`
     8  	// Aggregate time the container was throttled for in nanoseconds.
     9  	ThrottledTime uint64 `json:"throttled_time,omitempty"`
    10  }
    11  
    12  // CpuUsage denotes the usage of a CPU.
    13  // All CPU stats are aggregate since container inception.
    14  type CpuUsage struct {
    15  	// Total CPU time consumed.
    16  	// Units: nanoseconds.
    17  	TotalUsage uint64 `json:"total_usage,omitempty"`
    18  	// Total CPU time consumed per core.
    19  	// Units: nanoseconds.
    20  	PercpuUsage []uint64 `json:"percpu_usage,omitempty"`
    21  	// CPU time consumed per core in kernel mode
    22  	// Units: nanoseconds.
    23  	PercpuUsageInKernelmode []uint64 `json:"percpu_usage_in_kernelmode"`
    24  	// CPU time consumed per core in user mode
    25  	// Units: nanoseconds.
    26  	PercpuUsageInUsermode []uint64 `json:"percpu_usage_in_usermode"`
    27  	// Time spent by tasks of the cgroup in kernel mode.
    28  	// Units: nanoseconds.
    29  	UsageInKernelmode uint64 `json:"usage_in_kernelmode"`
    30  	// Time spent by tasks of the cgroup in user mode.
    31  	// Units: nanoseconds.
    32  	UsageInUsermode uint64 `json:"usage_in_usermode"`
    33  }
    34  
    35  type CpuStats struct {
    36  	CpuUsage       CpuUsage       `json:"cpu_usage,omitempty"`
    37  	ThrottlingData ThrottlingData `json:"throttling_data,omitempty"`
    38  }
    39  
    40  type CPUSetStats struct {
    41  	// List of the physical numbers of the CPUs on which processes
    42  	// in that cpuset are allowed to execute
    43  	CPUs []uint16 `json:"cpus,omitempty"`
    44  	// cpu_exclusive flag
    45  	CPUExclusive uint64 `json:"cpu_exclusive"`
    46  	// List of memory nodes on which processes in that cpuset
    47  	// are allowed to allocate memory
    48  	Mems []uint16 `json:"mems,omitempty"`
    49  	// mem_hardwall flag
    50  	MemHardwall uint64 `json:"mem_hardwall"`
    51  	// mem_exclusive flag
    52  	MemExclusive uint64 `json:"mem_exclusive"`
    53  	// memory_migrate flag
    54  	MemoryMigrate uint64 `json:"memory_migrate"`
    55  	// memory_spread page flag
    56  	MemorySpreadPage uint64 `json:"memory_spread_page"`
    57  	// memory_spread slab flag
    58  	MemorySpreadSlab uint64 `json:"memory_spread_slab"`
    59  	// memory_pressure
    60  	MemoryPressure uint64 `json:"memory_pressure"`
    61  	// sched_load balance flag
    62  	SchedLoadBalance uint64 `json:"sched_load_balance"`
    63  	// sched_relax_domain_level
    64  	SchedRelaxDomainLevel int64 `json:"sched_relax_domain_level"`
    65  }
    66  
    67  type MemoryData struct {
    68  	Usage    uint64 `json:"usage,omitempty"`
    69  	MaxUsage uint64 `json:"max_usage,omitempty"`
    70  	Failcnt  uint64 `json:"failcnt"`
    71  	Limit    uint64 `json:"limit"`
    72  }
    73  
    74  type MemoryStats struct {
    75  	// memory used for cache
    76  	Cache uint64 `json:"cache,omitempty"`
    77  	// usage of memory
    78  	Usage MemoryData `json:"usage,omitempty"`
    79  	// usage of memory + swap
    80  	SwapUsage MemoryData `json:"swap_usage,omitempty"`
    81  	// usage of swap only
    82  	SwapOnlyUsage MemoryData `json:"swap_only_usage,omitempty"`
    83  	// usage of kernel memory
    84  	KernelUsage MemoryData `json:"kernel_usage,omitempty"`
    85  	// usage of kernel TCP memory
    86  	KernelTCPUsage MemoryData `json:"kernel_tcp_usage,omitempty"`
    87  	// usage of memory pages by NUMA node
    88  	// see chapter 5.6 of memory controller documentation
    89  	PageUsageByNUMA PageUsageByNUMA `json:"page_usage_by_numa,omitempty"`
    90  	// if true, memory usage is accounted for throughout a hierarchy of cgroups.
    91  	UseHierarchy bool `json:"use_hierarchy"`
    92  
    93  	Stats map[string]uint64 `json:"stats,omitempty"`
    94  }
    95  
    96  type PageUsageByNUMA struct {
    97  	// Embedding is used as types can't be recursive.
    98  	PageUsageByNUMAInner
    99  	Hierarchical PageUsageByNUMAInner `json:"hierarchical,omitempty"`
   100  }
   101  
   102  type PageUsageByNUMAInner struct {
   103  	Total       PageStats `json:"total,omitempty"`
   104  	File        PageStats `json:"file,omitempty"`
   105  	Anon        PageStats `json:"anon,omitempty"`
   106  	Unevictable PageStats `json:"unevictable,omitempty"`
   107  }
   108  
   109  type PageStats struct {
   110  	Total uint64           `json:"total,omitempty"`
   111  	Nodes map[uint8]uint64 `json:"nodes,omitempty"`
   112  }
   113  
   114  type PidsStats struct {
   115  	// number of pids in the cgroup
   116  	Current uint64 `json:"current,omitempty"`
   117  	// active pids hard limit
   118  	Limit uint64 `json:"limit,omitempty"`
   119  }
   120  
   121  type BlkioStatEntry struct {
   122  	Major uint64 `json:"major,omitempty"`
   123  	Minor uint64 `json:"minor,omitempty"`
   124  	Op    string `json:"op,omitempty"`
   125  	Value uint64 `json:"value,omitempty"`
   126  }
   127  
   128  type BlkioStats struct {
   129  	// number of bytes transferred to and from the block device
   130  	IoServiceBytesRecursive []BlkioStatEntry `json:"io_service_bytes_recursive,omitempty"`
   131  	IoServicedRecursive     []BlkioStatEntry `json:"io_serviced_recursive,omitempty"`
   132  	IoQueuedRecursive       []BlkioStatEntry `json:"io_queue_recursive,omitempty"`
   133  	IoServiceTimeRecursive  []BlkioStatEntry `json:"io_service_time_recursive,omitempty"`
   134  	IoWaitTimeRecursive     []BlkioStatEntry `json:"io_wait_time_recursive,omitempty"`
   135  	IoMergedRecursive       []BlkioStatEntry `json:"io_merged_recursive,omitempty"`
   136  	IoTimeRecursive         []BlkioStatEntry `json:"io_time_recursive,omitempty"`
   137  	SectorsRecursive        []BlkioStatEntry `json:"sectors_recursive,omitempty"`
   138  }
   139  
   140  type HugetlbStats struct {
   141  	// current res_counter usage for hugetlb
   142  	Usage uint64 `json:"usage,omitempty"`
   143  	// maximum usage ever recorded.
   144  	MaxUsage uint64 `json:"max_usage,omitempty"`
   145  	// number of times hugetlb usage allocation failure.
   146  	Failcnt uint64 `json:"failcnt"`
   147  }
   148  
   149  type RdmaEntry struct {
   150  	Device     string `json:"device,omitempty"`
   151  	HcaHandles uint32 `json:"hca_handles,omitempty"`
   152  	HcaObjects uint32 `json:"hca_objects,omitempty"`
   153  }
   154  
   155  type RdmaStats struct {
   156  	RdmaLimit   []RdmaEntry `json:"rdma_limit,omitempty"`
   157  	RdmaCurrent []RdmaEntry `json:"rdma_current,omitempty"`
   158  }
   159  
   160  type Stats struct {
   161  	CpuStats    CpuStats    `json:"cpu_stats,omitempty"`
   162  	CPUSetStats CPUSetStats `json:"cpuset_stats,omitempty"`
   163  	MemoryStats MemoryStats `json:"memory_stats,omitempty"`
   164  	PidsStats   PidsStats   `json:"pids_stats,omitempty"`
   165  	BlkioStats  BlkioStats  `json:"blkio_stats,omitempty"`
   166  	// the map is in the format "size of hugepage: stats of the hugepage"
   167  	HugetlbStats map[string]HugetlbStats `json:"hugetlb_stats,omitempty"`
   168  	RdmaStats    RdmaStats               `json:"rdma_stats,omitempty"`
   169  }
   170  
   171  func NewStats() *Stats {
   172  	memoryStats := MemoryStats{Stats: make(map[string]uint64)}
   173  	hugetlbStats := make(map[string]HugetlbStats)
   174  	return &Stats{MemoryStats: memoryStats, HugetlbStats: hugetlbStats}
   175  }
   176  

View as plain text