mirror of https://github.com/nicolargo/glances.git
Avoid none in rate computation
This commit is contained in:
parent
28ae053e4b
commit
1434d3ad5c
|
|
@ -59,6 +59,7 @@ class GlancesStdout:
|
|||
stat = stats.get_plugin(plugin).get_export()
|
||||
else:
|
||||
continue
|
||||
|
||||
# Display stats
|
||||
if attribute is not None:
|
||||
# With attribute
|
||||
|
|
|
|||
|
|
@ -114,10 +114,15 @@ class NetworkPlugin(GlancesPluginModel):
|
|||
"""
|
||||
if self.input_method == 'local':
|
||||
stats = self.update_local()
|
||||
|
||||
# Update the stats
|
||||
for stat in stats:
|
||||
if stat.get('bytes_recv') is None:
|
||||
print(f"def update: bytes_recv is None for {stat['interface_name']}")
|
||||
|
||||
else:
|
||||
stats = self.get_init_value()
|
||||
|
||||
# Update the stats
|
||||
self.stats = stats
|
||||
|
||||
return self.stats
|
||||
|
|
|
|||
|
|
@ -1187,12 +1187,12 @@ class GlancesPluginModel:
|
|||
if self.time_since_last_update > 0:
|
||||
stat[field + '_rate_per_sec'] = stat[field] // self.time_since_last_update
|
||||
else:
|
||||
stat[field] = None
|
||||
stat[field + '_rate_per_sec'] = None
|
||||
stat[field] = 0
|
||||
stat[field + '_rate_per_sec'] = 0
|
||||
else:
|
||||
# Avoid strange rate at the first run
|
||||
stat[field] = None
|
||||
stat[field + '_rate_per_sec'] = None
|
||||
stat[field] = 0
|
||||
stat[field + '_rate_per_sec'] = 0
|
||||
return stat
|
||||
|
||||
def compute_rate_on_list(self, stats, stats_previous):
|
||||
|
|
|
|||
Loading…
Reference in New Issue