summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicolargo <nicolas@nicolargo.com>2024-04-22 11:41:38 +0200
committernicolargo <nicolas@nicolargo.com>2024-04-22 11:41:38 +0200
commitd1fdb90c8961da7bfdb0e31b81626d8514536e54 (patch)
tree0a8383c1eee201339b97e448b0f4e2c51fdb3bc0
parent01097af0ab9244d169a49550b93a64b3a9aad3de (diff)
Avoid arror when a new network interface is created on the fly
-rw-r--r--glances/plugins/network/__init__.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/glances/plugins/network/__init__.py b/glances/plugins/network/__init__.py
index be354355..9e6a6e85 100644
--- a/glances/plugins/network/__init__.py
+++ b/glances/plugins/network/__init__.py
@@ -297,14 +297,18 @@ class PluginModel(GlancesPluginModel):
to_bit = 8
unit = 'b'
- if args.network_cumul:
+ if args.network_cumul and 'bytes_recv' in i:
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
- else:
+ elif 'bytes_recv_rate_per_sec' in i:
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
+ else:
+ # Avoid issue when a new interface is created on the fly
+ # Example: start Glances, then start a new container
+ continue
# New line
ret.append(self.curse_new_line())