Merge branch 'develop' of https://github.com/nicolargo/glances into develop

This commit is contained in:
nicolargo 2016-01-23 10:18:26 +01:00
commit 00dd57bcd7
2 changed files with 10 additions and 8 deletions

View File

@ -215,7 +215,7 @@ Start the client browser (browser mode):\n\
dest='fahrenheit', help='display temperature in Fahrenheit (default is Celsius)')
parser.add_argument('-1', '--percpu', action='store_true', default=False,
dest='percpu', help='start Glances in per CPU mode')
parser.add_argument('--fs-free-space', action='store_false', default=False,
parser.add_argument('--fs-free-space', action='store_true', default=False,
dest='fs_free_space', help='display FS free space instead of used')
parser.add_argument('--theme-white', action='store_true', default=False,
dest='theme_white', help='optimize display colors for white background')

View File

@ -177,7 +177,7 @@ class ProcessTreeNode(object):
nodes_to_search.extend(current_node.children)
@staticmethod
def build_tree(process_dict, sort_key, sort_reverse, hide_kernel_threads):
def build_tree(process_dict, sort_key, sort_reverse, hide_kernel_threads, excluded_processes):
"""Build a process tree using using parent/child relationships.
Return the tree root node.
@ -193,8 +193,8 @@ class ProcessTreeNode(object):
except psutil.NoSuchProcess:
# parent is dead, consider no parent
parent_process = None
if parent_process is None:
# no parent, add this node at the top level
if (parent_process is None) or (parent_process in excluded_processes):
# no parent, or excluded parent, add this node at the top level
tree_root.children.append(new_node)
else:
parent_node = tree_root.find_process(parent_process)
@ -217,9 +217,8 @@ class ProcessTreeNode(object):
# level
tree_root.children.append(node_to_add)
else:
if parent_process is None:
# parent is None now, but was not at previous pass (can occur on Windows only)
# consider no parent, add this node at the top level
if (parent_process is None) or (parent_process in excluded_processes):
# no parent, or excluded parent, add this node at the top level
tree_root.children.append(node_to_add)
else:
parent_node = tree_root.find_process(parent_process)
@ -589,6 +588,7 @@ class GlancesProcesses(object):
# Build an internal dict with only mandatories stats (sort keys)
processdict = {}
excluded_processes = set()
for proc in psutil.process_iter():
# Ignore kernel threads if needed
if self.no_kernel_threads and not WINDOWS and is_kernel_thread(proc):
@ -601,6 +601,7 @@ class GlancesProcesses(object):
standard_stats=self.max_processes is None)
# Continue to the next process if it has to be filtered
if s is None or (self.is_filtered(s['cmdline']) and self.is_filtered(s['name'])):
excluded_processes.add(proc)
continue
# Ok add the process to the list
processdict[proc] = s
@ -634,7 +635,8 @@ class GlancesProcesses(object):
self.process_tree = ProcessTreeNode.build_tree(processdict,
self.sort_key,
self.sort_reverse,
self.no_kernel_threads)
self.no_kernel_threads,
excluded_processes)
for i, node in enumerate(self.process_tree):
# Only retreive stats for visible processes (max_processes)