From cc266ed54cf6732825010171e188919cc95cd1d7 Mon Sep 17 00:00:00 2001 From: Bernerd Schaefer Date: Thu, 19 Jun 2014 12:35:36 +0200 Subject: [PATCH] CpuStats.CpuUsage includes TotalUsage Docker-DCO-1.1-Signed-off-by: Bernerd Schaefer (github: bernerdschaefer) --- cgroups/fs/cpuacct.go | 1 + cgroups/stats.go | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cgroups/fs/cpuacct.go b/cgroups/fs/cpuacct.go index fe831d1b..a3d22c9f 100644 --- a/cgroups/fs/cpuacct.go +++ b/cgroups/fs/cpuacct.go @@ -84,6 +84,7 @@ func (s *cpuacctGroup) GetStats(d *data, stats *cgroups.Stats) error { if err != nil { return err } + stats.CpuStats.CpuUsage.TotalUsage = lastUsage stats.CpuStats.CpuUsage.PercpuUsage = percpuUsage stats.CpuStats.CpuUsage.UsageInKernelmode = (kernelModeUsage * nanosecondsInSecond) / clockTicks stats.CpuStats.CpuUsage.UsageInUsermode = (userModeUsage * nanosecondsInSecond) / clockTicks diff --git a/cgroups/stats.go b/cgroups/stats.go index 20a5f00a..2640245e 100644 --- a/cgroups/stats.go +++ b/cgroups/stats.go @@ -13,8 +13,10 @@ type CpuUsage struct { // percentage of available CPUs currently being used. PercentUsage uint64 `json:"percent_usage,omitempty"` // nanoseconds of cpu time consumed over the last 100 ms. - CurrentUsage uint64 `json:"current_usage,omitempty"` - PercpuUsage []uint64 `json:"percpu_usage,omitempty"` + CurrentUsage uint64 `json:"current_usage,omitempty"` + // total nanoseconds of cpu time consumed + TotalUsage uint64 `json:"total_usage,omitempty"` + 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.