Correct an issue when stats use old stats (example network). Had also to deal with the export CSV module not working.

pull/1872/head
nicolargo 2021-05-23 23:07:06 +02:00
parent 0417762d96
commit 90b28dc633
5 changed files with 22 additions and 5 deletions

View File

@ -107,6 +107,9 @@ class Export(GlancesExport):
# Others lines: stats
csv_data += itervalues(all_stats[plugin])
logger.info(len(csv_data))
logger.info(csv_data)
# Export to CSV
# Manage header
if self.first_line:

View File

@ -52,6 +52,7 @@ class Plugin(GlancesPlugin):
# We want to display the stat in the curse interface
self.display_curse = True
# Hide stats if it has never been != 0
if config is not None:
self.hide_zero = config.get_bool_value(
@ -60,6 +61,10 @@ class Plugin(GlancesPlugin):
self.hide_zero = False
self.hide_zero_fields = ['read_bytes', 'write_bytes']
# Force a first update because we need two update to have the first stat
self.update()
self.refresh_timer.set(0)
def get_key(self):
"""Return the key of the list."""
return 'disk_name'

View File

@ -95,6 +95,10 @@ class Plugin(GlancesPlugin):
# value: instance of ThreadDockerGrabber
self.thread_list = {}
# Force a first update because we need two update to have the first stat
self.update()
self.refresh_timer.set(0)
def exit(self):
"""Overwrite the exit method to close threads."""
for t in itervalues(self.thread_list):
@ -303,8 +307,8 @@ class Plugin(GlancesPlugin):
precpu_new['system'] = all_stats['precpu_stats'].get(
'system_cpu_usage', None)
# Issue #1857
# If either precpu_stats.online_cpus or cpu_stats.online_cpus is nil
# then for compatibility with older daemons the length of
# If either precpu_stats.online_cpus or cpu_stats.online_cpus is nil
# then for compatibility with older daemons the length of
# the corresponding cpu_usage.percpu_usage array should be used.
if 'online_cpus' in all_stats['cpu_stats'] and \
all_stats['cpu_stats']['online_cpus'] is not None:
@ -558,7 +562,7 @@ class Plugin(GlancesPlugin):
# Get the maximum containers name
# Max size is configurable. See feature request #1723.
name_max_width = min(self.config.get_int_value('docker', 'max_name_size', default=20),
len(max(self.stats['containers'],
len(max(self.stats['containers'],
key=lambda x: len(x['name']))['name']))
msg = ' {:{width}}'.format('Name', width=name_max_width)
ret.append(self.curse_add_line(msg))

View File

@ -60,6 +60,7 @@ class Plugin(GlancesPlugin):
# We want to display the stat in the curse interface
self.display_curse = True
# Hide stats if it has never been != 0
if config is not None:
self.hide_zero = config.get_bool_value(
@ -68,11 +69,15 @@ class Plugin(GlancesPlugin):
self.hide_zero = False
self.hide_zero_fields = ['rx', 'tx']
# Force a first update because we need two update to have the first stat
self.update()
self.refresh_timer.set(0)
def get_key(self):
"""Return the key of the list."""
return 'interface_name'
@GlancesPlugin._check_decorator
# @GlancesPlugin._check_decorator
@GlancesPlugin._log_result_decorator
def update(self):
"""Update network stats using the input method.

View File

@ -1013,7 +1013,7 @@ class GlancesPlugin(object):
- if the refresh_timer is finished
"""
def wrapper(self, *args, **kw):
if self.is_enable() and self.refresh_timer.finished():
if self.is_enable() and (self.refresh_timer.finished() or self.stats == {} or self.stats == []):
# Run the method
ret = fct(self, *args, **kw)
# Reset the timer