summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicolargo <nicolas@nicolargo.com>2021-03-21 17:11:47 +0100
committernicolargo <nicolas@nicolargo.com>2021-03-21 17:11:47 +0100
commitc96fee907e175ee2b0765da3c14d7b23b1370952 (patch)
tree6d39e7933443168c6dccaa0edb6358952dcaf2d3
parentc5e70b7ccfb01c7432d36a1266d8b3f23404e2a2 (diff)
Refactor the way importants stats are displayed #1826
-rw-r--r--conf/glances.conf26
-rw-r--r--glances/plugins/glances_cpu.py58
-rw-r--r--glances/plugins/glances_mem.py6
-rw-r--r--glances/plugins/glances_memswap.py7
4 files changed, 60 insertions, 37 deletions
diff --git a/conf/glances.conf b/conf/glances.conf
index d7c7d87a..0ed47419 100644
--- a/conf/glances.conf
+++ b/conf/glances.conf
@@ -42,24 +42,38 @@ swap_critical=90
[cpu]
disable=False
+# See https://scoutapm.com/blog/slow_server_flow_chart
+#
+# I/O wait percentage should be lower than 1/# (# = Logical CPU cores)
+# Leave commented to just use the default config:
+# Careful=1/#*100-20% / Warning=1/#*100-10% / Critical=1/#*100
+#iowait_careful=30
+#iowait_warning=40
+#iowait_critical=50
+#
+# Total % is 100 - idle
+total_careful=65
+total_warning=75
+total_critical=85
+total_log=True
+#
# Default values if not defined: 50/70/90 (except for iowait)
user_careful=50
user_warning=70
user_critical=90
-#user_log=False
+user_log=False
#user_critical_action=echo {{user}} {{value}} {{max}} > /tmp/cpu.alert
+#
system_careful=50
system_warning=70
system_critical=90
+system_log=False
+#
steal_careful=50
steal_warning=70
steal_critical=90
#steal_log=True
-# I/O wait percentage should be lower than 1/# (Logical CPU cores)
-# Leave commented to just use the default config (1/#-20% / 1/#-10% / 1/#)
-#iowait_careful=30
-#iowait_warning=40
-#iowait_critical=50
+#
# Context switch limit (core / second)
# Leave commented to just use the default config (critical is 50000*# (Logical CPU cores)
#ctx_switches_careful=10000
diff --git a/glances/plugins/glances_cpu.py b/glances/plugins/glances_cpu.py
index dc2f9e23..4ab2ad1a 100644
--- a/glances/plugins/glances_cpu.py
+++ b/glances/plugins/glances_cpu.py
@@ -19,6 +19,7 @@
"""CPU plugin."""
+from glances.logger import logger
from glances.timer import getTimeSinceLastUpdate
from glances.compat import iterkeys
from glances.cpu_percent import cpu_percent
@@ -196,11 +197,11 @@ class Plugin(GlancesPlugin):
# Add specifics informations
# Alert and log
- for key in ['user', 'system', 'iowait']:
+ for key in ['user', 'system', 'iowait', 'total']:
if key in self.stats:
self.views[key]['decoration'] = self.get_alert_log(self.stats[key], header=key)
# Alert only
- for key in ['steal', 'total']:
+ for key in ['steal']:
if key in self.stats:
self.views[key]['decoration'] = self.get_alert(self.stats[key], header=key)
# Alert only but depend on Core number
@@ -208,7 +209,7 @@ class Plugin(GlancesPlugin):
if key in self.stats:
self.views[key]['decoration'] = self.get_alert(self.stats[key], maximum=100 * self.stats['cpucore'], header=key)
# Optional
- for key in ['nice', 'irq', 'iowait', 'steal', 'ctx_switches', 'interrupts', 'soft_interrupts', 'syscalls']:
+ for key in ['nice', 'irq', 'idle', 'steal', 'ctx_switches', 'interrupts', 'soft_interrupts', 'syscalls']:
if key in self.stats:
self.views[key]['optional'] = True
@@ -239,17 +240,19 @@ class Plugin(GlancesPlugin):
ret.append(self.curse_add_line(msg))
# Total CPU usage
msg = '{:5.1f}%'.format(self.stats['total'])
- if idle_tag:
- ret.append(self.curse_add_line(
- msg, self.get_views(key='total', option='decoration')))
- else:
+ ret.append(self.curse_add_line(
+ msg, self.get_views(key='total', option='decoration')))
+ # if idle_tag:
+ # ret.append(self.curse_add_line(
+ # msg, self.get_views(key='total', option='decoration')))
+ # else:
+ # ret.append(self.curse_add_line(msg))
+ # Idle CPU
+ if 'idle' in self.stats and not idle_tag:
+ msg = ' {:8}'.format('idle:')
+ ret.append(self.curse_add_line(msg))
+ msg = '{:5.1f}%'.format(self.stats['idle'])
ret.append(self.curse_add_line(msg))
- # Nice CPU
- if 'nice' in self.stats:
- msg = ' {:8}'.format('nice:')
- ret.append(self.curse_add_line(msg, optional=self.get_views(key='nice', option='optional')))
- msg = '{:5.1f}%'.format(self.stats['nice'])
- ret.append(self.curse_add_line(msg, optional=self.get_views(key='nice', option='optional')))
# ctx_switches
if 'ctx_switches' in self.stats:
msg = ' {:8}'.format('ctx_sw:')
@@ -301,14 +304,14 @@ class Plugin(GlancesPlugin):
ret.append(self.curse_add_line(msg))
msg = '{:>6}'.format(self.stats['nb_log_core'])
ret.append(self.curse_add_line(msg))
- # IOWait CPU
- if 'iowait' in self.stats:
- msg = ' {:8}'.format('iowait:')
- ret.append(self.curse_add_line(msg, optional=self.get_views(key='iowait', option='optional')))
- msg = '{:5.1f}%'.format(self.stats['iowait'])
+ # Nice CPU
+ if 'nice' in self.stats:
+ msg = ' {:8}'.format('nice:')
ret.append(self.curse_add_line(
- msg, self.get_views(key='iowait', option='decoration'),
- optional=self.get_views(key='iowait', option='optional')))
+ msg, optional=self.get_views(key='nice', option='optional')))
+ msg = '{:5.1f}%'.format(self.stats['nice'])
+ ret.append(self.curse_add_line(
+ msg, optional=self.get_views(key='nice', option='optional')))
# soft_interrupts
if 'soft_interrupts' in self.stats:
msg = ' {:8}'.format('sw_int:')
@@ -318,12 +321,15 @@ class Plugin(GlancesPlugin):
# New line
ret.append(self.curse_new_line())
- # Idle CPU
- if 'idle' in self.stats and not idle_tag:
- msg = '{:8}'.format('idle:')
- ret.append(self.curse_add_line(msg))
- msg = '{:5.1f}%'.format(self.stats['idle'])
- ret.append(self.curse_add_line(msg))
+ # IOWait CPU
+ if 'iowait' in self.stats:
+ msg = '{:8}'.format('iowait:')
+ ret.append(self.curse_add_line(
+ msg, optional=self.get_views(key='iowait', option='optional')))
+ msg = '{:5.1f}%'.format(self.stats['iowait'])
+ ret.append(self.curse_add_line(
+ msg, self.get_views(key='iowait', option='decoration'),
+ optional=self.get_views(key='iowait', option='optional')))
# Steal CPU usage
if 'steal' in self.stats:
msg = ' {:8}'.format('steal:')
diff --git a/glances/plugins/glances_mem.py b/glances/plugins/glances_mem.py
index 83108e96..81d9004a 100644
--- a/glances/plugins/glances_mem.py
+++ b/glances/plugins/glances_mem.py
@@ -19,6 +19,7 @@
"""Virtual memory plugin."""
+from glances.logger import logger
from glances.compat import iterkeys
from glances.plugins.glances_plugin import GlancesPlugin
@@ -161,7 +162,7 @@ class Plugin(GlancesPlugin):
# Add specifics informations
# Alert and log
- self.views['used']['decoration'] = self.get_alert_log(self.stats['used'], maximum=self.stats['total'])
+ self.views['percent']['decoration'] = self.get_alert_log(self.stats['used'], maximum=self.stats['total'])
# Optional
for key in ['active', 'inactive', 'buffers', 'cached']:
if key in self.stats:
@@ -184,7 +185,8 @@ class Plugin(GlancesPlugin):
ret.append(self.curse_add_line(msg))
# Percent memory usage
msg = '{:>7.1%}'.format(self.stats['percent'] / 100)
- ret.append(self.curse_add_line(msg))
+ ret.append(self.curse_add_line(
+ msg, self.get_views(key='percent', option='decoration')))
# Active memory usage
if 'active' in self.stats:
msg = ' {:9}'.format('active:')
diff --git a/glances/plugins/glances_memswap.py b/glances/plugins/glances_memswap.py
index 87d1fb38..aa7a6c15 100644
--- a/glances/plugins/glances_memswap.py
+++ b/glances/plugins/glances_memswap.py
@@ -139,8 +139,8 @@ class Plugin(GlancesPlugin):
# Add specifics informations
# Alert and log
- if 'used' in self.stats and 'total' in self.stats:
- self.views['used']['decoration'] = self.get_alert_log(self.stats['used'], maximum=self.stats['total'])
+ if 'used' in self.stats and 'total' in self.stats and 'percent' in self.stats:
+ self.views['percent']['decoration'] = self.get_alert_log(self.stats['used'], maximum=self.stats['total'])
def msg_curse(self, args=None, max_width=None):
"""Return the dict to display in the curse interface."""
@@ -159,7 +159,8 @@ class Plugin(GlancesPlugin):
ret.append(self.curse_add_line(msg))
# Percent memory usage
msg = '{:>6.1%}'.format(self.stats['percent'] / 100)
- ret.append(self.curse_add_line(msg))
+ ret.append(self.curse_add_line(
+ msg, self.get_views(key='percent', option='decoration')))
# New line
ret.append(self.curse_new_line())
# Total memory usage