mirror of
https://github.com/nicolargo/glances.git
synced 2024-12-26 02:31:36 +03:00
Automaticaly compute top processes number for the current screen - issue #408
This commit is contained in:
parent
ff10056508
commit
4521f2aa0b
@ -96,10 +96,6 @@ core 0_alias=CPU Core 0
|
|||||||
core 1_alias=CPU Core 1
|
core 1_alias=CPU Core 1
|
||||||
|
|
||||||
[processlist]
|
[processlist]
|
||||||
# Maximum number of processes to show in the UI
|
|
||||||
# Note: Only limit number of showed processes (not the one returned by the API)
|
|
||||||
# Default is 20 processes (Top 20)
|
|
||||||
max_processes=20
|
|
||||||
# Limit values for CPU/MEM per process in %
|
# Limit values for CPU/MEM per process in %
|
||||||
# Default values if not defined: 50/70/90
|
# Default values if not defined: 50/70/90
|
||||||
cpu_careful=50
|
cpu_careful=50
|
||||||
|
@ -96,10 +96,6 @@ battery_critical=95
|
|||||||
#core 1_alias=CPU Core 1
|
#core 1_alias=CPU Core 1
|
||||||
|
|
||||||
[processlist]
|
[processlist]
|
||||||
# Maximum number of processes to show in the UI
|
|
||||||
# Note: Only limit number of showed processes (not the one returned by the API)
|
|
||||||
# Default is 20 processes (Top 20)
|
|
||||||
max_processes=20
|
|
||||||
# Limit values for CPU/MEM per process in %
|
# Limit values for CPU/MEM per process in %
|
||||||
# Default values if not defined: 50/70/90
|
# Default values if not defined: 50/70/90
|
||||||
cpu_careful=50
|
cpu_careful=50
|
||||||
|
@ -66,9 +66,6 @@ class GlancesProcesses(object):
|
|||||||
self.process_filter = None
|
self.process_filter = None
|
||||||
self.process_filter_re = None
|
self.process_filter_re = None
|
||||||
|
|
||||||
# !!! ONLY FOR TEST
|
|
||||||
# self.set_process_filter('.*python.*')
|
|
||||||
|
|
||||||
def enable(self):
|
def enable(self):
|
||||||
"""Enable process stats."""
|
"""Enable process stats."""
|
||||||
self.disable_tag = False
|
self.disable_tag = False
|
||||||
|
@ -34,14 +34,8 @@ class GlancesStandalone(object):
|
|||||||
# Init stats
|
# Init stats
|
||||||
self.stats = GlancesStats(config=config, args=args)
|
self.stats = GlancesStats(config=config, args=args)
|
||||||
|
|
||||||
# If configured, set the maximum processes number to display
|
# Default number of processes to displayed is set to 20
|
||||||
try:
|
glances_processes.set_max_processes(20)
|
||||||
max_processes = int(self.stats.get_plugin('processlist').get_conf_value('max_processes'))
|
|
||||||
logger.debug(_("Limit maximum displayed processes to %s") % max_processes)
|
|
||||||
except:
|
|
||||||
max_processes = None
|
|
||||||
logger.warning(_("Maximum displayed processes is not configured (high CPU consumption)"))
|
|
||||||
glances_processes.set_max_processes(max_processes)
|
|
||||||
|
|
||||||
# If process extended stats is disabled by user
|
# If process extended stats is disabled by user
|
||||||
if args.disable_process_extended:
|
if args.disable_process_extended:
|
||||||
|
@ -383,6 +383,7 @@ class GlancesCurses(object):
|
|||||||
# Update the stats messages
|
# Update the stats messages
|
||||||
###########################
|
###########################
|
||||||
|
|
||||||
|
|
||||||
# Update the client server status
|
# Update the client server status
|
||||||
self.args.cs_status = cs_status
|
self.args.cs_status = cs_status
|
||||||
stats_system = stats.get_plugin('system').get_stats_display(args=self.args)
|
stats_system = stats.get_plugin('system').get_stats_display(args=self.args)
|
||||||
@ -400,10 +401,22 @@ class GlancesCurses(object):
|
|||||||
stats_sensors = stats.get_plugin('sensors').get_stats_display(args=self.args)
|
stats_sensors = stats.get_plugin('sensors').get_stats_display(args=self.args)
|
||||||
stats_now = stats.get_plugin('now').get_stats_display()
|
stats_now = stats.get_plugin('now').get_stats_display()
|
||||||
stats_processcount = stats.get_plugin('processcount').get_stats_display(args=self.args)
|
stats_processcount = stats.get_plugin('processcount').get_stats_display(args=self.args)
|
||||||
stats_processlist = stats.get_plugin('processlist').get_stats_display(args=self.args)
|
|
||||||
stats_monitor = stats.get_plugin('monitor').get_stats_display(args=self.args)
|
stats_monitor = stats.get_plugin('monitor').get_stats_display(args=self.args)
|
||||||
stats_alert = stats.get_plugin('alert').get_stats_display(args=self.args)
|
stats_alert = stats.get_plugin('alert').get_stats_display(args=self.args)
|
||||||
|
|
||||||
|
# Adapt number of processes to the available space
|
||||||
|
max_processes_displayed = screen_y - 11 - self.get_stats_display_height(stats_alert)
|
||||||
|
if not self.args.disable_process_extended:
|
||||||
|
max_processes_displayed -= 4
|
||||||
|
if max_processes_displayed < 0:
|
||||||
|
max_processes_displayed = 0
|
||||||
|
if glances_processes.get_max_processes() is None or \
|
||||||
|
glances_processes.get_max_processes() != max_processes_displayed:
|
||||||
|
logger.debug(_("Set number of displayed processes to %s") % max_processes_displayed)
|
||||||
|
glances_processes.set_max_processes(max_processes_displayed)
|
||||||
|
|
||||||
|
stats_processlist = stats.get_plugin('processlist').get_stats_display(args=self.args)
|
||||||
|
|
||||||
# Display the stats on the curses interface
|
# Display the stats on the curses interface
|
||||||
###########################################
|
###########################################
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user