Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
蜕变的菜鸟
glances
提交
ad0a6ee3
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 搜索 >>
提交
ad0a6ee3
编写于
5月 29, 2016
作者:
N
nicolargo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add a new GlancesHistory class
上级
841d1156
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
75 addition
and
32 deletion
+75
-32
NEWS
NEWS
+8
-7
glances/history.py
glances/history.py
+56
-0
glances/plugins/glances_plugin.py
glances/plugins/glances_plugin.py
+11
-25
未找到文件。
NEWS
浏览文件 @
ad0a6ee3
...
...
@@ -5,6 +5,13 @@ Glances Version 2
Version 2.7
===========
Deprecated:
* Drop Python 2.6 support (issue #300)
* Monitoring process list module is replaced by AMP (see issue #780)
* Use --export-graph instead of --enable-history (issue #696)
* Use --path-graph instead of --path-history (issue #696)
Enhancements and new features:
* Add Application Monitoring Process plugin (issue #780)
...
...
@@ -15,6 +22,7 @@ Enhancements and new features:
* [Web UI] Add cpu name in quicklook plugin (issue #825)
* Allow theme to be set in configuration file (issue #862)
* Display a warning message when Glances is outdated (issue #865)
* Refactor stats history and export to graph (issue #696)
Bugs corrected:
...
...
@@ -24,13 +32,6 @@ Bugs corrected:
* Idle process is back on FreeBSD and Windows (issue #844)
* Top 3 processes are back in the alert summay
Deprecated:
* Drop Python 2.6 support (issue #300)
* Monitoring process list module is replaced by AMP (see issue #780)
* Use --export-graph instead of --enable-history (issue #696)
* Use --path-graph instead of --path-history (issue #696)
Version 2.6.1
=============
...
...
glances/history.py
0 → 100644
浏览文件 @
ad0a6ee3
# -*- coding: utf-8 -*-
#
# This file is part of Glances.
#
# Copyright (C) 2016 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/>.
"""Manage stats history"""
from
glances.attribute
import
GlancesAttribute
class
GlancesHistory
(
object
):
"""This class manage a dict of GlancesAttribute
- key: stats name
- GlancesAttribute: history value"""
def
__init__
(
self
):
"""
items_history_list: list of stats to historized (define inside plugins)
"""
self
.
stats_history
=
{}
def
add
(
self
,
key
,
value
,
description
=
''
,
history_max_size
=
None
,
is_rate
=
False
):
"""Add an new item (key, value) to the current history."""
if
key
not
in
self
.
stats_history
:
self
.
stats_history
[
key
]
=
GlancesAttribute
(
key
,
description
=
description
,
history_max_size
=
history_max_size
,
is_rate
=
is_rate
)
self
.
stats_history
[
key
].
value
=
value
def
reset
(
self
):
"""Reset all the stats history"""
for
a
in
self
.
stats_history
:
self
.
stats_history
[
a
].
history_reset
()
def
get
(
self
):
"""Get the history as a dict of list"""
return
{
i
:
self
.
stats_history
[
i
].
history
for
i
in
self
.
stats_history
}
glances/plugins/glances_plugin.py
浏览文件 @
ad0a6ee3
...
...
@@ -30,7 +30,7 @@ from operator import itemgetter
from
glances.compat
import
iterkeys
,
itervalues
,
listkeys
,
map
from
glances.actions
import
GlancesActions
from
glances.
attribute
import
GlancesAttribute
from
glances.
history
import
GlancesHistory
from
glances.logger
import
logger
from
glances.logs
import
glances_logs
...
...
@@ -87,47 +87,33 @@ class GlancesPlugin(object):
"""Return the key of the list."""
return
None
def
add_item_history
(
self
,
key
,
value
,
description
=
''
,
history_max_size
=
None
,
is_rate
=
False
):
"""Add an new item (key, value) to the current history."""
if
key
not
in
self
.
stats_history
:
self
.
stats_history
[
key
]
=
GlancesAttribute
(
key
,
description
=
description
,
history_max_size
=
history_max_size
)
self
.
stats_history
[
key
].
value
=
value
def
init_stats_history
(
self
):
"""Init the stats history (dict of GlancesAttribute)."""
ret
=
{}
if
self
.
args
is
not
None
and
self
.
args
.
export_graph
and
self
.
get_items_history_list
()
is
not
None
:
init_list
=
[
a
[
'name'
]
for
a
in
self
.
get_items_history_list
()]
logger
.
debug
(
"Stats history activated for plugin {0} (items: {1})"
.
format
(
self
.
plugin_name
,
init_list
))
return
ret
return
GlancesHistory
()
def
reset_stats_history
(
self
):
"""Reset the stats history (dict of GlancesAttribute)."""
if
self
.
args
is
not
None
and
self
.
args
.
export_graph
and
self
.
get_items_history_list
()
is
not
None
:
reset_list
=
[
a
[
'name'
]
for
a
in
self
.
get_items_history_list
()]
logger
.
debug
(
"Reset history for plugin {0} (items: {1})"
.
format
(
self
.
plugin_name
,
reset_list
))
for
a
in
self
.
stats_history
:
self
.
stats_history
[
a
].
history_reset
()
self
.
stats_history
.
reset
()
def
update_stats_history
(
self
,
item_name
=
''
):
"""Update stats history."""
if
(
self
.
stats
and
self
.
args
is
not
None
and
self
.
args
.
export_graph
and
self
.
get_items_history_list
()
is
not
None
):
# TODO in attribute ?
self
.
add_item_history
(
'date'
,
datetime
.
now
())
self
.
stats_history
.
add
(
'date'
,
datetime
.
now
())
for
i
in
self
.
get_items_history_list
():
if
isinstance
(
self
.
stats
,
list
):
# Stats is a list of data
# Iter throught it (for exemple, iter throught network
# interface)
for
l
in
self
.
stats
:
self
.
add_item_history
(
self
.
stats_history
.
add
(
l
[
item_name
]
+
'_'
+
i
[
'name'
],
l
[
i
[
'name'
]],
description
=
i
[
'description'
],
...
...
@@ -135,17 +121,17 @@ class GlancesPlugin(object):
else
:
# Stats is not a list
# Add the item to the history directly
self
.
add_item_history
(
i
[
'name'
],
self
.
stats
[
i
[
'name'
]],
description
=
i
[
'description'
],
history_max_size
=
None
)
self
.
stats_history
.
add
(
i
[
'name'
],
self
.
stats
[
i
[
'name'
]],
description
=
i
[
'description'
],
history_max_size
=
None
)
def
get_stats_history
(
self
):
"""Return the stats history (dict of list)."""
return
{
i
:
self
.
stats_history
[
i
].
history
for
i
in
self
.
stats_history
}
return
self
.
stats_history
.
get
()
def
get_items_history_list
(
self
):
"""Return the items history list
(define inside the plugins scripts)
."""
"""Return the items history list."""
return
self
.
items_history_list
@
property
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录