Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
蜕变的菜鸟
glances
提交
63172299
G
glances
项目概览
蜕变的菜鸟
/
glances
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
glances
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
63172299
编写于
1月 27, 2018
作者:
N
nicolargo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove tree view
上级
9356b70c
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
23 addition
and
151 deletion
+23
-151
glances/main.py
glances/main.py
+0
-3
glances/outputs/glances_curses.py
glances/outputs/glances_curses.py
+1
-1
glances/plugins/glances_processcount.py
glances/plugins/glances_processcount.py
+0
-3
glances/plugins/glances_processlist.py
glances/plugins/glances_processlist.py
+14
-110
glances/processes.py
glances/processes.py
+8
-27
glances/standalone.py
glances/standalone.py
+0
-7
未找到文件。
glances/main.py
浏览文件 @
63172299
...
...
@@ -213,9 +213,6 @@ Examples of use:
if
not
WINDOWS
:
parser
.
add_argument
(
'--hide-kernel-threads'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'no_kernel_threads'
,
help
=
'hide kernel threads in process list (not available on Windows)'
)
# if LINUX:
# parser.add_argument('--tree', action='store_true', default=False,
# dest='process_tree', help='display processes as a tree (Linux only)')
parser
.
add_argument
(
'-b'
,
'--byte'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'byte'
,
help
=
'display network rate in byte per second'
)
parser
.
add_argument
(
'--diskio-show-ramfs'
,
action
=
'store_true'
,
default
=
False
,
...
...
glances/outputs/glances_curses.py
浏览文件 @
63172299
...
...
@@ -533,7 +533,7 @@ class _GlancesCurses(object):
self
.
get_stats_display_height
(
__stat_display
[
"docker"
])))
try
:
if
self
.
args
.
enable_process_extended
and
not
self
.
args
.
process_tree
:
if
self
.
args
.
enable_process_extended
:
max_processes_displayed
-=
4
except
AttributeError
:
pass
...
...
glances/plugins/glances_processcount.py
浏览文件 @
63172299
...
...
@@ -124,9 +124,6 @@ class Plugin(GlancesPlugin):
else
:
msg
=
'sorted by {}'
.
format
(
glances_processes
.
sort_key
)
ret
.
append
(
self
.
curse_add_line
(
msg
))
ret
[
-
1
][
"msg"
]
+=
", %s view"
%
(
"tree"
if
glances_processes
.
is_tree_enabled
()
else
"flat"
)
# if args.disable_irix:
# ret[-1]["msg"] += " - IRIX off"
# Return the message with decoration
return
ret
glances/plugins/glances_processlist.py
浏览文件 @
63172299
...
...
@@ -106,10 +106,7 @@ class Plugin(GlancesPlugin):
# Update stats using the standard system lib
# Note: Update is done in the processcount plugin
# Just return the processes list
if
glances_processes
.
is_tree_enabled
():
self
.
stats
=
glances_processes
.
gettree
()
else
:
self
.
stats
=
glances_processes
.
getlist
()
self
.
stats
=
glances_processes
.
getlist
()
# Get the max values (dict)
# Use Deep copy to avoid change between update and display
...
...
@@ -121,87 +118,6 @@ class Plugin(GlancesPlugin):
return
self
.
stats
def
get_process_tree_curses_data
(
self
,
node
,
args
,
first_level
=
True
,
max_node_count
=
None
):
"""Get curses data to display for a process tree."""
ret
=
[]
node_count
=
0
if
not
node
.
is_root
and
((
max_node_count
is
None
)
or
(
max_node_count
>
0
)):
node_data
=
self
.
get_process_curses_data
(
node
.
stats
,
False
,
args
)
node_count
+=
1
ret
.
extend
(
node_data
)
for
child
in
node
.
iter_children
():
# stop if we have enough nodes to display
if
max_node_count
is
not
None
and
node_count
>=
max_node_count
:
break
if
max_node_count
is
None
:
children_max_node_count
=
None
else
:
children_max_node_count
=
max_node_count
-
node_count
child_data
=
self
.
get_process_tree_curses_data
(
child
,
args
,
first_level
=
node
.
is_root
,
max_node_count
=
children_max_node_count
)
if
max_node_count
is
None
:
node_count
+=
len
(
child
)
else
:
node_count
+=
min
(
children_max_node_count
,
len
(
child
))
if
not
node
.
is_root
:
child_data
=
self
.
add_tree_decoration
(
child_data
,
child
is
node
.
children
[
-
1
],
first_level
)
ret
.
extend
(
child_data
)
return
ret
def
add_tree_decoration
(
self
,
child_data
,
is_last_child
,
first_level
):
"""Add tree curses decoration and indentation to a subtree."""
# find process command indices in messages
pos
=
[]
for
i
,
m
in
enumerate
(
child_data
):
if
m
.
get
(
"_tree_decoration"
,
False
):
del
m
[
"_tree_decoration"
]
pos
.
append
(
i
)
# add new curses items for tree decoration
new_child_data
=
[]
new_pos
=
[]
for
i
,
m
in
enumerate
(
child_data
):
if
i
in
pos
:
new_pos
.
append
(
len
(
new_child_data
))
new_child_data
.
append
(
self
.
curse_add_line
(
""
))
new_child_data
[
-
1
][
"_tree_decoration"
]
=
True
new_child_data
.
append
(
m
)
child_data
=
new_child_data
pos
=
new_pos
if
pos
:
# draw node prefix
if
is_last_child
:
prefix
=
"└─"
else
:
prefix
=
"├─"
child_data
[
pos
[
0
]][
"msg"
]
=
prefix
# add indentation
for
i
in
pos
:
spacing
=
2
if
first_level
:
spacing
=
1
elif
is_last_child
and
(
i
is
not
pos
[
0
]):
# compensate indentation for missing '│' char
spacing
=
3
child_data
[
i
][
"msg"
]
=
"%s%s"
%
(
" "
*
spacing
,
child_data
[
i
][
"msg"
])
if
not
is_last_child
:
# add '│' tree decoration
for
i
in
pos
[
1
:]:
old_str
=
child_data
[
i
][
"msg"
]
if
first_level
:
child_data
[
i
][
"msg"
]
=
" │"
+
old_str
[
2
:]
else
:
child_data
[
i
][
"msg"
]
=
old_str
[:
2
]
+
"│"
+
old_str
[
3
:]
return
child_data
def
get_nice_alert
(
self
,
value
):
"""Return the alert relative to the Nice configuration list"""
value
=
str
(
value
)
...
...
@@ -355,16 +271,10 @@ class Plugin(GlancesPlugin):
if
os
.
path
.
isdir
(
path
)
and
not
args
.
process_short_name
:
msg
=
' {}'
.
format
(
path
)
+
os
.
sep
ret
.
append
(
self
.
curse_add_line
(
msg
,
splittable
=
True
))
if
glances_processes
.
is_tree_enabled
():
# mark position to add tree decoration
ret
[
-
1
][
"_tree_decoration"
]
=
True
ret
.
append
(
self
.
curse_add_line
(
cmd
,
decoration
=
'PROCESS'
,
splittable
=
True
))
else
:
msg
=
' {}'
.
format
(
cmd
)
ret
.
append
(
self
.
curse_add_line
(
msg
,
decoration
=
'PROCESS'
,
splittable
=
True
))
if
glances_processes
.
is_tree_enabled
():
# mark position to add tree decoration
ret
[
-
1
][
"_tree_decoration"
]
=
True
if
arguments
:
msg
=
' {}'
.
format
(
arguments
)
ret
.
append
(
self
.
curse_add_line
(
msg
,
splittable
=
True
))
...
...
@@ -462,24 +372,19 @@ class Plugin(GlancesPlugin):
self
.
__msg_curse_header
(
ret
,
process_sort_key
,
args
)
# Process list
if
glances_processes
.
is_tree_enabled
():
ret
.
extend
(
self
.
get_process_tree_curses_data
(
self
.
__sort_stats
(
process_sort_key
),
args
,
first_level
=
True
,
max_node_count
=
glances_processes
.
max_processes
))
else
:
# Loop over processes (sorted by the sort key previously compute)
first
=
True
for
p
in
self
.
__sort_stats
(
process_sort_key
):
ret
.
extend
(
self
.
get_process_curses_data
(
p
,
first
,
args
))
# End of extended stats
first
=
False
if
glances_processes
.
process_filter
is
not
None
:
if
args
.
reset_minmax_tag
:
args
.
reset_minmax_tag
=
not
args
.
reset_minmax_tag
self
.
__mmm_reset
()
self
.
__msg_curse_sum
(
ret
,
args
=
args
)
self
.
__msg_curse_sum
(
ret
,
mmm
=
'min'
,
args
=
args
)
self
.
__msg_curse_sum
(
ret
,
mmm
=
'max'
,
args
=
args
)
# Loop over processes (sorted by the sort key previously compute)
first
=
True
for
p
in
self
.
__sort_stats
(
process_sort_key
):
ret
.
extend
(
self
.
get_process_curses_data
(
p
,
first
,
args
))
# End of extended stats
first
=
False
if
glances_processes
.
process_filter
is
not
None
:
if
args
.
reset_minmax_tag
:
args
.
reset_minmax_tag
=
not
args
.
reset_minmax_tag
self
.
__mmm_reset
()
self
.
__msg_curse_sum
(
ret
,
args
=
args
)
self
.
__msg_curse_sum
(
ret
,
mmm
=
'min'
,
args
=
args
)
self
.
__msg_curse_sum
(
ret
,
mmm
=
'max'
,
args
=
args
)
# Return the message with decoration
return
ret
...
...
@@ -666,7 +571,6 @@ class Plugin(GlancesPlugin):
def
__sort_stats
(
self
,
sortedby
=
None
):
"""Return the stats (dict) sorted by (sortedby)."""
return
sort_stats
(
self
.
stats
,
sortedby
,
tree
=
glances_processes
.
is_tree_enabled
(),
reverse
=
glances_processes
.
sort_reverse
)
def
__max_pid_size
(
self
):
...
...
glances/processes.py
浏览文件 @
63172299
...
...
@@ -49,10 +49,6 @@ class GlancesProcesses(object):
# value = [ read_bytes_old, write_bytes_old ]
self
.
io_old
=
{}
# Wether or not to enable process tree
self
.
_enable_tree
=
False
self
.
process_tree
=
None
# Init stats
self
.
auto_sort
=
True
self
.
_sort_key
=
'cpu_percent'
...
...
@@ -194,14 +190,6 @@ class GlancesProcesses(object):
"""Ignore kernel threads in process list."""
self
.
no_kernel_threads
=
True
def
enable_tree
(
self
):
"""Enable process tree."""
self
.
_enable_tree
=
True
def
is_tree_enabled
(
self
):
"""Return True if process tree is enabled, False instead."""
return
self
.
_enable_tree
@
property
def
sort_reverse
(
self
):
"""Return True to sort processes in reverse 'key' order, False instead."""
...
...
@@ -379,10 +367,6 @@ class GlancesProcesses(object):
"""Get the processlist."""
return
self
.
processlist
def
gettree
(
self
):
"""Get the process tree."""
return
self
.
process_tree
@
property
def
sort_key
(
self
):
"""Get the current sort key."""
...
...
@@ -396,14 +380,14 @@ class GlancesProcesses(object):
# TODO: move this global function (also used in glances_processlist
# and logs) inside the GlancesProcesses class
def
sort_stats
(
stats
,
sortedby
=
None
,
tree
=
False
,
reverse
=
True
):
def
sort_stats
(
stats
,
sortedby
=
None
,
reverse
=
True
):
"""Return the stats (dict) sorted by (sortedby)
Reverse the sort if reverse is True."""
if
sortedby
is
None
:
# No need to sort...
return
stats
if
sortedby
==
'io_counters'
and
not
tree
:
if
sortedby
==
'io_counters'
:
# Specific case for io_counters
# Sum of io_r + io_w
try
:
...
...
@@ -417,15 +401,12 @@ def sort_stats(stats, sortedby=None, tree=False, reverse=True):
reverse
=
reverse
)
else
:
# Others sorts
if
tree
:
stats
.
set_sorting
(
sortedby
,
reverse
)
else
:
try
:
stats
.
sort
(
key
=
operator
.
itemgetter
(
sortedby
),
reverse
=
reverse
)
except
(
KeyError
,
TypeError
):
stats
.
sort
(
key
=
operator
.
itemgetter
(
'name'
),
reverse
=
False
)
try
:
stats
.
sort
(
key
=
operator
.
itemgetter
(
sortedby
),
reverse
=
reverse
)
except
(
KeyError
,
TypeError
):
stats
.
sort
(
key
=
operator
.
itemgetter
(
'name'
),
reverse
=
False
)
return
stats
...
...
glances/standalone.py
浏览文件 @
63172299
...
...
@@ -64,13 +64,6 @@ class GlancesStandalone(object):
# Ignore kernel threads in process list
glances_processes
.
disable_kernel_threads
()
# try:
# if args.process_tree:
# # Enable process tree view
# glances_processes.enable_tree()
# except AttributeError:
# pass
# Initial system informations update
self
.
stats
.
update
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录