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
}
type CpuUsage struct {
type CpuStats struct {
SystemMode float64
UserMode float64
ThrottledPeriods uint64
@ -23,7 +23,7 @@ type CpuUsage struct {
type TaskResourceUsage struct {
MemoryStats *MemoryStats
CpuStats *CpuUsage
CpuStats *CpuStats
}
// RestartPolicy defines how the Nomad client restarts

View File

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

View File

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

View File

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

View File

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