Add extended stats tag and key

This commit is contained in:
Nicolargo 2014-08-15 11:22:58 +02:00
parent ec7b0ac54f
commit 277f6baaf0
6 changed files with 36 additions and 3 deletions

View File

@ -74,6 +74,8 @@ class GlancesMain(object):
dest='disable_sensors', help=_('disable sensors module'))
parser.add_argument('--disable-process', action='store_true', default=False,
dest='disable_process', help=_('disable process module'))
parser.add_argument('--disable-process-extended', action='store_true', default=False,
dest='disable_process_extended', help=_('disable extended stats on top process'))
parser.add_argument('--disable-log', action='store_true', default=False,
dest='disable_log', help=_('disable log module'))
# CSV output feature

View File

@ -52,6 +52,9 @@ class GlancesProcesses(object):
# Default is to enable the processes stats
self.disable_tag = False
# Extended stats for top process is enable by default
self.disable_extended_tag = False
# Maximum number of processes showed in the UI interface
# None if no limit
self.max_processes = None
@ -65,6 +68,15 @@ class GlancesProcesses(object):
"""Disable process stats."""
self.disable_tag = True
def enable_extended(self):
"""Enable extended process stats."""
self.disable_extended_tag = False
self.update()
def disable_extended(self):
"""Disable extended process stats."""
self.disable_extended_tag = True
def set_max_processes(self, value):
"""Set the maximum number of processes showed in the UI interfaces"""
self.max_processes = value
@ -158,7 +170,7 @@ class GlancesProcesses(object):
procstat.update(proc.as_dict(attrs=['status', 'nice', 'memory_info', 'cpu_times']))
procstat['status'] = str(procstat['status'])[:1].upper()
if extended_stats:
if extended_stats and not self.disable_extended_tag:
procstat['extended_stats'] = True
# CPU affinity
@ -201,6 +213,8 @@ class GlancesProcesses(object):
else:
procstat['ionice'] = None
#logger.debug(procstat)
return procstat
def update(self):

View File

@ -43,6 +43,14 @@ class GlancesStandalone(object):
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 args.disable_process_extended:
logger.info(_("Extended stats for top process is disabled"))
glances_processes.disable_extended()
else:
logger.debug(_("Extended stats for top process is enabled (default behavor)"))
glances_processes.enable_extended()
# Initial system informations update
self.stats.update()

View File

@ -215,6 +215,13 @@ class GlancesCurses(object):
elif self.pressedkey == ord('d'):
# 'd' > Show/hide disk I/O stats
self.args.disable_diskio = not self.args.disable_diskio
elif self.pressedkey == ord('e'):
# 'e' > Enable/Disable extended stats for top process
self.args.disable_process_extended = not self.args.disable_process_extended
if self.args.disable_process_extended:
glances_processes.disable_extended()
else:
glances_processes.enable_extended()
elif self.pressedkey == ord('f'):
# 'f' > Show/hide fs stats
self.args.disable_fs = not self.args.disable_fs

View File

@ -124,7 +124,9 @@ class Plugin(GlancesPlugin):
msg = msg_col2.format("r", _("Reset history"))
ret.append(self.curse_add_line(msg))
ret.append(self.curse_new_line())
msg = msg_col.format("q", _("Quit (Esc and Ctrl-C also work)"))
msg = msg_col.format("e", _("Enable/disable top extended stats"))
ret.append(self.curse_add_line(msg))
msg = msg_col2.format("q", _("Quit (Esc and Ctrl-C also work)"))
ret.append(self.curse_add_line(msg))
# Return the message with decoration

View File

@ -40,7 +40,7 @@ class GlancesPlugin(object):
"""Init the plugin of plugins class."""
# Plugin name (= module name without glances_)
self.plugin_name = self.__class__.__module__[len('glances_'):]
logger.debug(_("Init plugin %s") % self.plugin_name)
# logger.debug(_("Init plugin %s") % self.plugin_name)
# Init the args
self.args = args