Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
蜕变的菜鸟
glances
提交
1286515f
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 搜索 >>
提交
1286515f
编写于
3月 13, 2014
作者:
N
Nicolas Hennion
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactor the diskIO plugin (based on the network one)
上级
db4b9ae1
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
64 addition
and
27 deletion
+64
-27
glances/plugins/glances_diskio.py
glances/plugins/glances_diskio.py
+48
-27
glances/plugins/glances_fs.py
glances/plugins/glances_fs.py
+4
-0
glances/plugins/glances_mem.py
glances/plugins/glances_mem.py
+4
-0
glances/plugins/glances_memswap.py
glances/plugins/glances_memswap.py
+4
-0
glances/plugins/glances_network.py
glances/plugins/glances_network.py
+4
-0
未找到文件。
glances/plugins/glances_diskio.py
浏览文件 @
1286515f
...
...
@@ -17,13 +17,16 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
Glances CPU plugin
"""
# Import system lib
from
psutil
import
disk_io_counters
# Import Glances lib
# Import Glances libs
from
glances.plugins.glances_plugin
import
GlancesPlugin
from
glances.core.glances_globals
import
is_Mac
from
glances_plugin
import
GlancesPlugin
from
glances.core.glances_timer
import
getTimeSinceLastUpdate
...
...
@@ -46,57 +49,76 @@ class Plugin(GlancesPlugin):
# Enter -1 to diplay bottom
self
.
line_curse
=
3
# Init stats
self
.
diskio_old
=
[]
def
update
(
self
):
"""
Update disk IO stats
"""
self
.
diskio
=
[]
#
Disk IO stat not available on Mac OS
if
is_Mac
:
self
.
stats
=
self
.
diskio
return
self
.
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
(
'disk'
)
if
not
hasattr
(
self
,
'diskio_old'
):
# Grab the stat using the PsUtil disk_io_counters method
# read_count: number of reads
#
write_count: number of writes
# read_bytes: number of bytes read
# write_bytes: number of bytes written
# read_time: time spent reading from disk (in milliseconds)
# write_time: time spent writing to disk (in milliseconds)
diskiocounters
=
disk_io_counters
(
perdisk
=
True
)
#
Previous disk IO stats are stored in the diskio_old variable
diskio
=
[]
if
(
self
.
diskio_old
==
[]):
# First call, we init the network_old var
try
:
self
.
diskio_old
=
disk
_io_counters
(
perdisk
=
True
)
except
IOError
:
self
.
diskio_error_tag
=
True
self
.
diskio_old
=
disk
iocounters
except
(
IOError
,
UnboundLocalError
)
:
pass
else
:
self
.
diskio_new
=
disk_io_counters
(
perdisk
=
True
)
for
disk
in
self
.
diskio_new
:
# 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
(
'disk'
)
diskio_new
=
diskiocounters
for
disk
in
diskio_new
:
try
:
# Try necessary to manage dynamic disk creation/del
diskstat
=
{}
diskstat
[
'time_since_update'
]
=
time_since_update
diskstat
[
'disk_name'
]
=
disk
diskstat
[
'read_bytes'
]
=
(
self
.
diskio_new
[
disk
].
read_bytes
-
diskio_new
[
disk
].
read_bytes
-
self
.
diskio_old
[
disk
].
read_bytes
)
diskstat
[
'write_bytes'
]
=
(
self
.
diskio_new
[
disk
].
write_bytes
-
diskio_new
[
disk
].
write_bytes
-
self
.
diskio_old
[
disk
].
write_bytes
)
except
Exception
:
except
KeyError
:
continue
else
:
self
.
diskio
.
append
(
diskstat
)
self
.
diskio_old
=
self
.
diskio_new
diskio
.
append
(
diskstat
)
self
.
diskio_old
=
diskio_new
self
.
stats
=
diskio
self
.
stats
=
self
.
diskio
return
self
.
stats
def
msg_curse
(
self
,
args
=
None
):
"""
Return the dict to display in the curse interface
"""
#!!! TODO: Add alert on disk IO
#!!! TODO: manage the hide tag for disk IO list
# Init the return message
ret
=
[]
# Only process if stats exist...
if
(
self
.
stats
==
[]):
return
ret
# Build the string message
# Header
msg
=
"{0:8}"
.
format
(
_
(
"DISK I/O"
))
...
...
@@ -107,7 +129,6 @@ class Plugin(GlancesPlugin):
ret
.
append
(
self
.
curse_add_line
(
msg
))
# Disk list (sorted by name)
for
i
in
sorted
(
self
.
stats
,
key
=
lambda
diskio
:
diskio
[
'disk_name'
]):
# !!! TODO: manage the hide tag
# New line
ret
.
append
(
self
.
curse_new_line
())
msg
=
"{0:8}"
.
format
(
i
[
'disk_name'
])
...
...
glances/plugins/glances_fs.py
浏览文件 @
1286515f
...
...
@@ -115,6 +115,10 @@ class Plugin(GlancesPlugin):
# Init the return message
ret
=
[]
# Only process if stats exist...
if
(
self
.
stats
==
[]):
return
ret
# Build the string message
# Header
msg
=
"{0:8}"
.
format
(
_
(
"MOUNT"
))
...
...
glances/plugins/glances_mem.py
浏览文件 @
1286515f
...
...
@@ -98,6 +98,10 @@ class Plugin(GlancesPlugin):
# Init the return message
ret
=
[]
# Only process if stats exist...
if
(
self
.
stats
==
{}):
return
ret
# Build the string message
# Header
msg
=
"{0:5} "
.
format
(
_
(
"MEM"
))
...
...
glances/plugins/glances_memswap.py
浏览文件 @
1286515f
...
...
@@ -81,6 +81,10 @@ class Plugin(GlancesPlugin):
# Init the return message
ret
=
[]
# Only process if stats exist...
if
(
self
.
stats
==
{}):
return
ret
# Build the string message
# Header
msg
=
"{0:5} "
.
format
(
_
(
"SWAP"
))
...
...
glances/plugins/glances_network.py
浏览文件 @
1286515f
...
...
@@ -113,6 +113,10 @@ class Plugin(GlancesPlugin):
# Init the return message
ret
=
[]
# Only process if stats exist...
if
(
self
.
stats
==
[]):
return
ret
# Build the string message
# Header
msg
=
"{0:8}"
.
format
(
_
(
"NETWORK"
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录