提交 5496fcac 编写于 作者: N Nicolargo

Add view (MVC speeking) for the plugins. LOAD OK.

上级 00353363
......@@ -22,7 +22,6 @@
import psutil
from glances.plugins.glances_plugin import GlancesPlugin
from glances.core.glances_logging import logger
# SNMP OID
# percentage of user CPU time: .1.3.6.1.4.1.2021.11.9.0
......@@ -159,8 +158,6 @@ class Plugin(GlancesPlugin):
if key in self.stats:
self.views[key]['optional'] = True
logger.info(self.views)
def msg_curse(self, args=None):
"""Return the list to display in the UI"""
# Init the return message
......
......@@ -111,8 +111,22 @@ class Plugin(GlancesPlugin):
# Update the history list
self.update_stats_history()
# Update the view
self.update_views()
return self.stats
def update_views(self):
"""Update stats views"""
# Call the father's method
GlancesPlugin.update_views(self)
# Add specifics informations
# Alert and log
self.views['min15']['decoration'] = self.get_alert_log(self.stats['min15'], max=100 * self.stats['cpucore'])
# Alert only
self.views['min5']['decoration'] = self.get_alert(self.stats['min5'], max=100 * self.stats['cpucore'])
def msg_curse(self, args=None):
"""Return the dict to display in the curse interface."""
# Init the return message
......@@ -144,7 +158,7 @@ class Plugin(GlancesPlugin):
ret.append(self.curse_add_line(msg))
msg = '{0:>6.2f}'.format(self.stats['min5'])
ret.append(self.curse_add_line(
msg, self.get_alert(self.stats['min5'], max=100 * self.stats['cpucore'])))
msg, self.get_views(key='min5', option='decoration')))
# New line
ret.append(self.curse_new_line())
# 15min load
......@@ -152,6 +166,6 @@ class Plugin(GlancesPlugin):
ret.append(self.curse_add_line(msg))
msg = '{0:>6.2f}'.format(self.stats['min15'])
ret.append(self.curse_add_line(
msg, self.get_alert_log(self.stats['min15'], max=100 * self.stats['cpucore'])))
msg, self.get_views(key='min15', option='decoration')))
return ret
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册