cgroups: skip not existing cpuacct files
if the cpuacct file doesn't exist, ignore it instead of erroring out.
Closes:
@@ -98,16 +98,25 @@ func (c *cpuHandler) Stat(ctr *CgroupControl, m *Metrics) error {
} else {
usage.Total, err = readAcct(ctr, "cpuacct.usage")
if err != nil {
+ if !os.IsNotExist(errors.Cause(err)) {
return err
}
+ usage.Total = 0
+ }
usage.Kernel, err = readAcct(ctr, "cpuacct.usage_sys")
if err != nil {
+ if !os.IsNotExist(errors.Cause(err)) {
return err
}
+ usage.Kernel = 0
+ }
usage.PerCPU, err = readAcctList(ctr, "cpuacct.usage_percpu")
if err != nil {
+ if !os.IsNotExist(errors.Cause(err)) {
return err
}
+ usage.PerCPU = nil
+ }
}
m.CPU = CPUMetrics{Usage: usage}
return nil
