Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
蜕变的菜鸟
glances
提交
9a40395e
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 搜索 >>
提交
9a40395e
编写于
1月 06, 2018
作者:
N
nicolargo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Correct IO counter and max cpu/mem
上级
fc7106c0
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
24 addition
and
17 deletion
+24
-17
glances/plugins/glances_processlist.py
glances/plugins/glances_processlist.py
+2
-1
glances/processes.py
glances/processes.py
+22
-16
未找到文件。
glances/plugins/glances_processlist.py
浏览文件 @
9a40395e
...
...
@@ -304,7 +304,8 @@ class Plugin(GlancesPlugin):
msg
=
'{:>10}'
.
format
(
'?'
)
ret
.
append
(
self
.
curse_add_line
(
msg
,
optional
=
True
))
# IO read/write
if
'io_counters'
in
p
:
if
'io_counters'
in
p
and
p
[
'io_counters'
][
4
]
==
1
:
# Display rate if stats is available and io_tag ([4]) == 1
# IO read
io_rs
=
int
((
p
[
'io_counters'
][
0
]
-
p
[
'io_counters'
][
2
])
/
p
[
'time_since_update'
])
if
io_rs
==
0
:
...
...
glances/processes.py
浏览文件 @
9a40395e
...
...
@@ -407,29 +407,34 @@ class GlancesProcesses(object):
if
self
.
disable_tag
:
return
# Get the time since last update
time_since_update
=
getTimeSinceLastUpdate
(
'process_disk'
)
# Reset the max dict
self
.
reset_max_values
()
# Update the maximum process ID (pid) number
self
.
processcount
[
'pid_max'
]
=
self
.
pid_max
# Only work whith PsUtil
# Grab the stats
mandatories_attr
=
[
'cmdline'
,
'cpu_percent'
,
'cpu_times'
,
'io_counters'
,
'memory_info'
,
'memory_percent'
,
'name'
,
'nice'
,
'pid'
,
'ppid'
,
'status'
,
'username'
]
# and build the processes stats list
self
.
processlist
=
[
p
.
info
for
p
in
sorted
(
psutil
.
process_iter
(
attrs
=
mandatories_attr
,
ad_value
=
None
),
key
=
lambda
p
:
p
.
info
[
'cpu_percent'
])]
# Add metadata
# Update the maximum process ID (pid) number
self
.
processcount
[
'pid_max'
]
=
self
.
pid_max
# Compute the maximum value for keys in self._max_values_list
# Reset the max dict
self
.
reset_max_values
()
# Compute max
for
k
in
self
.
_max_values_list
:
self
.
set_max_values
(
k
,
max
(
i
[
k
]
for
i
in
self
.
processlist
))
# Loop over processes and add metadata
for
proc
in
self
.
processlist
:
proc
[
'time_since_update'
]
=
time_since_update
# Status
# Time since last update (for disk_io rate computation)
proc
[
'time_since_update'
]
=
getTimeSinceLastUpdate
(
'process_disk'
)
# Process status (only keep the first char)
proc
[
'status'
]
=
str
(
proc
[
'status'
])[:
1
].
upper
()
# Process IO
# procstat['io_counters'] is a list:
# [read_bytes, write_bytes, read_bytes_old, write_bytes_old, io_tag]
...
...
@@ -437,17 +442,18 @@ class GlancesProcesses(object):
# If io_tag = 1 > No access denied (display the IO rate)
# Availability: all platforms except macOS and Illumos/Solaris
if
proc
[
'io_counters'
]
is
not
None
:
proc_io
=
proc
[
'io_counters'
]
io_new
=
[
proc_io
.
read_bytes
,
proc_io
.
write_bytes
]
io_new
=
[
proc
[
'io_counters'
].
read_bytes
,
proc
[
'io_counters'
]
.
write_bytes
]
# For IO rate computation
# Append saved IO r/w bytes
try
:
proc
[
'io_counters'
]
=
io_new
+
self
.
io_old
[
proc
[
'pid'
]]
io_tag
=
1
except
KeyError
:
proc
[
'io_counters'
]
=
io_new
+
[
0
,
0
]
io_tag
=
0
# then save the IO r/w bytes
self
.
io_old
[
proc
[
'pid'
]]
=
io_new
io_tag
=
1
else
:
proc
[
'io_counters'
]
=
[
0
,
0
]
+
[
0
,
0
]
io_tag
=
0
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录