From 64d5d8af08021eba73a02367759e032b907d5787 Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 4 May 2021 09:53:55 +0200 Subject: [PATCH] Added check to ensure network stats for container exist before reading them --- plugins/docker/docker_ | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/docker/docker_ b/plugins/docker/docker_ index cce10e15..3f313c8a 100755 --- a/plugins/docker/docker_ +++ b/plugins/docker/docker_ @@ -320,9 +320,10 @@ def print_containers_network(client): for container, stats in parallel_container_stats(client): tx_bytes = 0 rx_bytes = 0 - for data in stats['networks'].values(): - tx_bytes += data['tx_bytes'] - rx_bytes += data['rx_bytes'] + if "networks" in stats: + for data in stats['networks'].values(): + tx_bytes += data['tx_bytes'] + rx_bytes += data['rx_bytes'] clean_container_name = clean_fieldname(container.name) print(clean_container_name + '_up.value', tx_bytes) print(clean_container_name + '_down.value', rx_bytes)