2014-05-23 19:45:53 +00:00
|
|
|
package cgroups
|
|
|
|
|
|
|
|
type ThrottlingData struct {
|
|
|
|
// Number of periods with throttling active
|
2014-05-28 00:01:08 +00:00
|
|
|
Periods uint64 `json:"periods,omitempty"`
|
2014-05-23 19:45:53 +00:00
|
|
|
// Number of periods when the container hit its throttling limit.
|
2014-05-28 00:01:08 +00:00
|
|
|
ThrottledPeriods uint64 `json:"throttled_periods,omitempty"`
|
2014-05-23 19:45:53 +00:00
|
|
|
// Aggregate time the container was throttled for in nanoseconds.
|
2014-05-28 00:01:08 +00:00
|
|
|
ThrottledTime uint64 `json:"throttled_time,omitempty"`
|
2014-05-23 19:45:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type CpuUsage struct {
|
|
|
|
// percentage of available CPUs currently being used.
|
2014-05-28 00:01:08 +00:00
|
|
|
PercentUsage uint64 `json:"percent_usage,omitempty"`
|
2014-05-23 19:45:53 +00:00
|
|
|
// nanoseconds of cpu time consumed over the last 100 ms.
|
2014-05-28 00:01:08 +00:00
|
|
|
CurrentUsage uint64 `json:"current_usage,omitempty"`
|
2014-05-23 19:45:53 +00: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 00:01:08 +00:00
|
|
|
Usage uint64 `json:"usage,omitempty"`
|
2014-05-23 19:45:53 +00:00
|
|
|
// maximum usage ever recorded.
|
2014-05-28 00:01:08 +00:00
|
|
|
MaxUsage uint64 `json:"max_usage,omitempty"`
|
2014-05-23 19:45:53 +00:00
|
|
|
// TODO(vishh): Export these as stronger types.
|
|
|
|
// all the stats exported via memory.stat.
|
2014-05-28 00:01:08 +00:00
|
|
|
Stats map[string]uint64 `json:"stats,omitempty"`
|
2014-05-23 19:45:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type BlkioStatEntry struct {
|
2014-05-28 00:01:08 +00:00
|
|
|
Major uint64 `json:"major,omitempty"`
|
|
|
|
Minor uint64 `json:"minor,omitempty"`
|
2014-05-23 19:45:53 +00:00
|
|
|
Op string `json:"op,omitempty"`
|
2014-05-28 00:01:08 +00:00
|
|
|
Value uint64 `json:"value,omitempty"`
|
2014-05-23 19:45:53 +00:00
|
|
|
}
|
|
|
|
|
2014-05-28 00:01:08 +00:00
|
|
|
type BlkioStats struct {
|
2014-05-23 19:45:53 +00: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 00:01:08 +00:00
|
|
|
SectorsRecursive []BlkioStatEntry `json:"sectors_recursive,omitempty"`
|
2014-05-23 19:45:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// TODO(Vishh): Remove freezer from stats since it does not logically belong in stats.
|
|
|
|
type FreezerStats struct {
|
|
|
|
ParentState string `json:"parent_state,omitempty"`
|
|
|
|
SelfState string `json:"self_state,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type Stats struct {
|
|
|
|
CpuStats CpuStats `json:"cpu_stats,omitempty"`
|
|
|
|
MemoryStats MemoryStats `json:"memory_stats,omitempty"`
|
2014-05-28 00:01:08 +00:00
|
|
|
BlkioStats BlkioStats `json:"blkio_stats,omitempty"`
|
2014-05-23 19:45:53 +00:00
|
|
|
FreezerStats FreezerStats `json:"freezer_stats,omitempty"`
|
|
|
|
}
|
2014-05-28 00:01:08 +00:00
|
|
|
|
|
|
|
func NewStats() *Stats {
|
|
|
|
memoryStats := MemoryStats{Stats: make(map[string]uint64)}
|
|
|
|
return &Stats{MemoryStats: memoryStats}
|
|
|
|
}
|