From a550afbd2538a1f57c758deaf01c68c3d5c6f556 Mon Sep 17 00:00:00 2001 From: nicolargo Date: Sun, 13 Apr 2025 16:36:29 +0200 Subject: [PATCH] Take into account @amard33p comment - https://github.com/nicolargo/glances/issues/2394#issuecomment-2794522951 --- glances/plugins/network/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/glances/plugins/network/__init__.py b/glances/plugins/network/__init__.py index 449a2d5d..c753876d 100644 --- a/glances/plugins/network/__init__.py +++ b/glances/plugins/network/__init__.py @@ -300,11 +300,11 @@ class PluginModel(GlancesPluginModel): to_bit = 8 unit = 'b' - if args.network_cumul and 'bytes_recv' in i and 'bytes_sent' in i: + if args.network_cumul and i.get('bytes_recv') is not None and i.get('bytes_sent') is not None: rx = self.auto_unit(int(i['bytes_recv'] * to_bit)) + unit tx = self.auto_unit(int(i['bytes_sent'] * to_bit)) + unit ax = self.auto_unit(int(i['bytes_all'] * to_bit)) + unit - elif 'bytes_recv_rate_per_sec' in i and 'bytes_sent_rate_per_sec' in i: + elif i.get('bytes_recv_rate_per_sec') is not None and i.get('bytes_sent_rate_per_sec') is not None: rx = self.auto_unit(int(i['bytes_recv_rate_per_sec'] * to_bit)) + unit tx = self.auto_unit(int(i['bytes_sent_rate_per_sec'] * to_bit)) + unit ax = self.auto_unit(int(i['bytes_all_rate_per_sec'] * to_bit)) + unit