Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
蜕变的菜鸟
glances
提交
859ed24c
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,发现更多精彩内容 >>
提交
859ed24c
编写于
1月 18, 2015
作者:
N
Nicolargo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add view (MVC speeking) for the plugins. Client/Server OK.
上级
04377b8c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
19 addition
and
8 deletion
+19
-8
glances/core/glances_stats.py
glances/core/glances_stats.py
+3
-1
glances/plugins/glances_plugin.py
glances/plugins/glances_plugin.py
+12
-7
glances/plugins/glances_processlist.py
glances/plugins/glances_processlist.py
+4
-0
未找到文件。
glances/core/glances_stats.py
浏览文件 @
859ed24c
...
...
@@ -288,9 +288,11 @@ class GlancesStatsClient(GlancesStats):
def
update
(
self
,
input_stats
):
"""Update all the stats."""
# For Glances client mode
# Update plugin stats with items sent by the server
for
p
in
input_stats
:
# Update plugin stats with items sent by the server
self
.
_plugins
[
p
].
set_stats
(
input_stats
[
p
])
# Update the views for the updated stats
self
.
_plugins
[
p
].
update_views
()
class
GlancesStatsClientSNMP
(
GlancesStats
):
...
...
glances/plugins/glances_plugin.py
浏览文件 @
859ed24c
...
...
@@ -95,7 +95,8 @@ class GlancesPlugin(object):
ret
=
None
if
self
.
args
is
not
None
and
self
.
args
.
enable_history
and
self
.
get_items_history_list
()
is
not
None
:
init_list
=
[
i
[
'name'
]
for
i
in
self
.
get_items_history_list
()]
logger
.
debug
(
"Stats history activated for plugin {0} (items: {0})"
.
format
(
self
.
plugin_name
,
init_list
))
logger
.
debug
(
"Stats history activated for plugin {0} (items: {0})"
.
format
(
self
.
plugin_name
,
init_list
))
ret
=
{}
return
ret
...
...
@@ -103,7 +104,8 @@ class GlancesPlugin(object):
"""Reset the stats history (dict of list)"""
if
self
.
args
is
not
None
and
self
.
args
.
enable_history
and
self
.
get_items_history_list
()
is
not
None
:
reset_list
=
[
i
[
'name'
]
for
i
in
self
.
get_items_history_list
()]
logger
.
debug
(
"Reset history for plugin {0} (items: {0})"
.
format
(
self
.
plugin_name
,
reset_list
))
logger
.
debug
(
"Reset history for plugin {0} (items: {0})"
.
format
(
self
.
plugin_name
,
reset_list
))
self
.
stats_history
=
{}
return
self
.
stats_history
...
...
@@ -255,7 +257,8 @@ class GlancesPlugin(object):
try
:
return
json
.
dumps
({
value
:
[
i
for
i
in
self
.
stats
if
i
[
item
]
==
value
]})
except
(
KeyError
,
ValueError
)
as
e
:
logger
.
error
(
"Cannot get item({0})=value({1}) ({2})"
.
format
(
item
,
value
,
e
))
logger
.
error
(
"Cannot get item({0})=value({1}) ({2})"
.
format
(
item
,
value
,
e
))
return
None
def
update_views
(
self
):
...
...
@@ -270,7 +273,7 @@ class GlancesPlugin(object):
"""
ret
=
{}
if
type
(
self
.
get_raw
())
is
list
:
if
type
(
self
.
get_raw
())
is
list
and
self
.
get_raw
()
is
not
None
and
self
.
get_key
()
is
not
None
:
# Stats are stored in a list of dict (ex: NETWORK, FS...)
for
i
in
self
.
get_raw
():
ret
[
i
[
self
.
get_key
()]]
=
{}
...
...
@@ -280,7 +283,7 @@ class GlancesPlugin(object):
'additional'
:
False
,
'splittable'
:
False
}
ret
[
i
[
self
.
get_key
()]][
key
]
=
value
el
s
e
:
el
if
type
(
self
.
get_raw
())
is
dict
and
self
.
get_raw
()
is
not
Non
e
:
# Stats are stored in a dict (ex: CPU, LOAD...)
for
key
in
self
.
get_raw
().
keys
():
value
=
{
'decoration'
:
'DEFAULT'
,
...
...
@@ -411,13 +414,15 @@ class GlancesPlugin(object):
# If the stats are stored in a list of dict (fs plugin for exemple)
# Return the dict for the current header
try
:
mustache_dict
=
(
item
for
item
in
self
.
stats
if
item
[
self
.
get_key
()]
==
header
).
next
()
mustache_dict
=
(
item
for
item
in
self
.
stats
if
item
[
self
.
get_key
()]
==
header
).
next
()
except
StopIteration
:
mustache_dict
=
{}
else
:
# Use the stats dict
mustache_dict
=
self
.
stats
self
.
actions
.
run
(
stat_name
,
ret
.
lower
(),
command
,
mustache_dict
=
mustache_dict
)
self
.
actions
.
run
(
stat_name
,
ret
.
lower
(),
command
,
mustache_dict
=
mustache_dict
)
# Default is ok
return
ret
+
log_str
...
...
glances/plugins/glances_processlist.py
浏览文件 @
859ed24c
...
...
@@ -46,6 +46,10 @@ class Plugin(GlancesPlugin):
# Note: 'glances_processes' is already init in the glances_processes.py script
def
get_key
(
self
):
"""Return the key of the list"""
return
'pid'
def
reset
(
self
):
"""Reset/init the stats."""
self
.
stats
=
[]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录