提交 ad62f25a 编写于 作者: N nicolargo

Merge branch 'refactorplugins' into develop

......@@ -98,12 +98,6 @@ class Plugin(GlancesPlugin):
elif self.input_method == 'snmp':
self.update_snmp()
# Update the history list
self.update_stats_history()
# Update the view
self.update_views()
return self.stats
def update_local(self):
......
......@@ -142,12 +142,6 @@ class Plugin(GlancesPlugin):
# No standard way for the moment...
pass
# Update the history list
self.update_stats_history('disk_name')
# Update the view
self.update_views()
return self.stats
def update_views(self):
......
......@@ -237,9 +237,6 @@ class Plugin(GlancesPlugin):
# Not available
pass
# Update the view
self.update_views()
return self.stats
def get_docker_cpu(self, container_id, all_stats):
......
......@@ -180,12 +180,6 @@ class Plugin(GlancesPlugin):
'key': self.get_key()}
self.stats.append(fs_current)
# Update the history list
self.update_stats_history('mnt_point')
# Update the view
self.update_views()
return self.stats
def update_views(self):
......
......@@ -105,9 +105,6 @@ class Plugin(GlancesPlugin):
# Not implemented yet
pass
# Update the view
self.update_views()
return self.stats
def update_views(self):
......
......@@ -96,11 +96,9 @@ class Plugin(GlancesPlugin):
# not available
pass
# Update the view
self.update_views()
self.stats = sorted(self.stats, key=operator.itemgetter(
'irq_rate'), reverse=True)[:5] # top 5 IRQ by rate/s
return self.stats
def update_views(self):
......
......@@ -109,12 +109,6 @@ class Plugin(GlancesPlugin):
self.stats['cpucore'] = self.nb_log_core
# Update the history list
self.update_stats_history()
# Update the view
self.update_views()
return self.stats
def update_views(self):
......
......@@ -157,12 +157,6 @@ class Plugin(GlancesPlugin):
# percent: the percentage usage calculated as (total - available) / total * 100.
self.stats['percent'] = float((self.stats['total'] - self.stats['free']) / self.stats['total'] * 100)
# Update the history list
self.update_stats_history()
# Update the view
self.update_views()
return self.stats
def update_views(self):
......
......@@ -132,12 +132,6 @@ class Plugin(GlancesPlugin):
self.stats['percent'] = float(
(self.stats['total'] - self.stats['free']) / self.stats['total'] * 100)
# Update the history list
self.update_stats_history()
# Update the view
self.update_views()
return self.stats
def update_views(self):
......
......@@ -224,12 +224,6 @@ class Plugin(GlancesPlugin):
# Save stats to compute next bitrate
self.network_old = network_new
# Update the history list
self.update_stats_history(self.get_key())
# Update the view
self.update_views()
return self.stats
def update_views(self):
......
......@@ -124,8 +124,14 @@ class GlancesPlugin(object):
logger.debug("Reset history for plugin {0} (items: {1})".format(self.plugin_name, reset_list))
self.stats_history.reset()
def update_stats_history(self, item_name=''):
def update_stats_history(self):
"""Update stats history."""
# If the plugin data is a dict, the dict's key should be used
if self.get_key() is None:
item_name = ''
else:
item_name = self.get_key()
# Build the history
if self.stats and self._history_enable():
for i in self.get_items_history_list():
if isinstance(self.stats, list):
......
......@@ -86,9 +86,6 @@ class Plugin(GlancesPlugin):
self.stats['cpu_hz_current'] = cpu_info['hz_actual_raw'][0]
self.stats['cpu_hz'] = cpu_info['hz_advertised_raw'][0]
# Update the view
self.update_views()
return self.stats
def update_views(self):
......
......@@ -72,9 +72,6 @@ class Plugin(GlancesPlugin):
# No standard way for the moment...
pass
# Update the view
self.update_views()
return self.stats
def msg_curse(self, args=None):
......
......@@ -132,9 +132,6 @@ class Plugin(GlancesPlugin):
pass
# Update the view
self.update_views()
return self.stats
def __set_type(self, stats, sensor_type):
......
......@@ -124,9 +124,6 @@ class Plugin(GlancesPlugin):
# Not implemented yet
pass
# Update the view
self.update_views()
return self.stats
def get_alert(self, value):
......
......@@ -154,8 +154,12 @@ class GlancesStats(object):
# If current plugin is disable
# then continue to next plugin
continue
# Update the stats
# Update the stats...
self._plugins[p].update()
# ... the history
self._plugins[p].update_stats_history()
# ... and the views
self._plugins[p].update_views()
def export(self, input_stats=None):
"""Export all the stats.
......
......@@ -109,8 +109,13 @@ class GlancesStatsClientSNMP(GlancesStats):
self._plugins[p].input_method = 'snmp'
self._plugins[p].short_system_name = self.system_name
# Update the stats
# Update the stats...
try:
self._plugins[p].update()
except Exception as e:
logger.error("Update {} failed: {}".format(p, e))
else:
# ... the history
self._plugins[p].update_stats_history()
# ... and the views
self._plugins[p].update_views()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册