Make processes.sort_key configurable #1536

This commit is contained in:
nicolargo 2019-11-02 09:42:28 +01:00
parent 9943c3071b
commit 62132c16e2
3 changed files with 10 additions and 15 deletions

View File

@ -244,6 +244,10 @@ battery_critical=95
[processlist] [processlist]
disable=False disable=False
# Sort key: if not defined, the sort is automatically done by Glances (recommended)
# Should be one of the following:
# cpu_percent, memory_percent, io_counters, name, cpu_times, username
#sort_key=memory_percent
# Define CPU/MEM (per process) thresholds in % # Define CPU/MEM (per process) thresholds in %
# Default values if not defined: 50/70/90 # Default values if not defined: 50/70/90
cpu_careful=50 cpu_careful=50

View File

@ -308,21 +308,6 @@ class _GlancesCurses(object):
except Exception: except Exception:
pass pass
# def get_key(self, window):
# # Catch ESC key AND numlock key (issue #163)
# keycode = [0, 0]
# keycode[0] = window.getch()
# keycode[1] = window.getch()
#
# if keycode != [-1, -1]:
# logger.debug("Keypressed (code: %s)" % keycode)
#
# if keycode[0] == 27 and keycode[1] != -1:
# # Do not escape on specials keys
# return -1
# else:
# return keycode[0]
def get_key(self, window): def get_key(self, window):
# @TODO: Check issue #163 # @TODO: Check issue #163
ret = window.getch() ret = window.getch()

View File

@ -116,6 +116,12 @@ class Plugin(GlancesPlugin):
# Use to optimize space (see https://github.com/nicolargo/glances/issues/959) # Use to optimize space (see https://github.com/nicolargo/glances/issues/959)
self.pid_max = glances_processes.pid_max self.pid_max = glances_processes.pid_max
# Set the default sort key if it is defined in the configuration file
if 'processlist' in config.as_dict() and 'sort_key' in config.as_dict()['processlist']:
logger.debug('Configuration overwrites processes sort key by {}'.format(config.as_dict()['processlist']['sort_key']))
self.auto_sort = False
self._sort_key = config.as_dict()['processlist']['sort_key']
# Note: 'glances_processes' is already init in the processes.py script # Note: 'glances_processes' is already init in the processes.py script
def get_key(self): def get_key(self):