Not all field in CPU export. Had to investigate

This commit is contained in:
nicolargo 2021-05-24 08:05:02 +02:00
parent ab7948c47a
commit 958225051a
4 changed files with 14 additions and 10 deletions

View File

@ -90,7 +90,6 @@ class Export(GlancesExport):
# Loop over plugins to export
for plugin in self.plugins_to_export():
csv_data += [plugin]
if isinstance(all_stats[plugin], list):
for stat in all_stats[plugin]:
# First line: header
@ -108,9 +107,6 @@ 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

@ -75,6 +75,10 @@ class Plugin(GlancesPlugin):
except Exception:
self.nb_log_core = 1
# Force a first update because we need two update to have the first stat
self.update()
self.refresh_timer.set(0)
@GlancesPlugin._check_decorator
@GlancesPlugin._log_result_decorator
def update(self):

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() or self.stats == {} or self.stats == []):
if self.is_enable() and (self.refresh_timer.finished() or self.stats == self.get_init_value):
# Run the method
ret = fct(self, *args, **kw)
# Reset the timer

View File

@ -2,7 +2,7 @@
#
# This file is part of Glances.
#
# Copyright (C) 2019 Nicolargo <nicolas@nicolargo.com>
# Copyright (C) 2021 Nicolargo <nicolas@nicolargo.com>
#
# Glances is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
@ -45,12 +45,9 @@ class GlancesStats(object):
self.args = args
# Load plugins and exports modules
self.first_export = True
self.load_modules(self.args)
# Load the limits (for plugins)
# Not necessary anymore, configuration file is loaded on init
# self.load_limits(self.config)
def __getattr__(self, item):
"""Overwrite the getattr method in case of attribute is not found.
@ -241,6 +238,11 @@ class GlancesStats(object):
Each export module is ran in a dedicated thread.
"""
if self.first_export:
logger.info("Do not export on first iteration because some stats missing")
self.first_export = False
return False
input_stats = input_stats or {}
for e in self._exports:
@ -249,6 +251,8 @@ class GlancesStats(object):
args=(input_stats,))
thread.start()
return True
def getAll(self):
"""Return all the stats (list)."""
return [self._plugins[p].get_raw() for p in self._plugins]