Renamed CpuUsage to CpuStats

This commit is contained in:
Diptanu Choudhury 2016-05-21 00:49:17 -07:00
parent 77357ccf80
commit cfd3016747
5 changed files with 15 additions and 11 deletions

View File

@ -13,7 +13,7 @@ type MemoryStats struct {
KernelMaxUsage uint64 KernelMaxUsage uint64
} }
type CpuUsage struct { type CpuStats struct {
SystemMode float64 SystemMode float64
UserMode float64 UserMode float64
ThrottledPeriods uint64 ThrottledPeriods uint64
@ -23,7 +23,7 @@ type CpuUsage struct {
type TaskResourceUsage struct { type TaskResourceUsage struct {
MemoryStats *MemoryStats MemoryStats *MemoryStats
CpuStats *CpuUsage CpuStats *CpuStats
} }
// RestartPolicy defines how the Nomad client restarts // RestartPolicy defines how the Nomad client restarts

View File

@ -991,7 +991,7 @@ func (h *DockerHandle) monitorUsage() {
MaxUsage: s.MemoryStats.MaxUsage, MaxUsage: s.MemoryStats.MaxUsage,
} }
cs := &cstructs.CpuUsage{ cs := &cstructs.CpuStats{
SystemMode: float64(s.CPUStats.CPUUsage.UsageInKernelmode), SystemMode: float64(s.CPUStats.CPUUsage.UsageInKernelmode),
UserMode: float64(s.CPUStats.CPUUsage.UsageInKernelmode), UserMode: float64(s.CPUStats.CPUUsage.UsageInKernelmode),
ThrottledPeriods: s.CPUStats.ThrottlingData.ThrottledPeriods, ThrottledPeriods: s.CPUStats.ThrottlingData.ThrottledPeriods,

View File

@ -497,7 +497,7 @@ func (e *UniversalExecutor) PidStats() (map[int]*cstructs.TaskResourceUsage, err
ms.Swap = memInfo.Swap ms.Swap = memInfo.Swap
} }
cs := &cstructs.CpuUsage{} cs := &cstructs.CpuStats{}
if cpuStats, err := p.Times(); err == nil { if cpuStats, err := p.Times(); err == nil {
cs.SystemMode = cpuStats.System cs.SystemMode = cpuStats.System
cs.UserMode = cpuStats.User cs.UserMode = cpuStats.User
@ -739,7 +739,7 @@ func (e *UniversalExecutor) resourceUsagePids() (*cstructs.TaskResourceUsage, er
totalSwap += rs.MemoryStats.Swap totalSwap += rs.MemoryStats.Swap
} }
totalCPU := &cstructs.CpuUsage{ totalCPU := &cstructs.CpuStats{
SystemMode: systemModeCPU, SystemMode: systemModeCPU,
UserMode: userModeCPU, UserMode: userModeCPU,
Percent: percent, Percent: percent,

View File

@ -151,14 +151,14 @@ func (e *UniversalExecutor) Stats() (*cstructs.TaskResourceUsage, error) {
} }
// CPU Related Stats // CPU Related Stats
totalProcessCPUUsage := stats.CpuStats.CpuUsage.TotalUsage totalProcessCPUUsage := stats.CpuStats.CpuStats.TotalUsage
userModeTime := stats.CpuStats.CpuUsage.UsageInUsermode userModeTime := stats.CpuStats.CpuStats.UsageInUsermode
kernelModeTime := stats.CpuStats.CpuUsage.UsageInKernelmode kernelModeTime := stats.CpuStats.CpuStats.UsageInKernelmode
umTicks := (userModeTime * clockTicks) / nanosecondsInSecond umTicks := (userModeTime * clockTicks) / nanosecondsInSecond
kmTicks := (kernelModeTime * clockTicks) / nanosecondsInSecond kmTicks := (kernelModeTime * clockTicks) / nanosecondsInSecond
cs := &cstructs.CpuUsage{ cs := &cstructs.CpuStats{
SystemMode: float64(kmTicks), SystemMode: float64(kmTicks),
UserMode: float64(umTicks), UserMode: float64(umTicks),
ThrottledPeriods: stats.CpuStats.ThrottlingData.ThrottledPeriods, ThrottledPeriods: stats.CpuStats.ThrottlingData.ThrottledPeriods,

View File

@ -85,6 +85,7 @@ type CheckResult struct {
Err error Err error
} }
// MemoryStats holds memory usage related stats
type MemoryStats struct { type MemoryStats struct {
RSS uint64 RSS uint64
Cache uint64 Cache uint64
@ -94,7 +95,8 @@ type MemoryStats struct {
KernelMaxUsage uint64 KernelMaxUsage uint64
} }
type CpuUsage struct { // CpuStats holds cpu usage related stats
type CpuStats struct {
SystemMode float64 SystemMode float64
UserMode float64 UserMode float64
ThrottledPeriods uint64 ThrottledPeriods uint64
@ -102,8 +104,10 @@ type CpuUsage struct {
Percent float64 Percent float64
} }
// TaskResourceUsage holds aggregated resource usage of all processes in a Task
// and the resource usage of the individual pids
type TaskResourceUsage struct { type TaskResourceUsage struct {
MemoryStats *MemoryStats MemoryStats *MemoryStats
CpuStats *CpuUsage CpuStats *CpuStats
Timestamp time.Time Timestamp time.Time
} }