Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
蜕变的菜鸟
glances
提交
311ba7ce
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 搜索 >>
提交
311ba7ce
编写于
1月 25, 2014
作者:
N
Nicolas Hennion
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add FS and DiskIO plugins
上级
30826905
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
199 addition
and
12 deletion
+199
-12
glances/core/glances_core.py
glances/core/glances_core.py
+0
-7
glances/plugins/glances_diskio.py
glances/plugins/glances_diskio.py
+86
-0
glances/plugins/glances_fs.py
glances/plugins/glances_fs.py
+108
-0
glances/plugins/glances_network.py
glances/plugins/glances_network.py
+5
-5
未找到文件。
glances/core/glances_core.py
浏览文件 @
311ba7ce
...
...
@@ -56,13 +56,6 @@ if psutil_version < (0, 5, 0):
print
(
'PsUtil 0.5.1 or higher is needed. Glances cannot start.'
)
sys
.
exit
(
1
)
if
not
is_Mac
:
psutil_get_io_counter_tag
=
True
else
:
# get_io_counters() not available on OS X
psutil_get_io_counter_tag
=
False
class
GlancesCore
(
object
):
"""
Main class to manage Glances instance
...
...
glances/plugins/glances_diskio.py
0 → 100644
浏览文件 @
311ba7ce
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Glances - An eye on your system
#
# Copyright (C) 2014 Nicolargo <nicolas@nicolargo.com>
#
# Glances is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Glances is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# 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/>.
from
psutil
import
disk_io_counters
from
glances.core.glances_globals
import
is_Mac
from
glances_plugin
import
GlancesPlugin
,
getTimeSinceLastUpdate
class
Plugin
(
GlancesPlugin
):
"""
Glances's disks IO Plugin
stats is a list
"""
def
__init__
(
self
):
GlancesPlugin
.
__init__
(
self
)
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'
):
try
:
self
.
diskio_old
=
disk_io_counters
(
perdisk
=
True
)
except
IOError
:
self
.
diskio_error_tag
=
True
else
:
self
.
diskio_new
=
disk_io_counters
(
perdisk
=
True
)
for
disk
in
self
.
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
-
self
.
diskio_old
[
disk
].
read_bytes
)
diskstat
[
'write_bytes'
]
=
(
self
.
diskio_new
[
disk
].
write_bytes
-
self
.
diskio_old
[
disk
].
write_bytes
)
except
Exception
:
continue
else
:
self
.
diskio
.
append
(
diskstat
)
self
.
diskio_old
=
self
.
diskio_new
self
.
stats
=
self
.
diskio
def
get_stats
(
self
):
# Return the stats object for the RPC API
# Sort it by disk name
# Convert it to string
return
str
(
sorted
(
self
.
stats
,
key
=
lambda
network
:
network
[
'disk_name'
]))
glances/plugins/glances_fs.py
0 → 100644
浏览文件 @
311ba7ce
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Glances - An eye on your system
#
# Copyright (C) 2014 Nicolargo <nicolas@nicolargo.com>
#
# Glances is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Glances is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# 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/>.
from
psutil
import
disk_partitions
,
disk_usage
from
glances_plugin
import
GlancesPlugin
,
getTimeSinceLastUpdate
class
Plugin
(
GlancesPlugin
):
"""
Glances's File System (fs) Plugin
stats is a list
"""
def
__init__
(
self
):
GlancesPlugin
.
__init__
(
self
)
# Init the FS class
self
.
glancesgrabfs
=
glancesGrabFs
()
def
update
(
self
):
"""
Update stats
"""
self
.
stats
=
self
.
glancesgrabfs
.
get
()
def
get_stats
(
self
):
# Return the stats object for the RPC API
# Sort it by mount name
# Convert it to string
return
str
(
sorted
(
self
.
stats
,
key
=
lambda
network
:
network
[
'mnt_point'
]))
class
glancesGrabFs
:
"""
Get FS stats
"""
def
__init__
(
self
):
"""
Init FS stats
"""
# Ignore the following FS name
self
.
ignore_fsname
=
(
''
,
'cgroup'
,
'fusectl'
,
'gvfs-fuse-daemon'
,
'gvfsd-fuse'
,
'none'
)
# Ignore the following FS type
self
.
ignore_fstype
=
(
'autofs'
,
'binfmt_misc'
,
'configfs'
,
'debugfs'
,
'devfs'
,
'devpts'
,
'devtmpfs'
,
'hugetlbfs'
,
'iso9660'
,
'linprocfs'
,
'mqueue'
,
'none'
,
'proc'
,
'procfs'
,
'pstore'
,
'rootfs'
,
'securityfs'
,
'sysfs'
,
'usbfs'
)
# ignore FS by mount point
self
.
ignore_mntpoint
=
(
''
,
'/dev/shm'
,
'/lib/init/rw'
,
'/sys/fs/cgroup'
)
def
__update__
(
self
):
"""
Update the stats
"""
# Reset the list
self
.
fs_list
=
[]
# Open the current mounted FS
fs_stat
=
disk_partitions
(
all
=
True
)
for
fs
in
range
(
len
(
fs_stat
)):
fs_current
=
{}
fs_current
[
'device_name'
]
=
fs_stat
[
fs
].
device
if
fs_current
[
'device_name'
]
in
self
.
ignore_fsname
:
continue
fs_current
[
'fs_type'
]
=
fs_stat
[
fs
].
fstype
if
fs_current
[
'fs_type'
]
in
self
.
ignore_fstype
:
continue
fs_current
[
'mnt_point'
]
=
fs_stat
[
fs
].
mountpoint
if
fs_current
[
'mnt_point'
]
in
self
.
ignore_mntpoint
:
continue
try
:
fs_usage
=
disk_usage
(
fs_current
[
'mnt_point'
])
except
Exception
:
continue
fs_current
[
'size'
]
=
fs_usage
.
total
fs_current
[
'used'
]
=
fs_usage
.
used
fs_current
[
'avail'
]
=
fs_usage
.
free
self
.
fs_list
.
append
(
fs_current
)
def
get
(
self
):
self
.
__update__
()
return
self
.
fs_list
glances/plugins/glances_network.py
浏览文件 @
311ba7ce
...
...
@@ -48,10 +48,7 @@ class Plugin(GlancesPlugin):
Update network 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
(
'net'
)
network
=
[]
# psutil >= 1.0.0
try
:
...
...
@@ -63,7 +60,10 @@ class Plugin(GlancesPlugin):
except
IOError
:
pass
network
=
[]
# 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
(
'net'
)
# Previous network interface stats are stored in the network_old variable
if
not
hasattr
(
self
,
'network_old'
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录