Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
蜕变的菜鸟
glances
提交
396f3acf
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,发现更多精彩内容 >>
提交
396f3acf
编写于
5月 28, 2016
作者:
N
nicolargo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add new attribute class. Only for history for the moment
上级
42d45c29
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
80 addition
and
33 deletion
+80
-33
glances/exports/glances_history.py
glances/exports/glances_history.py
+7
-4
glances/plugins/glances_cpu.py
glances/plugins/glances_cpu.py
+8
-2
glances/plugins/glances_diskio.py
glances/plugins/glances_diskio.py
+8
-2
glances/plugins/glances_fs.py
glances/plugins/glances_fs.py
+3
-1
glances/plugins/glances_load.py
glances/plugins/glances_load.py
+9
-3
glances/plugins/glances_mem.py
glances/plugins/glances_mem.py
+4
-1
glances/plugins/glances_memswap.py
glances/plugins/glances_memswap.py
+4
-1
glances/plugins/glances_network.py
glances/plugins/glances_network.py
+8
-2
glances/plugins/glances_plugin.py
glances/plugins/glances_plugin.py
+29
-17
未找到文件。
glances/exports/glances_history.py
浏览文件 @
396f3acf
...
...
@@ -71,7 +71,7 @@ class GlancesHistory(object):
def
get_graph_legend
(
self
,
item
):
"""Get the item's legend."""
return
item
[
'
name
'
]
return
item
[
'
description
'
]
def
get_graph_yunit
(
self
,
item
,
pre_label
=
''
):
"""Get the item's Y unit."""
...
...
@@ -95,9 +95,12 @@ class GlancesHistory(object):
index_all
=
0
for
p
in
stats
.
getAllPlugins
():
# History
h
=
stats
.
get_plugin
(
p
).
get_stats_history
()
# Data
if
h
is
None
:
# Current plugin item history list
ih
=
stats
.
get_plugin
(
p
).
get_items_history_list
()
# Check if we must process history
if
h
is
None
or
ih
is
None
:
# History (h) not available for plugin (p)
continue
# Init graph
...
...
@@ -105,7 +108,7 @@ class GlancesHistory(object):
index_graph
=
0
handles
=
[]
labels
=
[]
for
i
in
stats
.
get_plugin
(
p
).
get_items_history_list
()
:
for
i
in
ih
:
if
i
[
'name'
]
in
iterkeys
(
h
):
# The key exist
# Add the curves in the current chart
...
...
glances/plugins/glances_cpu.py
浏览文件 @
396f3acf
...
...
@@ -46,8 +46,14 @@ snmp_oid = {'default': {'user': '1.3.6.1.4.1.2021.11.9.0',
# - 'color' define the graph color in #RGB format
# - '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'
,
'color'
:
'#00FF00'
,
'y_unit'
:
'%'
},
{
'name'
:
'system'
,
'color'
:
'#FF0000'
,
'y_unit'
:
'%'
}]
items_history_list
=
[{
'name'
:
'user'
,
'description'
:
'User CPU usage'
,
'color'
:
'#00FF00'
,
'y_unit'
:
'%'
},
{
'name'
:
'system'
,
'description'
:
'System CPU usage'
,
'color'
:
'#FF0000'
,
'y_unit'
:
'%'
}]
class
Plugin
(
GlancesPlugin
):
...
...
glances/plugins/glances_diskio.py
浏览文件 @
396f3acf
...
...
@@ -30,8 +30,14 @@ import psutil
# Define the history items list
# All items in this list will be historised if the --enable-history tag is set
# 'color' define the graph color in #RGB format
items_history_list
=
[{
'name'
:
'read_bytes'
,
'color'
:
'#00FF00'
,
'y_unit'
:
'B/s'
},
{
'name'
:
'write_bytes'
,
'color'
:
'#FF0000'
,
'y_unit'
:
'B/s'
}]
items_history_list
=
[{
'name'
:
'read_bytes'
,
'description'
:
'Bytes read per second'
,
'color'
:
'#00FF00'
,
'y_unit'
:
'B/s'
},
{
'name'
:
'write_bytes'
,
'description'
:
'Bytes write per second'
,
'color'
:
'#FF0000'
,
'y_unit'
:
'B/s'
}]
class
Plugin
(
GlancesPlugin
):
...
...
glances/plugins/glances_fs.py
浏览文件 @
396f3acf
...
...
@@ -59,7 +59,9 @@ snmp_oid['esxi'] = snmp_oid['windows']
# Define the history items list
# All items in this list will be historised if the --enable-history tag is set
# 'color' define the graph color in #RGB format
items_history_list
=
[{
'name'
:
'percent'
,
'color'
:
'#00FF00'
}]
items_history_list
=
[{
'name'
:
'percent'
,
'description'
:
'File system usage in percent'
,
'color'
:
'#00FF00'
}]
class
Plugin
(
GlancesPlugin
):
...
...
glances/plugins/glances_load.py
浏览文件 @
396f3acf
...
...
@@ -36,9 +36,15 @@ snmp_oid = {'min1': '1.3.6.1.4.1.2021.10.1.3.1',
# Define the history items list
# All items in this list will be historised if the --enable-history tag is set
# 'color' define the graph color in #RGB format
items_history_list
=
[{
'name'
:
'min1'
,
'color'
:
'#0000FF'
},
{
'name'
:
'min5'
,
'color'
:
'#0000AA'
},
{
'name'
:
'min15'
,
'color'
:
'#000044'
}]
items_history_list
=
[{
'name'
:
'min1'
,
'description'
:
'1 minute load'
,
'color'
:
'#0000FF'
},
{
'name'
:
'min5'
,
'description'
:
'5 minutes load'
,
'color'
:
'#0000AA'
},
{
'name'
:
'min15'
,
'description'
:
'15 minutes load'
,
'color'
:
'#000044'
}]
class
Plugin
(
GlancesPlugin
):
...
...
glances/plugins/glances_mem.py
浏览文件 @
396f3acf
...
...
@@ -49,7 +49,10 @@ snmp_oid = {'default': {'total': '1.3.6.1.4.1.2021.4.5.0',
# Define the history items list
# All items in this list will be historised if the --enable-history tag is set
# 'color' define the graph color in #RGB format
items_history_list
=
[{
'name'
:
'percent'
,
'color'
:
'#00FF00'
,
'y_unit'
:
'%'
}]
items_history_list
=
[{
'name'
:
'percent'
,
'description'
:
'RAM memory usage'
,
'color'
:
'#00FF00'
,
'y_unit'
:
'%'
}]
class
Plugin
(
GlancesPlugin
):
...
...
glances/plugins/glances_memswap.py
浏览文件 @
396f3acf
...
...
@@ -37,7 +37,10 @@ snmp_oid = {'default': {'total': '1.3.6.1.4.1.2021.4.3.0',
# Define the history items list
# All items in this list will be historised if the --enable-history tag is set
# 'color' define the graph color in #RGB format
items_history_list
=
[{
'name'
:
'percent'
,
'color'
:
'#00FF00'
,
'y_unit'
:
'%'
}]
items_history_list
=
[{
'name'
:
'percent'
,
'description'
:
'Swap memory usage'
,
'color'
:
'#00FF00'
,
'y_unit'
:
'%'
}]
class
Plugin
(
GlancesPlugin
):
...
...
glances/plugins/glances_network.py
浏览文件 @
396f3acf
...
...
@@ -37,8 +37,14 @@ snmp_oid = {'default': {'interface_name': '1.3.6.1.2.1.2.2.1.2',
# Define the history items list
# All items in this list will be historised if the --enable-history tag is set
# 'color' define the graph color in #RGB format
items_history_list
=
[{
'name'
:
'rx'
,
'color'
:
'#00FF00'
,
'y_unit'
:
'bit/s'
},
{
'name'
:
'tx'
,
'color'
:
'#FF0000'
,
'y_unit'
:
'bit/s'
}]
items_history_list
=
[{
'name'
:
'rx'
,
'description'
:
'Download rate per second'
,
'color'
:
'#00FF00'
,
'y_unit'
:
'bit/s'
},
{
'name'
:
'tx'
,
'description'
:
'Upload rate per second'
,
'color'
:
'#FF0000'
,
'y_unit'
:
'bit/s'
}]
class
Plugin
(
GlancesPlugin
):
...
...
glances/plugins/glances_plugin.py
浏览文件 @
396f3acf
...
...
@@ -30,6 +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.logger
import
logger
from
glances.logs
import
glances_logs
...
...
@@ -86,34 +87,39 @@ class GlancesPlugin(object):
"""Return the key of the list."""
return
None
def
add_item_history
(
self
,
key
,
value
):
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."""
try
:
self
.
stats_history
[
key
].
append
(
value
)
except
KeyError
:
self
.
stats_history
[
key
]
=
[
value
]
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
list
)."""
ret
=
None
"""Init the stats history (dict of
GlancesAttribute
)."""
ret
=
{}
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
()]
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
))
ret
=
{}
return
ret
def
reset_stats_history
(
self
):
"""Reset the stats history (dict of
list
)."""
"""Reset the stats history (dict of
GlancesAttribute
)."""
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
()]
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
))
self
.
stats_history
=
{}
for
a
in
self
.
stats_history
:
self
.
stats_history
[
a
].
history_reset
()
def
update_stats_history
(
self
,
item_name
=
''
):
"""Update stats history."""
if
(
self
.
stats
and
self
.
args
is
not
None
and
self
.
args
.
enable_history
and
self
.
get_items_history_list
()
is
not
None
):
# TODO in attribute ?
self
.
add_item_history
(
'date'
,
datetime
.
now
())
for
i
in
self
.
get_items_history_list
():
if
isinstance
(
self
.
stats
,
list
):
...
...
@@ -122,18 +128,24 @@ class GlancesPlugin(object):
# interface)
for
l
in
self
.
stats
:
self
.
add_item_history
(
l
[
item_name
]
+
'_'
+
i
[
'name'
],
l
[
i
[
'name'
]])
l
[
item_name
]
+
'_'
+
i
[
'name'
],
l
[
i
[
'name'
]],
description
=
i
[
'description'
],
history_max_size
=
None
)
else
:
# Stats is not a list
# Add the item to the history directly
self
.
add_item_history
(
i
[
'name'
],
self
.
stats
[
i
[
'name'
]])
self
.
add_item_history
(
i
[
'name'
],
self
.
stats
[
i
[
'name'
]],
description
=
i
[
'description'
],
history_max_size
=
None
)
def
get_stats_history
(
self
):
"""Return the stats history."""
return
self
.
stats_history
"""Return the stats history
(dict of list)
."""
return
{
i
:
self
.
stats_history
[
i
].
history
for
i
in
self
.
stats_history
}
def
get_items_history_list
(
self
):
"""Return the items history list."""
"""Return the items history list
(define inside the plugins scripts)
."""
return
self
.
items_history_list
@
property
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录