containerd/patch/0002-sys-sys-count-steal-time-when-calculating-Sys.patch
2019-12-30 12:24:38 +08:00

45 lines
1.3 KiB
Diff

From 003dc7956765712fdf4a893c2d541af2e2d0f300 Mon Sep 17 00:00:00 2001
From: jingrui <jingrui@huawei.com>
Date: Sat, 22 Dec 2018 15:44:50 +0800
Subject: [PATCH 02/27] sys: sys: count steal time when calculating
SystemCPUUsage
reason: count steal time when calculating SystemCPUUsage
cherry-pick from containerd-0.2.8
13f22eecd33d30520ace277822ac5f0acb387e75
containerd: count steal time when calculating SystemCPUUsage
[Changelog]: when counting docker stat in virtual machines, now containerd do not count steal time when calculating SystemCPUUsage, which causes that cpuusage value larger than its actua$
[Author]git
Change-Id: I2b62c9508cbdc444d514116f4bea5aad3d292af5
Signed-off-by: jingrui <jingrui@huawei.com>
---
sys/proc.go | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sys/proc.go b/sys/proc.go
index 496eb1f..82a6351 100644
--- a/sys/proc.go
+++ b/sys/proc.go
@@ -61,11 +61,11 @@ func GetSystemCPUUsage() (uint64, error) {
parts := strings.Fields(line)
switch parts[0] {
case "cpu":
- if len(parts) < 8 {
+ if len(parts) < 9 {
return 0, fmt.Errorf("bad format of cpu stats")
}
var totalClockTicks uint64
- for _, i := range parts[1:8] {
+ for _, i := range parts[1:9] {
v, err := strconv.ParseUint(i, 10, 64)
if err != nil {
return 0, fmt.Errorf("error parsing cpu stats")
--
2.7.4.3