Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
蜕变的菜鸟
glances
提交
a7944969
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 搜索 >>
提交
a7944969
编写于
3月 31, 2018
作者:
N
nicolargo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add Pygal option in the configuration file
上级
368cfd56
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
71 addition
and
17 deletion
+71
-17
conf/glances.conf
conf/glances.conf
+11
-0
glances/exports/glances_graph.py
glances/exports/glances_graph.py
+34
-11
glances/plugins/glances_cpu.py
glances/plugins/glances_cpu.py
+0
-1
glances/plugins/glances_diskio.py
glances/plugins/glances_diskio.py
+0
-1
glances/plugins/glances_percpu.py
glances/plugins/glances_percpu.py
+10
-1
glances/plugins/glances_plugin.py
glances/plugins/glances_plugin.py
+1
-1
glances/plugins/glances_processcount.py
glances/plugins/glances_processcount.py
+15
-2
未找到文件。
conf/glances.conf
浏览文件 @
a7944969
...
...
@@ -315,6 +315,17 @@ all=False
# Exports
##############################################################################
[
graph
]
# Configuration for the --export graph option
# Set the path where the graph (.svg files) will be created
# Can be overwrite by the --graph-path command line option
path
=/
tmp
# See followings configuration keys definitions in the Pygal lib documentation
# http://pygal.org/en/stable/documentation/index.html
width
=
800
height
=
600
style
=
DarkStyle
[
influxdb
]
# Configuration for the --export influxdb option
# https://influxdb.com/
...
...
glances/exports/glances_graph.py
浏览文件 @
a7944969
...
...
@@ -20,7 +20,7 @@
"""Graph exporter interface class."""
from
pygal
import
DateTimeLine
from
pygal.style
import
DarkS
tyle
import
pygal.s
tyle
import
sys
import
os
import
tempfile
...
...
@@ -39,25 +39,37 @@ class Export(GlancesExport):
"""Init the export IF."""
super
(
Export
,
self
).
__init__
(
config
=
config
,
args
=
args
)
# Graph export folder path
self
.
_graph_path
=
args
.
export_graph_path
# Load the Graph configuration file section (is exists)
self
.
export_enable
=
self
.
load_conf
(
'graph'
,
options
=
[
'path'
,
'width'
,
'height'
,
'style'
])
# Manage options (command line arguments overwrite configuration file)
self
.
path
=
args
.
export_graph_path
or
self
.
path
self
.
width
=
int
(
getattr
(
self
,
'width'
,
800
))
self
.
height
=
int
(
getattr
(
self
,
'height'
,
600
))
self
.
style
=
getattr
(
pygal
.
style
,
getattr
(
self
,
'style'
,
'DarkStyle'
),
pygal
.
style
.
DarkStyle
)
# Create export folder
try
:
os
.
makedirs
(
self
.
_graph_
path
)
os
.
makedirs
(
self
.
path
)
except
OSError
as
e
:
if
e
.
errno
!=
errno
.
EEXIST
:
logger
.
critical
(
"Cannot create the Graph output folder {} ({})"
.
format
(
self
.
_graph_
path
,
e
))
logger
.
critical
(
"Cannot create the Graph output folder {} ({})"
.
format
(
self
.
path
,
e
))
sys
.
exit
(
2
)
# Check if output folder is writeable
try
:
tempfile
.
TemporaryFile
(
dir
=
self
.
_graph_
path
)
tempfile
.
TemporaryFile
(
dir
=
self
.
path
)
except
OSError
as
e
:
logger
.
critical
(
"Graph output folder {} is not writeable"
.
format
(
self
.
_graph_
path
))
logger
.
critical
(
"Graph output folder {} is not writeable"
.
format
(
self
.
path
))
sys
.
exit
(
2
)
logger
.
info
(
"Graphs will be created in the folder {}"
.
format
(
self
.
_graph_
path
))
logger
.
info
(
"Graphs will be created in the folder {}"
.
format
(
self
.
path
))
logger
.
info
(
"Graphs are created when 'g' key is pressed"
)
def
exit
(
self
):
...
...
@@ -75,7 +87,7 @@ class Export(GlancesExport):
if
plugin_name
in
self
.
plugins_to_export
():
self
.
export
(
plugin_name
,
plugin
.
get_export_history
())
logger
.
info
(
"Graphs created in the folder {}"
.
format
(
self
.
_graph_
path
))
logger
.
info
(
"Graphs created in the folder {}"
.
format
(
self
.
path
))
self
.
args
.
generate_graph
=
False
def
export
(
self
,
title
,
data
):
...
...
@@ -91,13 +103,24 @@ class Export(GlancesExport):
...
]
}
Return:
* True if the graph have been generated
* False if the graph have not been generated
"""
if
data
==
{}:
return
False
chart
=
DateTimeLine
(
title
=
title
.
capitalize
(),
style
=
DarkStyle
,
width
=
self
.
width
,
height
=
self
.
height
,
style
=
self
.
style
,
show_dots
=
False
,
legend_at_bottom
=
True
,
x_label_rotation
=
20
,
x_value_formatter
=
lambda
dt
:
dt
.
strftime
(
'%Y/%m/%d %H:%M:%S'
))
for
k
,
v
in
iteritems
(
data
):
chart
.
add
(
k
,
v
)
chart
.
render_to_file
(
os
.
path
.
join
(
self
.
_graph_
path
,
chart
.
render_to_file
(
os
.
path
.
join
(
self
.
path
,
title
+
'.svg'
))
return
True
glances/plugins/glances_cpu.py
浏览文件 @
a7944969
...
...
@@ -44,7 +44,6 @@ snmp_oid = {'default': {'user': '1.3.6.1.4.1.2021.11.9.0',
# Define the history items list
# - 'name' define the stat identifier
# - 'y_unit' define the Y label
# All items in this list will be historised if the --enable-history tag is set
items_history_list
=
[{
'name'
:
'user'
,
'description'
:
'User CPU usage'
,
'y_unit'
:
'%'
},
...
...
glances/plugins/glances_diskio.py
浏览文件 @
a7944969
...
...
@@ -27,7 +27,6 @@ import psutil
# Define the history items list
# All items in this list will be historised if the --enable-history tag is set
items_history_list
=
[{
'name'
:
'read_bytes'
,
'description'
:
'Bytes read per second'
,
'y_unit'
:
'B/s'
},
...
...
glances/plugins/glances_percpu.py
浏览文件 @
a7944969
...
...
@@ -22,6 +22,14 @@
from
glances.cpu_percent
import
cpu_percent
from
glances.plugins.glances_plugin
import
GlancesPlugin
# Define the history items list
items_history_list
=
[{
'name'
:
'user'
,
'description'
:
'User CPU usage'
,
'y_unit'
:
'%'
},
{
'name'
:
'system'
,
'description'
:
'System CPU usage'
,
'y_unit'
:
'%'
}]
class
Plugin
(
GlancesPlugin
):
"""Glances per-CPU plugin.
...
...
@@ -32,7 +40,8 @@ class Plugin(GlancesPlugin):
def
__init__
(
self
,
args
=
None
):
"""Init the plugin."""
super
(
Plugin
,
self
).
__init__
(
args
=
args
)
super
(
Plugin
,
self
).
__init__
(
args
=
args
,
items_history_list
=
items_history_list
)
# We want to display the stat in the curse interface
self
.
display_curse
=
True
...
...
glances/plugins/glances_plugin.py
浏览文件 @
a7944969
...
...
@@ -170,7 +170,7 @@ class GlancesPlugin(object):
# interface)
for
l
in
self
.
stats
:
self
.
stats_history
.
add
(
l
[
item_name
]
+
'_'
+
i
[
'name'
],
str
(
l
[
item_name
])
+
'_'
+
i
[
'name'
],
l
[
i
[
'name'
]],
description
=
i
[
'description'
],
history_max_size
=
self
.
_limits
[
'history_size'
])
...
...
glances/plugins/glances_processcount.py
浏览文件 @
a7944969
...
...
@@ -22,7 +22,19 @@
from
glances.processes
import
glances_processes
from
glances.plugins.glances_plugin
import
GlancesPlugin
# Note: history items list is not compliant with process count
# Define the history items list
items_history_list
=
[{
'name'
:
'total'
,
'description'
:
'Total number of processes'
,
'y_unit'
:
''
},
{
'name'
:
'running'
,
'description'
:
'Total number of running processes'
,
'y_unit'
:
''
},
{
'name'
:
'sleeping'
,
'description'
:
'Total number of sleeping processes'
,
'y_unit'
:
''
},
{
'name'
:
'thread'
,
'description'
:
'Total number of threads'
,
'y_unit'
:
''
}]
class
Plugin
(
GlancesPlugin
):
...
...
@@ -33,7 +45,8 @@ class Plugin(GlancesPlugin):
def
__init__
(
self
,
args
=
None
):
"""Init the plugin."""
super
(
Plugin
,
self
).
__init__
(
args
=
args
)
super
(
Plugin
,
self
).
__init__
(
args
=
args
,
items_history_list
=
items_history_list
)
# We want to display the stat in the curse interface
self
.
display_curse
=
True
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录