Automaticaly compute top processes number for the current screen - issue #408

pull/435/head
Nicolas Hennion 2014-09-15 19:06:12 +02:00
parent ff10056508
commit 4521f2aa0b
5 changed files with 16 additions and 20 deletions

View File

@ -96,10 +96,6 @@ core 0_alias=CPU Core 0
core 1_alias=CPU Core 1
[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 %
# Default values if not defined: 50/70/90
cpu_careful=50

View File

@ -96,10 +96,6 @@ battery_critical=95
#core 1_alias=CPU Core 1
[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 %
# Default values if not defined: 50/70/90
cpu_careful=50

View File

@ -66,9 +66,6 @@ class GlancesProcesses(object):
self.process_filter = None
self.process_filter_re = None
# !!! ONLY FOR TEST
# self.set_process_filter('.*python.*')
def enable(self):
"""Enable process stats."""
self.disable_tag = False

View File

@ -34,14 +34,8 @@ class GlancesStandalone(object):
# Init stats
self.stats = GlancesStats(config=config, args=args)
# If configured, set the maximum processes number to display
try:
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)
# Default number of processes to displayed is set to 20
glances_processes.set_max_processes(20)
# If process extended stats is disabled by user
if args.disable_process_extended:

View File

@ -383,6 +383,7 @@ class GlancesCurses(object):
# Update the stats messages
###########################
# Update the client server status
self.args.cs_status = cs_status
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_now = stats.get_plugin('now').get_stats_display()
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_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
###########################################