collectd cpu plugin does not always initialize

This changes the initialization of per cgroup cpuacct timings
to account for cgroup directories that may not be present at the time
the plugin starts. As an example, the docker cgroup is created often
much later or not at all.

Change-Id: Iaf279e650cc16966b40c24a9f55f53fa4696a92b
Closes-Bug: 1855733
Signed-off-by: Jim Gauld <james.gauld@windriver.com>
This commit is contained in:
Jim Gauld 2020-06-26 16:56:04 -04:00
parent 1a5e6c4c3d
commit 1bdd9200bb
1 changed files with 1 additions and 1 deletions

View File

@ -327,7 +327,7 @@ def update_cpu_data(init=False):
for i in t1_cpuacct.keys():
cpuacct[i] = {}
for k, v in t1_cpuacct[i].items():
if k in obj._t0_cpuacct[i]:
if i in obj._t0_cpuacct and k in obj._t0_cpuacct[i]:
cpuacct[i][k] = v - obj._t0_cpuacct[i][k]
else:
cpuacct[i][k] = v