Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
蜕变的菜鸟
glances
提交
47c6bcc2
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,发现更多精彩内容 >>
提交
47c6bcc2
编写于
4月 02, 2017
作者:
N
nicolargo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add trends in the Curses interface #1077
上级
130cd296
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
56 addition
and
9 deletion
+56
-9
NEWS
NEWS
+1
-0
glances/attribute.py
glances/attribute.py
+4
-0
glances/compat.py
glances/compat.py
+4
-0
glances/history.py
glances/history.py
+2
-2
glances/plugins/glances_cpu.py
glances/plugins/glances_cpu.py
+9
-1
glances/plugins/glances_mem.py
glances/plugins/glances_mem.py
+3
-1
glances/plugins/glances_memswap.py
glances/plugins/glances_memswap.py
+3
-1
glances/plugins/glances_plugin.py
glances/plugins/glances_plugin.py
+30
-4
未找到文件。
NEWS
浏览文件 @
47c6bcc2
...
...
@@ -8,6 +8,7 @@ Version 2.9.2
Enhancements and new features:
* Use -> and <- arrows keys to switch between processing sort (issue #1075)
* Add trends in the Curses interface (issue #1077)
Bugs corrected:
...
...
glances/attribute.py
浏览文件 @
47c6bcc2
...
...
@@ -126,6 +126,10 @@ class GlancesAttribute(object):
"""
return
self
.
_history
[
-
pos
]
def
history_raw
(
self
,
nb
=
0
):
"""Return the history of last nb items (0 for all) In ISO JSON format"""
return
self
.
_history
[
-
nb
:]
def
history_json
(
self
,
nb
=
0
):
"""Return the history of last nb items (0 for all) In ISO JSON format"""
return
[(
i
[
0
].
isoformat
(),
i
[
1
])
for
i
in
self
.
_history
[
-
nb
:]]
...
...
glances/compat.py
浏览文件 @
47c6bcc2
...
...
@@ -35,6 +35,7 @@ if PY3:
from
xmlrpc.server
import
SimpleXMLRPCRequestHandler
,
SimpleXMLRPCServer
from
urllib.request
import
urlopen
from
urllib.error
import
HTTPError
,
URLError
from
statistics
import
mean
input
=
input
range
=
range
...
...
@@ -103,6 +104,9 @@ else:
viewvalues
=
operator
.
methodcaller
(
'viewvalues'
)
viewitems
=
operator
.
methodcaller
(
'viewitems'
)
def
mean
(
numbers
):
return
float
(
sum
(
numbers
))
/
max
(
len
(
numbers
),
1
)
def
to_ascii
(
s
):
"""Convert the unicode 's' to a ASCII string
Usefull to remove accent (diacritics)"""
...
...
glances/history.py
浏览文件 @
47c6bcc2
...
...
@@ -49,9 +49,9 @@ class GlancesHistory(object):
for
a
in
self
.
stats_history
:
self
.
stats_history
[
a
].
history_reset
()
def
get
(
self
):
def
get
(
self
,
nb
=
0
):
"""Get the history as a dict of list"""
return
{
i
:
self
.
stats_history
[
i
].
history
for
i
in
self
.
stats_history
}
return
{
i
:
self
.
stats_history
[
i
].
history
_raw
(
nb
=
nb
)
for
i
in
self
.
stats_history
}
def
get_json
(
self
,
nb
=
0
):
"""Get the history as a dict of list (with list JSON compliant)"""
...
...
glances/plugins/glances_cpu.py
浏览文件 @
47c6bcc2
...
...
@@ -229,8 +229,16 @@ class Plugin(GlancesPlugin):
idle_tag
=
'user'
not
in
self
.
stats
# Header
msg
=
'{
:8
}'
.
format
(
'CPU'
)
msg
=
'{}'
.
format
(
'CPU'
)
ret
.
append
(
self
.
curse_add_line
(
msg
,
"TITLE"
))
trend_user
=
self
.
get_trend
(
'user'
)
trend_system
=
self
.
get_trend
(
'system'
)
if
trend_user
is
None
or
trend_user
is
None
:
trend_cpu
=
None
else
:
trend_cpu
=
trend_user
+
trend_system
msg
=
' {:4}'
.
format
(
self
.
trend_msg
(
trend_cpu
))
ret
.
append
(
self
.
curse_add_line
(
msg
))
# Total CPU usage
msg
=
'{:5.1f}%'
.
format
(
self
.
stats
[
'total'
])
if
idle_tag
:
...
...
glances/plugins/glances_mem.py
浏览文件 @
47c6bcc2
...
...
@@ -183,8 +183,10 @@ class Plugin(GlancesPlugin):
# Build the string message
# Header
msg
=
'{
:5}
'
.
format
(
'MEM'
)
msg
=
'{
}
'
.
format
(
'MEM'
)
ret
.
append
(
self
.
curse_add_line
(
msg
,
"TITLE"
))
msg
=
' {:2}'
.
format
(
self
.
trend_msg
(
self
.
get_trend
(
'percent'
)))
ret
.
append
(
self
.
curse_add_line
(
msg
))
# Percent memory usage
msg
=
'{:>7.1%}'
.
format
(
self
.
stats
[
'percent'
]
/
100
)
ret
.
append
(
self
.
curse_add_line
(
msg
))
...
...
glances/plugins/glances_memswap.py
浏览文件 @
47c6bcc2
...
...
@@ -154,8 +154,10 @@ class Plugin(GlancesPlugin):
# Build the string message
# Header
msg
=
'{
:7
} '
.
format
(
'SWAP'
)
msg
=
'{} '
.
format
(
'SWAP'
)
ret
.
append
(
self
.
curse_add_line
(
msg
,
"TITLE"
))
msg
=
' {:2}'
.
format
(
self
.
trend_msg
(
self
.
get_trend
(
'percent'
)))
ret
.
append
(
self
.
curse_add_line
(
msg
))
# Percent memory usage
msg
=
'{:>6.1%}'
.
format
(
self
.
stats
[
'percent'
]
/
100
)
ret
.
append
(
self
.
curse_add_line
(
msg
))
...
...
glances/plugins/glances_plugin.py
浏览文件 @
47c6bcc2
...
...
@@ -27,7 +27,7 @@ import re
import
json
from
operator
import
itemgetter
from
glances.compat
import
iterkeys
,
itervalues
,
listkeys
,
map
from
glances.compat
import
iterkeys
,
itervalues
,
listkeys
,
map
,
mean
from
glances.actions
import
GlancesActions
from
glances.history
import
GlancesHistory
from
glances.logger
import
logger
...
...
@@ -156,12 +156,13 @@ class GlancesPlugin(object):
"""Return the items history list."""
return
self
.
items_history_list
def
get_raw_history
(
self
,
item
=
None
):
def
get_raw_history
(
self
,
item
=
None
,
nb
=
0
):
"""Return
- the stats history (dict of list) if item is None
- the stats history for the given item (list) instead
- None if item did not exist in the history"""
s
=
self
.
stats_history
.
get
()
- None if item did not exist in the history
Limit to lasts nb items (all if nb=0)"""
s
=
self
.
stats_history
.
get
(
nb
=
nb
)
if
item
is
None
:
return
s
else
:
...
...
@@ -215,6 +216,17 @@ class GlancesPlugin(object):
else
:
return
None
def
get_trend
(
self
,
item
,
nb
=
6
):
"""Get the trend regarding to the last nb values
The trend is the diff between the mean of the last nb values
and the current one.
"""
raw_history
=
self
.
get_raw_history
(
item
=
item
,
nb
=
nb
)
if
raw_history
is
None
or
len
(
raw_history
)
<
nb
:
return
None
last_nb
=
[
v
[
1
]
for
v
in
raw_history
]
return
last_nb
[
-
1
]
-
mean
(
last_nb
[:
-
1
])
@
property
def
input_method
(
self
):
"""Get the input method."""
...
...
@@ -798,6 +810,20 @@ class GlancesPlugin(object):
value
,
decimal
=
decimal_precision
,
symbol
=
symbol
)
return
'{!s}'
.
format
(
number
)
def
trend_msg
(
self
,
trend
,
significant
=
1
):
"""Return the trend message
Do not take into account if trend < significant"""
logger
.
info
(
trend
)
ret
=
'-'
if
trend
is
None
:
ret
=
' '
elif
trend
>
significant
:
ret
=
'/'
elif
trend
<
-
significant
:
ret
=
'
\\
'
logger
.
info
(
ret
)
return
ret
def
_check_decorator
(
fct
):
"""Check if the plugin is enabled."""
def
wrapper
(
self
,
*
args
,
**
kw
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录