Refactor top menu of the curse interface

pull/2064/head
nicolargo 2022-05-27 18:36:36 +02:00
parent 586ebd7099
commit 87d90987a8
5 changed files with 27 additions and 21 deletions

View File

@ -329,9 +329,9 @@ class Plugin(GlancesPlugin):
ret.append(self.curse_add_line(msg, self.get_views(key='total', option='decoration')))
# Idle CPU
if 'idle' in self.stats and not idle_tag:
msg = ' {:8}'.format('idle:')
msg = ' {:8}'.format('idle')
ret.append(self.curse_add_line(msg, optional=self.get_views(key='idle', option='optional')))
msg = '{:5.1f}%'.format(self.stats['idle'])
msg = '{:4.1f}%'.format(self.stats['idle'])
ret.append(self.curse_add_line(msg, optional=self.get_views(key='idle', option='optional')))
# ctx_switches
ret.extend(self.curse_add_stat('ctx_switches', width=15, header=' '))
@ -345,7 +345,7 @@ class Plugin(GlancesPlugin):
elif 'idle' in self.stats:
ret.extend(self.curse_add_stat('idle', width=15))
# IRQ CPU
ret.extend(self.curse_add_stat('irq', width=15, header=' '))
ret.extend(self.curse_add_stat('irq', width=14, header=' '))
# interrupts
ret.extend(self.curse_add_stat('interrupts', width=15, header=' '))
@ -358,7 +358,7 @@ class Plugin(GlancesPlugin):
else:
ret.extend(self.curse_add_stat('core', width=15))
# Nice CPU
ret.extend(self.curse_add_stat('nice', width=15, header=' '))
ret.extend(self.curse_add_stat('nice', width=14, header=' '))
# soft_interrupts
ret.extend(self.curse_add_stat('soft_interrupts', width=15, header=' '))
@ -368,7 +368,7 @@ class Plugin(GlancesPlugin):
# IOWait CPU
ret.extend(self.curse_add_stat('iowait', width=15))
# Steal CPU usage
ret.extend(self.curse_add_stat('steal', width=15, header=' '))
ret.extend(self.curse_add_stat('steal', width=14, header=' '))
# syscalls: number of system calls since boot. Always set to 0 on Linux. (do not display)
if not LINUX:
ret.extend(self.curse_add_stat('syscalls', width=15, header=' '))

View File

@ -170,7 +170,7 @@ class Plugin(GlancesPlugin):
# Build the string message
# Header
msg = '{:6}'.format('LOAD')
msg = '{:5}'.format('LOAD')
ret.append(self.curse_add_line(msg, "TITLE"))
# Core number
if 'cpucore' in self.stats and self.stats['cpucore'] > 0:
@ -179,7 +179,7 @@ class Plugin(GlancesPlugin):
# Loop over 1min, 5min and 15min load
for load_time in ['1', '5', '15']:
ret.append(self.curse_new_line())
msg = '{:8}'.format('{} min'.format(load_time))
msg = '{:7}'.format('{} min'.format(load_time))
ret.append(self.curse_add_line(msg))
if args.disable_irix and self.nb_log_core != 0:
# Enable Irix mode for load (see issue #1554)

View File

@ -57,11 +57,17 @@ note that this doesn\'t reflect the actual memory available (use \'available\' i
'unit': 'bytes',
'min_symbol': 'K',
},
'inactive': {'description': '*(UNIX)*: memory that is marked as not used.', 'unit': 'bytes', 'min_symbol': 'K'},
'inactive': {
'description': '*(UNIX)*: memory that is marked as not used.',
'unit': 'bytes',
'min_symbol': 'K',
'short_name': 'inacti',
},
'buffers': {
'description': '*(Linux, BSD)*: cache for things like file system metadata.',
'unit': 'bytes',
'min_symbol': 'K',
'short_name': 'buffer',
},
'cached': {'description': '*(Linux, BSD)*: cache for various things.', 'unit': 'bytes', 'min_symbol': 'K'},
'wired': {
@ -258,7 +264,7 @@ class Plugin(GlancesPlugin):
msg = '{:>7.1%}'.format(self.stats['percent'] / 100)
ret.append(self.curse_add_line(msg, self.get_views(key='percent', option='decoration')))
# Active memory usage
ret.extend(self.curse_add_stat('active', width=18, header=' '))
ret.extend(self.curse_add_stat('active', width=16, header=' '))
# Second line
# total + inactive
@ -266,7 +272,7 @@ class Plugin(GlancesPlugin):
# Total memory usage
ret.extend(self.curse_add_stat('total', width=15))
# Inactive memory usage
ret.extend(self.curse_add_stat('inactive', width=18, header=' '))
ret.extend(self.curse_add_stat('inactive', width=16, header=' '))
# Third line
# used + buffers
@ -274,7 +280,7 @@ class Plugin(GlancesPlugin):
# Used memory usage
ret.extend(self.curse_add_stat('used', width=15))
# Buffers memory usage
ret.extend(self.curse_add_stat('buffers', width=18, header=' '))
ret.extend(self.curse_add_stat('buffers', width=16, header=' '))
# Fourth line
# free + cached
@ -282,6 +288,6 @@ class Plugin(GlancesPlugin):
# Free memory usage
ret.extend(self.curse_add_stat('free', width=15))
# Cached memory usage
ret.extend(self.curse_add_stat('cached', width=18, header=' '))
ret.extend(self.curse_add_stat('cached', width=16, header=' '))
return ret

View File

@ -172,9 +172,9 @@ class Plugin(GlancesPlugin):
# First line
# total%
msg = '{}'.format('SWAP')
msg = '{:4}'.format('SWAP')
ret.append(self.curse_add_line(msg, "TITLE"))
msg = ' {:3}'.format(self.trend_msg(self.get_trend('percent')))
msg = ' {:2}'.format(self.trend_msg(self.get_trend('percent')))
ret.append(self.curse_add_line(msg))
# Percent memory usage
msg = '{:>6.1%}'.format(self.stats['percent'] / 100)
@ -184,18 +184,18 @@ class Plugin(GlancesPlugin):
# total
ret.append(self.curse_new_line())
# Total memory usage
ret.extend(self.curse_add_stat('total', width=16))
ret.extend(self.curse_add_stat('total', width=15))
# Third line
# used
ret.append(self.curse_new_line())
# Used memory usage
ret.extend(self.curse_add_stat('used', width=16))
ret.extend(self.curse_add_stat('used', width=15))
# Fourth line
# free
ret.append(self.curse_new_line())
# Free memory usage
ret.extend(self.curse_add_stat('free', width=16))
ret.extend(self.curse_add_stat('free', width=15))
return ret

View File

@ -988,7 +988,7 @@ class GlancesPlugin(object):
| | | | |_ trailer
| | | |_ self.stats[key]
| | |_ separator
| |_ key (if display_key is True)
| |_ 'short_name' description or key or nothing if display_key is True
|_ header
Instead of:
@ -1005,12 +1005,12 @@ class GlancesPlugin(object):
return []
# Check if a shortname is defined
if key in self.fields_description and 'short_name' in self.fields_description[key]:
if not display_key:
key_name = ''
elif key in self.fields_description and 'short_name' in self.fields_description[key]:
key_name = self.fields_description[key]['short_name']
else:
key_name = key
if not display_key:
key_name = ''
# Check if unit is defined and get the short unit char in the unit_sort dict
if (