cgroups: fix times conversion

convert the time we read in microseconds to nanoseconds.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
Giuseppe Scrivano
2019-07-02 12:50:15 +02:00
parent 3b9ce8a3ac
commit 7423426f73
2 changed files with 3 additions and 1 deletions

View File

@ -30,7 +30,7 @@ type CgroupControl struct {
additionalControllers []controller
}
// CPUUsage keeps stats for the CPU usage
// CPUUsage keeps stats for the CPU usage (unit: nanoseconds)
type CPUUsage struct {
Kernel uint64
Total uint64

View File

@ -85,12 +85,14 @@ func (c *cpuHandler) Stat(ctr *CgroupControl, m *Metrics) error {
if err != nil {
return err
}
usage.Kernel *= 1000
}
if val, found := values["system_usec"]; found {
usage.Total, err = strconv.ParseUint(cleanString(val[0]), 10, 0)
if err != nil {
return err
}
usage.Total *= 1000
}
// FIXME: How to read usage.PerCPU?
} else {