From 48ff7469c0a6886165620dcb37e2d25a86621a94 Mon Sep 17 00:00:00 2001 From: Matthias Tafelmeier Date: Fri, 24 Nov 2023 15:58:30 +0100 Subject: [PATCH] improve decode error handling further Return empty result in case of decode error. Also print the raw socket diag result. --- prometheus_ss_exporter/stats.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/prometheus_ss_exporter/stats.py b/prometheus_ss_exporter/stats.py index 97f814d..14abf09 100644 --- a/prometheus_ss_exporter/stats.py +++ b/prometheus_ss_exporter/stats.py @@ -48,13 +48,13 @@ def provide_tcp_stats(self): self._reset_io() - sk_stats_parsed = dict() + sk_stats_parsed = dict(TCP=dict(flows=list())) try: sk_stats_parsed = json.loads(sk_stats_raw) except json.decoder.JSONDecodeError as err: logging.error("Failed parsing sample") logging.error("-----") - logging.error(sk_stats_parsed) + logging.error(sk_stats_raw) logging.error("-----") return sk_stats_parsed