Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
蜕变的菜鸟
glances
提交
94614e1f
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,发现更多精彩内容 >>
提交
94614e1f
编写于
10月 12, 2014
作者:
N
Nicolargo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add a configuration key to set the gaph ouput folder --output-history - issue #428
上级
7edcd3e4
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
25 addition
and
19 deletion
+25
-19
glances/core/glances_main.py
glances/core/glances_main.py
+16
-4
glances/outputs/glances_curses.py
glances/outputs/glances_curses.py
+3
-3
glances/outputs/glances_history.py
glances/outputs/glances_history.py
+6
-12
未找到文件。
glances/core/glances_main.py
浏览文件 @
94614e1f
...
...
@@ -22,6 +22,8 @@
# Import system libs
import
argparse
import
sys
import
os
import
tempfile
# Import Glances libs
from
glances.core.glances_config
import
Config
...
...
@@ -34,6 +36,7 @@ class GlancesMain(object):
# Default stats' refresh time is 3 seconds
refresh_time
=
3
# Set the default cache lifetime to 1 second (only for server)
# !!! Todo: configuration from the command line
cached_time
=
1
...
...
@@ -61,10 +64,6 @@ class GlancesMain(object):
parser
.
add_argument
(
'-C'
,
'--config'
,
dest
=
'conf_file'
,
help
=
_
(
'path to the configuration file'
))
# Enable or disable option on startup
parser
.
add_argument
(
'--enable-history'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'enable_history'
,
help
=
_
(
'enable the history mode'
))
parser
.
add_argument
(
'--disable-bold'
,
action
=
'store_false'
,
default
=
True
,
dest
=
'disable_bold'
,
help
=
_
(
'disable bold mode in the terminal'
))
parser
.
add_argument
(
'--disable-network'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'disable_network'
,
help
=
_
(
'disable network module'
))
parser
.
add_argument
(
'--disable-diskio'
,
action
=
'store_true'
,
default
=
False
,
...
...
@@ -81,6 +80,12 @@ class GlancesMain(object):
dest
=
'disable_process_extended'
,
help
=
_
(
'disable extended stats on top process'
))
parser
.
add_argument
(
'--disable-log'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'disable_log'
,
help
=
_
(
'disable log module'
))
parser
.
add_argument
(
'--disable-bold'
,
action
=
'store_false'
,
default
=
True
,
dest
=
'disable_bold'
,
help
=
_
(
'disable bold mode in the terminal'
))
parser
.
add_argument
(
'--enable-history'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'enable_history'
,
help
=
_
(
'enable the history mode'
))
parser
.
add_argument
(
'--path-history'
,
default
=
tempfile
.
gettempdir
(),
dest
=
'path_history'
,
help
=
_
(
'Set the export path for graph history'
))
# CSV output feature
parser
.
add_argument
(
'--output-csv'
,
default
=
None
,
dest
=
'output_csv'
,
help
=
_
(
'export stats to a CSV file'
))
...
...
@@ -187,6 +192,13 @@ class GlancesMain(object):
logger
.
critical
(
_
(
"Process filter is only available in standalone mode"
))
sys
.
exit
(
2
)
# Check graph output path
if
args
.
enable_history
and
args
.
path_history
is
not
None
:
if
not
os
.
access
(
args
.
path_history
,
os
.
W_OK
):
logger
.
critical
(
_
(
"History output path (%s) do not exist or is not writable"
)
%
args
.
path_history
)
sys
.
exit
(
2
)
logger
.
info
(
_
(
"History output path is %s"
)
%
args
.
path_history
)
return
args
def
__hash_password
(
self
,
plain_password
):
...
...
glances/outputs/glances_curses.py
浏览文件 @
94614e1f
...
...
@@ -184,12 +184,12 @@ class GlancesCurses(object):
self
.
reset_history_tag
=
False
self
.
history_tag
=
False
if
args
.
enable_history
:
logger
.
info
(
'Stats history enabled
'
)
logger
.
info
(
'Stats history enabled
with output path %s'
%
args
.
path_history
)
from
glances.outputs.glances_history
import
GlancesHistory
self
.
glances_history
=
GlancesHistory
()
self
.
glances_history
=
GlancesHistory
(
args
.
path_history
)
if
not
self
.
glances_history
.
graph_enabled
():
args
.
enable_history
=
False
logger
.
error
(
'Stats history disabled because
graph lib is not available
'
)
logger
.
error
(
'Stats history disabled because
MatPlotLib is not installed
'
)
def
set_cursor
(
self
,
value
):
"""Configure the cursor
...
...
glances/outputs/glances_history.py
浏览文件 @
94614e1f
...
...
@@ -21,7 +21,6 @@
# Import system lib
import
os
import
tempfile
# Import Glances lib
from
glances.core.glances_globals
import
logger
...
...
@@ -43,12 +42,7 @@ class GlancesHistory(object):
"""This class define the object to manage stats history"""
def
__init__
(
self
,
output_folder
=
tempfile
.
gettempdir
()):
# !!! MINUS: matplotlib footprint (mem/cpu) => Fork process ?
# !!! MINUS: Mem used to store history
# !!! TODO: sampling before graph => Usefull ?
# !!! TODO: do not display first two point (glances is running)
# !!! TODO: replace /tmp by a cross platform way to get /tmp folder
def
__init__
(
self
,
output_folder
):
self
.
output_folder
=
output_folder
def
get_output_folder
(
self
):
...
...
@@ -87,21 +81,21 @@ class GlancesHistory(object):
# Label
plt
.
title
(
"%s stats"
%
p
)
handles
=
[]
for
i
in
stats
.
get_plugin
(
p
).
get_items_history_list
():
handles
.
append
(
plt
.
Rectangle
((
0
,
0
),
1
,
1
,
fc
=
i
[
'color'
],
ec
=
i
[
'color'
],
linewidth
=
1
))
labels
=
[
i
[
'name'
]
for
i
in
stats
.
get_plugin
(
p
).
get_items_history_list
()]
plt
.
legend
(
handles
,
labels
,
loc
=
1
,
prop
=
{
'size'
:
9
})
plt
.
legend
(
handles
,
labels
,
loc
=
1
,
prop
=
{
'size'
:
9
})
formatter
=
dates
.
DateFormatter
(
'%H:%M:%S'
)
ax
.
xaxis
.
set_major_formatter
(
formatter
)
# ax.set_ylabel('%')
# Draw the stats
for
i
in
stats
.
get_plugin
(
p
).
get_items_history_list
():
ax
.
plot_date
(
h
[
'date'
],
h
[
i
[
'name'
]],
i
[
'color'
],
label
=
'%s'
%
i
[
'name'
],
ax
.
plot_date
(
h
[
'date'
],
h
[
i
[
'name'
]],
i
[
'color'
],
label
=
'%s'
%
i
[
'name'
],
xdate
=
True
,
ydate
=
False
)
# Save and display
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录