2016-01-05 22:56:27 +00:00
|
|
|
// +build linux
|
|
|
|
|
|
|
|
package cgroups
|
|
|
|
|
|
|
|
type ThrottlingData struct {
|
|
|
|
// Number of periods with throttling active
|
|
|
|
Periods uint64 `json:"periods,omitempty"`
|
|
|
|
// Number of periods when the container hit its throttling limit.
|
|
|
|
ThrottledPeriods uint64 `json:"throttled_periods,omitempty"`
|
|
|
|
// Aggregate time the container was throttled for in nanoseconds.
|
|
|
|
ThrottledTime uint64 `json:"throttled_time,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// All CPU stats are aggregate since container inception.
|
|
|
|
type CpuUsage struct {
|
|
|
|
// Total CPU time consumed.
|
|
|
|
// Units: nanoseconds.
|
|
|
|
TotalUsage uint64 `json:"total_usage,omitempty"`
|
|
|
|
// Total CPU time consumed per core.
|
|
|
|
// Units: nanoseconds.
|
|
|
|
PercpuUsage []uint64 `json:"percpu_usage,omitempty"`
|
|
|
|
// Time spent by tasks of the cgroup in kernel mode.
|
|
|
|
// Units: nanoseconds.
|
|
|
|
UsageInKernelmode uint64 `json:"usage_in_kernelmode"`
|
|
|
|
// Time spent by tasks of the cgroup in user mode.
|
|
|
|
// Units: nanoseconds.
|
|
|
|
UsageInUsermode uint64 `json:"usage_in_usermode"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type CpuStats struct {
|
|
|
|
CpuUsage CpuUsage `json:"cpu_usage,omitempty"`
|
|
|
|
ThrottlingData ThrottlingData `json:"throttling_data,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type MemoryData struct {
|
|
|
|
Usage uint64 `json:"usage,omitempty"`
|
|
|
|
MaxUsage uint64 `json:"max_usage,omitempty"`
|
|
|
|
Failcnt uint64 `json:"failcnt"`
|
2016-02-11 22:07:34 +00:00
|
|
|
Limit uint64 `json:"limit"`
|
2016-01-05 22:56:27 +00:00
|
|
|
}
|
2016-02-11 22:07:34 +00:00
|
|
|
|
2016-01-05 22:56:27 +00:00
|
|
|
type MemoryStats struct {
|
|
|
|
// memory used for cache
|
|
|
|
Cache uint64 `json:"cache,omitempty"`
|
|
|
|
// usage of memory
|
|
|
|
Usage MemoryData `json:"usage,omitempty"`
|
|
|
|
// usage of memory + swap
|
|
|
|
SwapUsage MemoryData `json:"swap_usage,omitempty"`
|
2016-03-07 18:30:59 +00:00
|
|
|
// usage of kernel memory
|
2016-01-05 22:56:27 +00:00
|
|
|
KernelUsage MemoryData `json:"kernel_usage,omitempty"`
|
|
|
|
Stats map[string]uint64 `json:"stats,omitempty"`
|
|
|
|
}
|
|
|
|
|
2016-02-11 22:07:34 +00:00
|
|
|
type PidsStats struct {
|
|
|
|
// number of pids in the cgroup
|
|
|
|
Current uint64 `json:"current,omitempty"`
|
2016-03-15 18:19:21 +00:00
|
|
|
// active pids hard limit
|
|
|
|
Max uint64 `json:"max,omitempty"`
|
2016-02-11 22:07:34 +00:00
|
|
|
}
|
|
|
|
|
2016-01-05 22:56:27 +00:00
|
|
|
type BlkioStatEntry struct {
|
|
|
|
Major uint64 `json:"major,omitempty"`
|
|
|
|
Minor uint64 `json:"minor,omitempty"`
|
|
|
|
Op string `json:"op,omitempty"`
|
|
|
|
Value uint64 `json:"value,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type BlkioStats struct {
|
|
|
|
// number of bytes tranferred to and from the block device
|
|
|
|
IoServiceBytesRecursive []BlkioStatEntry `json:"io_service_bytes_recursive,omitempty"`
|
|
|
|
IoServicedRecursive []BlkioStatEntry `json:"io_serviced_recursive,omitempty"`
|
|
|
|
IoQueuedRecursive []BlkioStatEntry `json:"io_queue_recursive,omitempty"`
|
|
|
|
IoServiceTimeRecursive []BlkioStatEntry `json:"io_service_time_recursive,omitempty"`
|
|
|
|
IoWaitTimeRecursive []BlkioStatEntry `json:"io_wait_time_recursive,omitempty"`
|
|
|
|
IoMergedRecursive []BlkioStatEntry `json:"io_merged_recursive,omitempty"`
|
|
|
|
IoTimeRecursive []BlkioStatEntry `json:"io_time_recursive,omitempty"`
|
|
|
|
SectorsRecursive []BlkioStatEntry `json:"sectors_recursive,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type HugetlbStats struct {
|
|
|
|
// current res_counter usage for hugetlb
|
|
|
|
Usage uint64 `json:"usage,omitempty"`
|
|
|
|
// maximum usage ever recorded.
|
|
|
|
MaxUsage uint64 `json:"max_usage,omitempty"`
|
2016-03-07 18:30:59 +00:00
|
|
|
// number of times hugetlb usage allocation failure.
|
2016-01-05 22:56:27 +00:00
|
|
|
Failcnt uint64 `json:"failcnt"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type Stats struct {
|
|
|
|
CpuStats CpuStats `json:"cpu_stats,omitempty"`
|
|
|
|
MemoryStats MemoryStats `json:"memory_stats,omitempty"`
|
2016-02-11 22:07:34 +00:00
|
|
|
PidsStats PidsStats `json:"pids_stats,omitempty"`
|
2016-01-05 22:56:27 +00:00
|
|
|
BlkioStats BlkioStats `json:"blkio_stats,omitempty"`
|
|
|
|
// the map is in the format "size of hugepage: stats of the hugepage"
|
|
|
|
HugetlbStats map[string]HugetlbStats `json:"hugetlb_stats,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewStats() *Stats {
|
|
|
|
memoryStats := MemoryStats{Stats: make(map[string]uint64)}
|
|
|
|
hugetlbStats := make(map[string]HugetlbStats)
|
|
|
|
return &Stats{MemoryStats: memoryStats, HugetlbStats: hugetlbStats}
|
|
|
|
}
|