Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
蜕变的菜鸟
glances
提交
b6d25c75
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,发现更多精彩内容 >>
提交
b6d25c75
编写于
5月 02, 2012
作者:
N
nicolargo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Allow user to disable module from the command line
上级
e413c170
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
85 addition
and
59 deletion
+85
-59
NEWS
NEWS
+3
-0
glances/glances.py
glances/glances.py
+81
-58
glances/html/default.html
glances/html/default.html
+1
-1
未找到文件。
NEWS
浏览文件 @
b6d25c75
...
...
@@ -9,6 +9,9 @@ Version 1.4
* Only major stats (CPU, Load and memory) use background colors
* Add optionnal (if space is available): PID, UID
* Improve operating system name
* Disable Disk IO module from the command line (-d)
* Disable Mount module from the command line (-m)
* Disable Net rate module from the command line (-n)
* Code is now checked with pep8
Version 1.3.7
...
...
glances/glances.py
浏览文件 @
b6d25c75
...
...
@@ -22,7 +22,7 @@
from
__future__
import
generators
__appname__
=
'glances'
__version__
=
"1.4b1
8
"
__version__
=
"1.4b1
9
"
__author__
=
"Nicolas Hennion <nicolas@nicolargo.com>"
__licence__
=
"LGPL"
...
...
@@ -309,7 +309,8 @@ class glancesGrabFs:
# Ignore the following FS type
self
.
ignore_fstype
=
(
'binfmt_misc'
,
'devpts'
,
'iso9660'
,
'none'
,
\
'proc'
,
'sysfs'
,
'usbfs'
,
'rootfs'
,
'autofs'
)
'proc'
,
'sysfs'
,
'usbfs'
,
'rootfs'
,
'autofs'
,
\
'devtmpfs'
)
def
__update__
(
self
):
"""
...
...
@@ -496,66 +497,69 @@ class glancesStats:
self
.
memswap
=
{}
# NET
self
.
network
=
[]
try
:
self
.
network_old
except
:
if
(
psutil_network_io_tag
):
self
.
network_old
=
psutil
.
network_io_counters
(
True
)
else
:
if
psutil_network_io_tag
:
self
.
network
=
[]
try
:
self
.
network_
new
=
psutil
.
network_io_counters
(
True
)
self
.
network_
old
except
:
pass
if
(
psutil_network_io_tag
):
self
.
network_old
=
psutil
.
network_io_counters
(
True
)
else
:
for
net
in
self
.
network_new
:
try
:
netstat
=
{}
netstat
[
'interface_name'
]
=
net
netstat
[
'rx'
]
=
self
.
network_new
[
net
].
bytes_recv
-
\
self
.
network_old
[
net
].
bytes_recv
netstat
[
'tx'
]
=
self
.
network_new
[
net
].
bytes_sent
-
\
self
.
network_old
[
net
].
bytes_sent
except
:
continue
else
:
self
.
network
.
append
(
netstat
)
self
.
network_old
=
self
.
network_new
try
:
self
.
network_new
=
psutil
.
network_io_counters
(
True
)
except
:
pass
else
:
for
net
in
self
.
network_new
:
try
:
netstat
=
{}
netstat
[
'interface_name'
]
=
net
netstat
[
'rx'
]
=
self
.
network_new
[
net
].
bytes_recv
-
\
self
.
network_old
[
net
].
bytes_recv
netstat
[
'tx'
]
=
self
.
network_new
[
net
].
bytes_sent
-
\
self
.
network_old
[
net
].
bytes_sent
except
:
continue
else
:
self
.
network
.
append
(
netstat
)
self
.
network_old
=
self
.
network_new
# DISK I/O
self
.
diskio
=
[]
try
:
self
.
diskio_old
except
:
if
(
psutil_disk_io_tag
):
self
.
diskio_old
=
psutil
.
disk_io_counters
(
True
)
else
:
if
psutil_disk_io_tag
:
self
.
diskio
=
[]
try
:
self
.
diskio_
new
=
psutil
.
disk_io_counters
(
True
)
self
.
diskio_
old
except
:
pass
if
(
psutil_disk_io_tag
):
self
.
diskio_old
=
psutil
.
disk_io_counters
(
True
)
else
:
for
disk
in
self
.
diskio_new
:
try
:
diskstat
=
{}
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
:
continue
else
:
self
.
diskio
.
append
(
diskstat
)
self
.
diskio_old
=
self
.
diskio_new
try
:
self
.
diskio_new
=
psutil
.
disk_io_counters
(
True
)
except
:
pass
else
:
for
disk
in
self
.
diskio_new
:
try
:
diskstat
=
{}
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
:
continue
else
:
self
.
diskio
.
append
(
diskstat
)
self
.
diskio_old
=
self
.
diskio_new
# FILE SYSTEM
try
:
self
.
fs
=
self
.
glancesgrabfs
.
get
()
except
:
self
.
fs
=
{}
if
psutil_fs_usage_tag
:
try
:
self
.
fs
=
self
.
glancesgrabfs
.
get
()
except
:
self
.
fs
=
{}
# PROCESS
# Initialiation of the running processes list
...
...
@@ -653,14 +657,23 @@ class glancesStats:
return
self
.
memswap
def
getNetwork
(
self
):
return
sorted
(
self
.
network
,
\
key
=
lambda
network
:
network
[
'interface_name'
])
if
psutil_network_io_tag
:
return
sorted
(
self
.
network
,
\
key
=
lambda
network
:
network
[
'interface_name'
])
else
:
return
0
def
getDiskIO
(
self
):
return
sorted
(
self
.
diskio
,
key
=
lambda
diskio
:
diskio
[
'disk_name'
])
if
psutil_disk_io_tag
:
return
sorted
(
self
.
diskio
,
key
=
lambda
diskio
:
diskio
[
'disk_name'
])
else
:
return
0
def
getFs
(
self
):
return
sorted
(
self
.
fs
,
key
=
lambda
fs
:
fs
[
'mnt_point'
])
if
psutil_fs_usage_tag
:
return
sorted
(
self
.
fs
,
key
=
lambda
fs
:
fs
[
'mnt_point'
])
else
:
return
0
def
getProcessCount
(
self
):
return
self
.
processcount
...
...
@@ -1749,8 +1762,11 @@ def printSyntax():
printVersion
()
print
_
(
"Usage: glances [-f file] [-o output] [-t sec] [-h] [-v]"
)
print
""
print
_
(
"
\t
-d
\t\t
Disable Disk I/O module"
)
print
_
(
"
\t
-f file
\t\t
Set the output folder (HTML) or file (CSV)"
)
print
_
(
"
\t
-h
\t\t
Display the syntax and exit"
)
print
_
(
"
\t
-m
\t\t
Disable Mount module"
)
print
_
(
"
\t
-n
\t\t
Disable Net Rate module"
)
print
_
(
"
\t
-o output
\t
Define additional output (available: HTML or CSV)"
)
print
_
(
"
\t
-t sec
\t\t
Set the refresh time in second default is %d"
\
%
refresh_time
)
...
...
@@ -1772,6 +1788,7 @@ def printSyntax():
def
init
():
global
psutil_disk_io_tag
,
psutil_fs_usage_tag
,
psutil_network_io_tag
global
limits
,
logs
,
stats
,
screen
global
htmloutput
,
csvoutput
global
html_tag
,
csv_tag
...
...
@@ -1787,7 +1804,7 @@ def init():
# Manage args
try
:
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
\
"ho:f:t:v"
,
\
"
dmn
ho:f:t:v"
,
\
[
"help"
,
"output"
,
"file"
,
"time"
,
"version"
])
except
getopt
.
GetoptError
,
err
:
# Print help information and exit:
...
...
@@ -1825,10 +1842,16 @@ def init():
else
:
print
_
(
"Error: Refresh time should be a positive integer"
)
sys
.
exit
(
2
)
elif
opt
in
(
"-d"
,
"--diskio"
):
psutil_disk_io_tag
=
False
elif
opt
in
(
"-m"
,
"--mount"
):
psutil_fs_usage_tag
=
False
elif
opt
in
(
"-n"
,
"--netrate"
):
psutil_network_io_tag
=
False
else
:
printSyntax
()
sys
.
exit
(
0
)
# Check options
if
(
html_tag
):
try
:
...
...
glances/html/default.html
浏览文件 @
b6d25c75
...
...
@@ -9,7 +9,7 @@
{% block cpu %}
{% if cpu is defined %}
<table
>
<table>
<thead>
<tr>
<th
scope=
"col"
class=
"bgcpu fgcpu"
></th>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录