Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
蜕变的菜鸟
glances
提交
841d1156
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 搜索 >>
提交
841d1156
编写于
5月 29, 2016
作者:
N
nicolargo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename glances_history to graph
上级
13fbad5b
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
38 addition
and
35 deletion
+38
-35
NEWS
NEWS
+2
-0
glances/exports/graph.py
glances/exports/graph.py
+3
-3
glances/main.py
glances/main.py
+10
-8
glances/outputs/glances_curses.py
glances/outputs/glances_curses.py
+20
-21
glances/plugins/glances_plugin.py
glances/plugins/glances_plugin.py
+3
-3
未找到文件。
NEWS
浏览文件 @
841d1156
...
...
@@ -28,6 +28,8 @@ 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/exports/g
lances_history
.py
→
glances/exports/g
raph
.py
浏览文件 @
841d1156
...
...
@@ -17,7 +17,7 @@
# 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/>.
"""
History
class."""
"""
Graph generation
class."""
import
os
...
...
@@ -35,9 +35,9 @@ else:
logger
.
info
(
'Load Matplotlib version %s'
%
matplotlib_version
)
class
Glances
History
(
object
):
class
Glances
Graph
(
object
):
"""Th
is class define the object to manage stats history
."""
"""Th
anks to this class, Glances can export history to graphs
."""
def
__init__
(
self
,
output_folder
):
self
.
output_folder
=
output_folder
...
...
glances/main.py
浏览文件 @
841d1156
...
...
@@ -148,11 +148,13 @@ Start the client browser (browser mode):\n\
dest
=
'disable_bg'
,
help
=
'disable background colors in the terminal'
)
parser
.
add_argument
(
'--enable-process-extended'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'enable_process_extended'
,
help
=
'enable extended stats on top process'
)
parser
.
add_argument
(
'--enable-history'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'enable_history'
,
help
=
'enable the history mode (matplotlib needed)'
)
parser
.
add_argument
(
'--path-history'
,
default
=
tempfile
.
gettempdir
(),
dest
=
'path_history'
,
help
=
'set the export path for graph history'
)
# Export modules feature
# --enable-history is for 2.7< version compatibility
parser
.
add_argument
(
'--export-graph'
,
'--enable-history'
,
action
=
'store_true'
,
default
=
None
,
dest
=
'export_graph'
,
help
=
'export stats to graphs'
)
# --path-history is for 2.7< version compatibility
parser
.
add_argument
(
'--path-graph'
,
'--path-history'
,
default
=
tempfile
.
gettempdir
(),
dest
=
'path_graph'
,
help
=
'set the export path for graphs (default is {0})'
.
format
(
tempfile
.
gettempdir
()))
parser
.
add_argument
(
'--export-csv'
,
default
=
None
,
dest
=
'export_csv'
,
help
=
'export stats to a CSV file'
)
parser
.
add_argument
(
'--export-influxdb'
,
action
=
'store_true'
,
default
=
False
,
...
...
@@ -337,11 +339,11 @@ Start the client browser (browser mode):\n\
sys
.
exit
(
2
)
# Check graph output path
if
args
.
e
nable_history
and
args
.
path_history
is
not
None
:
if
not
os
.
access
(
args
.
path_
history
,
os
.
W_OK
):
logger
.
critical
(
"
History output path {0} do not exist or is not writable"
.
format
(
args
.
path_history
))
if
args
.
e
xport_graph
and
args
.
path_graph
is
not
None
:
if
not
os
.
access
(
args
.
path_
graph
,
os
.
W_OK
):
logger
.
critical
(
"
Graphs output path {0} do not exist or is not writable"
.
format
(
args
.
path_graph
))
sys
.
exit
(
2
)
logger
.
debug
(
"
History output path is set to {0}"
.
format
(
args
.
path_history
))
logger
.
debug
(
"
Graphs output path is set to {0}"
.
format
(
args
.
path_graph
))
# Disable HDDTemp if sensors are disabled
if
args
.
disable_sensors
:
...
...
glances/outputs/glances_curses.py
浏览文件 @
841d1156
...
...
@@ -117,16 +117,15 @@ class _GlancesCurses(object):
'''Init the history option'''
self
.
reset_history_tag
=
False
self
.
history_tag
=
False
if
self
.
args
.
enable_history
:
logger
.
info
(
'Stats history enabled with output path %s'
%
self
.
args
.
path_history
)
from
glances.exports.glances_history
import
GlancesHistory
self
.
glances_history
=
GlancesHistory
(
self
.
args
.
path_history
)
if
not
self
.
glances_history
.
graph_enabled
():
self
.
args
.
enable_history
=
False
logger
.
error
(
'Stats history disabled because MatPlotLib is not installed'
)
self
.
graph_tag
=
False
if
self
.
args
.
export_graph
:
logger
.
info
(
'Export graphs function enabled with output path %s'
%
self
.
args
.
path_graph
)
from
glances.exports.graph
import
GlancesGraph
self
.
glances_graph
=
GlancesGraph
(
self
.
args
.
path_graph
)
if
not
self
.
glances_graph
.
graph_enabled
():
self
.
args
.
export_graph
=
False
logger
.
error
(
'Export graphs disabled'
)
def
_init_cursor
(
self
):
'''Init cursors'''
...
...
@@ -384,8 +383,8 @@ class _GlancesCurses(object):
self
.
args
.
disable_fs
=
not
self
.
args
.
disable_fs
self
.
args
.
disable_folder
=
not
self
.
args
.
disable_folder
elif
self
.
pressedkey
==
ord
(
'g'
):
# 'g' >
History
self
.
history_tag
=
not
self
.
history
_tag
# 'g' >
Export graphs to file
self
.
graph_tag
=
not
self
.
graph
_tag
elif
self
.
pressedkey
==
ord
(
'h'
):
# 'h' > Show/hide help
self
.
args
.
help_tag
=
not
self
.
args
.
help_tag
...
...
@@ -756,25 +755,25 @@ class _GlancesCurses(object):
# History option
# Generate history graph
if
self
.
history_tag
and
self
.
args
.
enable_history
:
if
self
.
graph_tag
and
self
.
args
.
export_graph
:
self
.
display_popup
(
'Generate graphs history in {0}
\n
Please wait...'
.
format
(
self
.
glances_
history
.
get_output_folder
()))
self
.
glances_
graph
.
get_output_folder
()))
self
.
display_popup
(
'Generate graphs history in {0}
\n
Done: {1} graphs generated'
.
format
(
self
.
glances_
history
.
get_output_folder
(),
self
.
glances_
history
.
generate_graph
(
stats
)))
elif
self
.
reset_history_tag
and
self
.
args
.
e
nable_history
:
self
.
glances_
graph
.
get_output_folder
(),
self
.
glances_
graph
.
generate_graph
(
stats
)))
elif
self
.
reset_history_tag
and
self
.
args
.
e
xport_graph
:
self
.
display_popup
(
'Reset history'
)
self
.
glances_
history
.
reset
(
stats
)
elif
(
self
.
history_tag
or
self
.
reset_history_tag
)
and
not
self
.
args
.
enable_history
:
self
.
glances_
graph
.
reset
(
stats
)
elif
(
self
.
graph_tag
or
self
.
reset_history_tag
)
and
not
self
.
args
.
export_graph
:
try
:
self
.
glances_
history
.
graph_enabled
()
self
.
glances_
graph
.
graph_enabled
()
except
Exception
:
self
.
display_popup
(
'History disabled
\n
Enable it using --enable-history'
)
else
:
self
.
display_popup
(
'History disabled
\n
Please install matplotlib'
)
self
.
history
_tag
=
False
self
.
graph
_tag
=
False
self
.
reset_history_tag
=
False
# Display edit filter popup
...
...
glances/plugins/glances_plugin.py
浏览文件 @
841d1156
...
...
@@ -101,14 +101,14 @@ class GlancesPlugin(object):
def
init_stats_history
(
self
):
"""Init the stats history (dict of GlancesAttribute)."""
ret
=
{}
if
self
.
args
is
not
None
and
self
.
args
.
e
nable_history
and
self
.
get_items_history_list
()
is
not
None
:
if
self
.
args
is
not
None
and
self
.
args
.
e
xport_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
def
reset_stats_history
(
self
):
"""Reset the stats history (dict of GlancesAttribute)."""
if
self
.
args
is
not
None
and
self
.
args
.
e
nable_history
and
self
.
get_items_history_list
()
is
not
None
:
if
self
.
args
is
not
None
and
self
.
args
.
e
xport_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
:
...
...
@@ -117,7 +117,7 @@ class GlancesPlugin(object):
def
update_stats_history
(
self
,
item_name
=
''
):
"""Update stats history."""
if
(
self
.
stats
and
self
.
args
is
not
None
and
self
.
args
.
e
nable_history
and
self
.
args
.
e
xport_graph
and
self
.
get_items_history_list
()
is
not
None
):
# TODO in attribute ?
self
.
add_item_history
(
'date'
,
datetime
.
now
())
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录