diff --git a/conf/glances.conf b/conf/glances.conf index d7c7d87a0314ff6f058349ea02e3025f5aca8905..0ed47419559101e159b16bdcf8df2c61e4864869 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 dc2f9e2324b3d0675a9910b217cc2358a28c1e09..4ab2ad1a35ea2248a7b0f224a5dba2dcebb31803 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 83108e96c9a81f7961f9de6145df5c3c6d0b7cc1..81d9004aedd34bd886f2cb8d87c7d59421ab985b 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 87d1fb387e6d54e5eda454a21ba7587191d94120..aa7a6c159cd3035732b4fd432e21459ba8b613b7 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