Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
蜕变的菜鸟
glances
提交
e40f5555
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 搜索 >>
提交
e40f5555
编写于
5月 24, 2021
作者:
N
Nicolas Hennion
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
CPU is OK, but not diskio and others plugins
上级
95822505
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
33 addition
and
32 deletion
+33
-32
glances/cpu_percent.py
glances/cpu_percent.py
+1
-1
glances/plugins/glances_cpu.py
glances/plugins/glances_cpu.py
+20
-23
glances/plugins/glances_diskio.py
glances/plugins/glances_diskio.py
+10
-6
glances/standalone.py
glances/standalone.py
+1
-1
glances/stats.py
glances/stats.py
+1
-1
未找到文件。
glances/cpu_percent.py
浏览文件 @
e40f5555
...
...
@@ -34,9 +34,9 @@ class CpuPercent(object):
# cached_time is the minimum time interval between stats updates
# since last update is passed (will retrieve old cached info instead)
self
.
cached_time
=
0
self
.
timer_cpu
=
Timer
(
0
)
self
.
timer_percpu
=
Timer
(
0
)
self
.
cached_time
=
cached_time
def
get_key
(
self
):
"""Return the key of the per CPU list."""
...
...
glances/plugins/glances_cpu.py
浏览文件 @
e40f5555
...
...
@@ -108,39 +108,41 @@ class Plugin(GlancesPlugin):
stats
=
self
.
get_init_value
()
stats
[
'total'
]
=
cpu_percent
.
get
()
# Grab: 'user', 'system', 'idle', 'nice', 'iowait',
# 'irq', 'softirq', 'steal', 'guest', 'guest_nice'
cpu_times_percent
=
psutil
.
cpu_times_percent
(
interval
=
0.0
)
for
stat
in
[
'user'
,
'system'
,
'idle'
,
'nice'
,
'iowait'
,
'irq'
,
'softirq'
,
'steal'
,
'guest'
,
'guest_nice'
]:
if
hasattr
(
cpu_times_percent
,
stat
):
stats
[
stat
]
=
getattr
(
cpu_times_percent
,
stat
)
for
stat
in
cpu_times_percent
.
_fields
:
stats
[
stat
]
=
getattr
(
cpu_times_percent
,
stat
)
# Additional CPU stats (number of events not as a %; psutil>=4.1.0)
#
ctx_switches: number of context switches (voluntary + involuntary) per second
#
interrupts: number of interrupts per second
#
soft_interrupts: number of software interrupts per second
. Always set to 0 on Windows and SunOS.
# syscalls: number of system calls since boot. Always set to 0 on Linux.
#
- ctx_switches: number of context switches (voluntary + involuntary) since boot.
#
- interrupts: number of interrupts since boot.
#
- soft_interrupts: number of software interrupts since boot
. Always set to 0 on Windows and SunOS.
#
-
syscalls: number of system calls since boot. Always set to 0 on Linux.
cpu_stats
=
psutil
.
cpu_stats
()
# By storing time data we enable Rx/s and Tx/s calculations in the
# XML/RPC API, which would otherwise be overly difficult work
# for users of the API
time_since_update
=
getTimeSinceLastUpdate
(
'cpu'
)
stats
[
'time_since_update'
]
=
getTimeSinceLastUpdate
(
'cpu'
)
# Core number is needed to compute the CTX switch limit
stats
[
'cpucore'
]
=
self
.
nb_log_core
# Previous CPU stats are stored in the cpu_stats_old variable
if
not
hasattr
(
self
,
'cpu_stats_old'
):
# First call, we init the cpu_stats_old var
self
.
cpu_stats_old
=
cpu_stats
# Init the stats (needed to have the key name for export)
for
stat
in
cpu_stats
.
_fields
:
# @TODO: better to set it to None but should refactor views and UI...
stats
[
stat
]
=
0
else
:
# Others calls...
for
stat
in
cpu_stats
.
_fields
:
if
getattr
(
cpu_stats
,
stat
)
is
not
None
:
stats
[
stat
]
=
getattr
(
cpu_stats
,
stat
)
-
getattr
(
self
.
cpu_stats_old
,
stat
)
stats
[
'time_since_update'
]
=
time_since_update
# Core number is needed to compute the CTX switch limit
stats
[
'cpucore'
]
=
self
.
nb_log_core
# Save stats to compute next step
self
.
cpu_stats_old
=
cpu_stats
# Save stats to compute next step
self
.
cpu_stats_old
=
cpu_stats
return
stats
...
...
@@ -245,11 +247,6 @@ class Plugin(GlancesPlugin):
msg
=
'{:5.1f}%'
.
format
(
self
.
stats
[
'total'
])
ret
.
append
(
self
.
curse_add_line
(
msg
,
self
.
get_views
(
key
=
'total'
,
option
=
'decoration'
)))
# if idle_tag:
# ret.append(self.curse_add_line(
# msg, self.get_views(key='total', option='decoration')))
# else:
# ret.append(self.curse_add_line(msg))
# Idle CPU
if
'idle'
in
self
.
stats
and
not
idle_tag
:
msg
=
' {:8}'
.
format
(
'idle:'
)
...
...
glances/plugins/glances_diskio.py
浏览文件 @
e40f5555
...
...
@@ -86,7 +86,7 @@ class Plugin(GlancesPlugin):
# read_time: time spent reading from disk (in milliseconds)
# write_time: time spent writing to disk (in milliseconds)
try
:
diskio
counters
=
psutil
.
disk_io_counters
(
perdisk
=
True
)
diskio
=
psutil
.
disk_io_counters
(
perdisk
=
True
)
except
Exception
:
return
stats
...
...
@@ -94,7 +94,7 @@ class Plugin(GlancesPlugin):
if
not
hasattr
(
self
,
'diskio_old'
):
# First call, we init the diskio_old var
try
:
self
.
diskio_old
=
diskio
counters
self
.
diskio_old
=
diskio
except
(
IOError
,
UnboundLocalError
):
pass
else
:
...
...
@@ -103,7 +103,7 @@ class Plugin(GlancesPlugin):
# for users of the API
time_since_update
=
getTimeSinceLastUpdate
(
'disk'
)
diskio_new
=
diskio
counters
diskio_new
=
diskio
for
disk
in
diskio_new
:
# By default, RamFS is not displayed (issue #714)
if
self
.
args
is
not
None
and
not
self
.
args
.
diskio_show_ramfs
and
disk
.
startswith
(
'ram'
):
...
...
@@ -130,13 +130,17 @@ class Plugin(GlancesPlugin):
'write_count'
:
write_count
,
'read_bytes'
:
read_bytes
,
'write_bytes'
:
write_bytes
}
# Add alias if exist (define in the configuration file)
if
self
.
has_alias
(
disk
)
is
not
None
:
diskstat
[
'alias'
]
=
self
.
has_alias
(
disk
)
except
KeyError
:
continue
else
:
# Add alias if exist (define in the configuration file)
if
self
.
has_alias
(
disk
)
is
not
None
:
diskstat
[
'alias'
]
=
self
.
has_alias
(
disk
)
# Add the dict key
diskstat
[
'key'
]
=
self
.
get_key
()
# Ad dthe current disk stat to the list
stats
.
append
(
diskstat
)
# Save stats to compute next bitrate
...
...
glances/standalone.py
浏览文件 @
e40f5555
...
...
@@ -92,7 +92,7 @@ class GlancesStandalone(object):
# Init screen
self
.
screen
=
GlancesStdout
(
config
=
config
,
args
=
args
)
elif
args
.
stdout_csv
:
logger
.
info
(
"Stdout CSV mode is ON, following stats will be displayed: {}"
.
format
(
args
.
stdout
))
logger
.
info
(
"Stdout CSV mode is ON, following stats will be displayed: {}"
.
format
(
args
.
stdout
_csv
))
# Init screen
self
.
screen
=
GlancesStdoutCsv
(
config
=
config
,
args
=
args
)
else
:
...
...
glances/stats.py
浏览文件 @
e40f5555
...
...
@@ -239,7 +239,7 @@ class GlancesStats(object):
Each export module is ran in a dedicated thread.
"""
if
self
.
first_export
:
logger
.
info
(
"Do not export on first iteration because some stats
missing"
)
logger
.
debug
(
"Do not export stats during the first iteration because some information are
missing"
)
self
.
first_export
=
False
return
False
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录