diff options
author | Giuseppe Scrivano <gscrivan@redhat.com> | 2020-02-12 11:58:29 +0100 |
---|---|---|
committer | Giuseppe Scrivano <gscrivan@redhat.com> | 2020-02-12 11:58:29 +0100 |
commit | 510fa4ebc8271f929753275428ae2b6047ecc8c7 (patch) | |
tree | 1e1770ea9ec95ce4a3a984b4d9dab44732a5b12f /pkg/api/handlers | |
parent | 6215e1bb218a86c217a66e34f2abd043feca8582 (diff) | |
download | podman-510fa4ebc8271f929753275428ae2b6047ecc8c7.tar.gz podman-510fa4ebc8271f929753275428ae2b6047ecc8c7.tar.bz2 podman-510fa4ebc8271f929753275428ae2b6047ecc8c7.zip |
stats: add SystemUsage
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Diffstat (limited to 'pkg/api/handlers')
-rw-r--r-- | pkg/api/handlers/generic/containers_stats.go | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/pkg/api/handlers/generic/containers_stats.go b/pkg/api/handlers/generic/containers_stats.go index cfc14786f..85757c33e 100644 --- a/pkg/api/handlers/generic/containers_stats.go +++ b/pkg/api/handlers/generic/containers_stats.go @@ -64,6 +64,7 @@ func StatsContainer(w http.ResponseWriter, r *http.Request) { var preCPUStats docker.CPUStats if query.Stream { preRead = time.Now() + systemUsage, _ := cgroups.GetSystemCPUUsage() preCPUStats = docker.CPUStats{ CPUUsage: docker.CPUUsage{ TotalUsage: stats.CPUNano, @@ -71,7 +72,7 @@ func StatsContainer(w http.ResponseWriter, r *http.Request) { UsageInKernelmode: stats.CPUSystemNano, UsageInUsermode: stats.CPUNano - stats.CPUSystemNano, }, - SystemUsage: 0, + SystemUsage: systemUsage, OnlineCPUs: 0, ThrottlingData: docker.ThrottlingData{}, } @@ -125,6 +126,8 @@ func StatsContainer(w http.ResponseWriter, r *http.Request) { InstanceID: "", } + systemUsage, _ := cgroups.GetSystemCPUUsage() + s := handlers.Stats{StatsJSON: docker.StatsJSON{ Stats: docker.Stats{ Read: time.Now(), @@ -150,7 +153,7 @@ func StatsContainer(w http.ResponseWriter, r *http.Request) { UsageInKernelmode: cgroupStat.CPU.Usage.Kernel, UsageInUsermode: cgroupStat.CPU.Usage.Total - cgroupStat.CPU.Usage.Kernel, }, - SystemUsage: 0, + SystemUsage: systemUsage, OnlineCPUs: uint32(len(cgroupStat.CPU.Usage.PerCPU)), ThrottlingData: docker.ThrottlingData{ Periods: 0, |