Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
蜕变的菜鸟
glances
提交
6a667d63
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,发现更多精彩内容 >>
提交
6a667d63
编写于
11月 16, 2014
作者:
D
desbma
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add command line --tree option and remove hardcoded boolean
上级
5c3a2698
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
30 addition
and
19 deletion
+30
-19
glances/core/glances_main.py
glances/core/glances_main.py
+2
-0
glances/core/glances_processes.py
glances/core/glances_processes.py
+14
-5
glances/core/glances_standalone.py
glances/core/glances_standalone.py
+5
-1
glances/outputs/glances_curses.py
glances/outputs/glances_curses.py
+1
-3
glances/plugins/glances_processcount.py
glances/plugins/glances_processcount.py
+1
-3
glances/plugins/glances_processlist.py
glances/plugins/glances_processlist.py
+7
-7
未找到文件。
glances/core/glances_main.py
浏览文件 @
6a667d63
...
...
@@ -128,6 +128,8 @@ class GlancesMain(object):
if
not
is_windows
:
parser
.
add_argument
(
'--hide-kernel-threads'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'no_kernel_threads'
,
help
=
_
(
'hide kernel threads in process list'
))
parser
.
add_argument
(
'--tree'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'process_tree'
,
help
=
_
(
'display processes as a tree'
))
parser
.
add_argument
(
'-b'
,
'--byte'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'byte'
,
help
=
_
(
'display network rate in byte per second'
))
parser
.
add_argument
(
'-1'
,
'--percpu'
,
action
=
'store_true'
,
default
=
False
,
...
...
glances/core/glances_processes.py
浏览文件 @
6a667d63
...
...
@@ -26,8 +26,6 @@ import collections
import
psutil
import
re
PROCESS_TREE
=
True
# TODO remove that and take command line parameter
class
ProcessTreeNode
(
object
):
...
...
@@ -220,8 +218,11 @@ class GlancesProcesses(object):
# value = [ read_bytes_old, write_bytes_old ]
self
.
io_old
=
{}
# Init stats
# Wether or not to enable process tree
self
.
_enable_tree
=
False
self
.
process_tree
=
None
# Init stats
self
.
resetsort
()
self
.
processlist
=
[]
self
.
processcount
=
{
...
...
@@ -310,6 +311,14 @@ 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
def
__get_process_stats
(
self
,
proc
,
mandatory_stats
=
True
,
standard_stats
=
True
,
...
...
@@ -558,7 +567,7 @@ class GlancesProcesses(object):
except
:
pass
if
PROCESS_TREE
:
if
self
.
_enable_tree
:
self
.
process_tree
=
ProcessTreeNode
.
buildTree
(
processdict
,
self
.
getsortkey
(),
self
.
no_kernel_threads
)
...
...
@@ -656,7 +665,7 @@ class GlancesProcesses(object):
def
setmanualsortkey
(
self
,
sortedby
):
"""Set the current sort key for manual sort."""
self
.
processmanualsort
=
sortedby
if
PROCESS_TREE
and
(
self
.
process_tree
is
not
None
):
if
self
.
_enable_tree
and
(
self
.
process_tree
is
not
None
):
self
.
process_tree
.
setSorting
(
sortedby
,
sortedby
!=
"name"
)
return
self
.
processmanualsort
...
...
glances/core/glances_standalone.py
浏览文件 @
6a667d63
...
...
@@ -49,10 +49,14 @@ class GlancesStandalone(object):
if
args
.
process_filter
is
not
None
:
glances_processes
.
set_process_filter
(
args
.
process_filter
)
# Ignore kernel threads in process list
if
(
not
is_windows
)
and
args
.
no_kernel_threads
:
# Ignore kernel threads in process list
glances_processes
.
disable_kernel_threads
()
if
args
.
process_tree
:
# Enable process tree view
glances_processes
.
enable_tree
()
# Initial system informations update
self
.
stats
.
update
()
...
...
glances/outputs/glances_curses.py
浏览文件 @
6a667d63
...
...
@@ -19,8 +19,6 @@
"""Curses interface class."""
PROCESS_TREE
=
True
# Import system lib
import
sys
...
...
@@ -425,7 +423,7 @@ class GlancesCurses(object):
# Adapt number of processes to the available space
max_processes_displayed
=
screen_y
-
11
-
\
self
.
get_stats_display_height
(
stats_alert
)
if
self
.
args
.
enable_process_extended
and
not
PROCESS_TREE
:
if
self
.
args
.
enable_process_extended
and
not
self
.
args
.
process_tree
:
max_processes_displayed
-=
4
if
max_processes_displayed
<
0
:
max_processes_displayed
=
0
...
...
glances/plugins/glances_processcount.py
浏览文件 @
6a667d63
...
...
@@ -26,8 +26,6 @@ from glances.plugins.glances_plugin import GlancesPlugin
# Note: history items list is not compliant with process count
# if a filter is applyed, the graph will show the filtered processes count
PROCESS_TREE
=
True
# TODO remove that and take command line parameter
class
Plugin
(
GlancesPlugin
):
...
...
@@ -127,7 +125,7 @@ class Plugin(GlancesPlugin):
else
:
msg
=
_
(
"sorted by {0}"
).
format
(
glances_processes
.
getmanualsortkey
())
ret
.
append
(
self
.
curse_add_line
(
msg
))
ret
[
-
1
][
"msg"
]
+=
", %s view"
%
(
"tree"
if
PROCESS_TREE
else
"flat"
)
ret
[
-
1
][
"msg"
]
+=
", %s view"
%
(
"tree"
if
glances_processes
.
is_tree_enabled
()
else
"flat"
)
# Return the message with decoration
return
ret
glances/plugins/glances_processlist.py
浏览文件 @
6a667d63
...
...
@@ -27,8 +27,6 @@ from datetime import timedelta
from
glances.core.glances_globals
import
glances_processes
,
is_linux
,
is_bsd
,
is_mac
,
is_windows
,
logger
from
glances.plugins.glances_plugin
import
GlancesPlugin
PROCESS_TREE
=
True
# TODO remove that and take command line parameter
class
Plugin
(
GlancesPlugin
):
...
...
@@ -59,7 +57,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
PROCESS_TREE
:
if
glances_processes
.
is_tree_enabled
()
:
self
.
stats
=
glances_processes
.
gettree
()
else
:
self
.
stats
=
glances_processes
.
getlist
()
...
...
@@ -396,7 +394,7 @@ class Plugin(GlancesPlugin):
# Trying to display proc time
self
.
tag_proc_time
=
True
if
PROCESS_TREE
:
if
glances_processes
.
is_tree_enabled
()
:
ret
.
extend
(
self
.
get_process_tree_curses_data
(
self
.
sortstats
(
process_sort_key
),
args
,
first_level
=
True
,
...
...
@@ -422,7 +420,9 @@ class Plugin(GlancesPlugin):
if
sortedby
==
'name'
:
sortedreverse
=
False
if
sortedby
==
'io_counters'
and
not
PROCESS_TREE
:
tree
=
glances_processes
.
is_tree_enabled
()
if
sortedby
==
'io_counters'
and
not
tree
:
# Specific case for io_counters
# Sum of io_r + io_w
try
:
...
...
@@ -438,7 +438,7 @@ class Plugin(GlancesPlugin):
reverse
=
sortedreverse
)
else
:
# Others sorts
if
PROCESS_TREE
:
if
tree
:
self
.
stats
.
setSorting
(
sortedby
,
sortedreverse
)
else
:
try
:
...
...
@@ -450,7 +450,7 @@ class Plugin(GlancesPlugin):
key
=
lambda
process
:
process
[
'name'
],
reverse
=
False
)
if
not
PROCESS_TREE
:
if
not
tree
:
self
.
stats
=
listsorted
return
self
.
stats
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录