From e9583ff368dfcb366a70eb642ec3721b8db61191 Mon Sep 17 00:00:00 2001 From: Stephen Palfreyman Date: Mon, 14 Mar 2022 22:17:52 +0000 Subject: [PATCH] Update blkio stats for newer versions of docker Fixes #50 Newer versions of docker include a discard metric for blkio stats --- dockerplugin.db | 3 ++- dockerplugin.py | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/dockerplugin.db b/dockerplugin.db index a8e6e4f..0940995 100644 --- a/dockerplugin.db +++ b/dockerplugin.db @@ -1,4 +1,5 @@ -blkio read:COUNTER:0:U, write:COUNTER:0:U, sync:COUNTER:0:U, async:COUNTER:0:U, total:COUNTER:0:U +blkio read:COUNTER:0:U, write:COUNTER:0:U, sync:COUNTER:0:U, async:COUNTER:0:U, discard:COUNTER:0:U, total:COUNTER:0:U +blkio.old read:COUNTER:0:U, write:COUNTER:0:U, sync:COUNTER:0:U, async:COUNTER:0:U, total:COUNTER:0:U blkio.single value:COUNTER:0:U cpu.percpu.usage value:COUNTER:0:U cpu.usage total:COUNTER:0:U, kernelmode:COUNTER:0:U, usermode:COUNTER:0:U, system:COUNTER:0:U diff --git a/dockerplugin.py b/dockerplugin.py index 7cf3b83..51e7577 100755 --- a/dockerplugin.py +++ b/dockerplugin.py @@ -95,9 +95,12 @@ def read(cls, container, stats, t): device_stats[k].append(value['value']) for type_instance, values in device_stats.items(): - if len(values) == 5: + if len(values) == 6: cls.emit(container, 'blkio', values, type_instance=type_instance, t=t) + elif len(values) == 5: + cls.emit(container, 'blkio.old', values, + type_instance=type_instance, t=t) elif len(values) == 1: # For some reason, some fields contains only one value and # the 'op' field is empty. Need to investigate this