2014-05-24 03:45:53 +08:00
|
|
|
package cgroups
|
|
|
|
|
|
|
|
type ThrottlingData struct {
|
|
|
|
// Number of periods with throttling active
|
2014-05-28 08:01:08 +08:00
|
|
|
Periods uint64 `json:"periods,omitempty"`
|
2014-05-24 03:45:53 +08:00
|
|
|
// Number of periods when the container hit its throttling limit.
|
2014-05-28 08:01:08 +08:00
|
|
|
ThrottledPeriods uint64 `json:"throttled_periods,omitempty"`
|
2014-05-24 03:45:53 +08:00
|
|
|
// Aggregate time the container was throttled for in nanoseconds.
|
2014-05-28 08:01:08 +08:00
|
|
|
ThrottledTime uint64 `json:"throttled_time,omitempty"`
|
2014-05-24 03:45:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
type CpuUsage struct {
|
|
|
|
// percentage of available CPUs currently being used.
|
2014-05-28 08:01:08 +08:00
|
|
|
PercentUsage uint64 `json:"percent_usage,omitempty"`
|
2014-05-24 03:45:53 +08:00
|
|
|
// nanoseconds of cpu time consumed over the last 100 ms.
|
2014-06-19 18:35:36 +08:00
|
|
|
CurrentUsage uint64 `json:"current_usage,omitempty"`
|
|
|
|
// total nanoseconds of cpu time consumed
|
|
|
|
TotalUsage uint64 `json:"total_usage,omitempty"`
|
|
|
|
PercpuUsage []uint64 `json:"percpu_usage,omitempty"`
|
2014-06-04 14:41:03 +08:00
|
|
|
// 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"`
|
2014-05-24 03:45:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
type CpuStats struct {
|
|
|
|
CpuUsage CpuUsage `json:"cpu_usage,omitempty"`
|
|
|
|
ThrottlingData ThrottlingData `json:"throlling_data,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type MemoryStats struct {
|
|
|
|
// current res_counter usage for memory
|
2014-05-28 08:01:08 +08:00
|
|
|
Usage uint64 `json:"usage,omitempty"`
|
2014-05-24 03:45:53 +08:00
|
|
|
// maximum usage ever recorded.
|
2014-05-28 08:01:08 +08:00
|
|
|
MaxUsage uint64 `json:"max_usage,omitempty"`
|
2014-05-24 03:45:53 +08:00
|
|
|
// TODO(vishh): Export these as stronger types.
|
|
|
|
// all the stats exported via memory.stat.
|
2014-05-28 08:01:08 +08:00
|
|
|
Stats map[string]uint64 `json:"stats,omitempty"`
|
2014-06-04 14:41:03 +08:00
|
|
|
// number of times memory usage hits limits.
|
|
|
|
Failcnt uint64 `json:"failcnt"`
|
2014-05-24 03:45:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
type BlkioStatEntry struct {
|
2014-05-28 08:01:08 +08:00
|
|
|
Major uint64 `json:"major,omitempty"`
|
|
|
|
Minor uint64 `json:"minor,omitempty"`
|
2014-05-24 03:45:53 +08:00
|
|
|
Op string `json:"op,omitempty"`
|
2014-05-28 08:01:08 +08:00
|
|
|
Value uint64 `json:"value,omitempty"`
|
2014-05-24 03:45:53 +08:00
|
|
|
}
|
|
|
|
|
2014-05-28 08:01:08 +08:00
|
|
|
type BlkioStats struct {
|
2014-05-24 03:45:53 +08:00
|
|
|
// number of bytes tranferred to and from the block device
|
|
|
|
IoServiceBytesRecursive []BlkioStatEntry `json:"io_service_bytes_recursive,omitempty"`
|
|
|
|
IoServicedRecursive []BlkioStatEntry `json:"io_serviced_recusrive,omitempty"`
|
|
|
|
IoQueuedRecursive []BlkioStatEntry `json:"io_queue_recursive,omitempty"`
|
2014-05-28 08:01:08 +08:00
|
|
|
SectorsRecursive []BlkioStatEntry `json:"sectors_recursive,omitempty"`
|
2014-05-24 03:45:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
type Stats struct {
|
2014-07-14 07:14:05 +08:00
|
|
|
CpuStats CpuStats `json:"cpu_stats,omitempty"`
|
|
|
|
MemoryStats MemoryStats `json:"memory_stats,omitempty"`
|
|
|
|
BlkioStats BlkioStats `json:"blkio_stats,omitempty"`
|
2014-05-24 03:45:53 +08:00
|
|
|
}
|
2014-05-28 08:01:08 +08:00
|
|
|
|
|
|
|
func NewStats() *Stats {
|
|
|
|
memoryStats := MemoryStats{Stats: make(map[string]uint64)}
|
|
|
|
return &Stats{MemoryStats: memoryStats}
|
|
|
|
}
|