Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
蜕变的菜鸟
glances
提交
58f03687
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 搜索 >>
提交
58f03687
编写于
3月 10, 2015
作者:
N
nicolargo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Hide Rx/Tx net interface for the Docker plugin. Not work has expected
上级
ddc2e88e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
34 addition
and
26 deletion
+34
-26
glances/plugins/glances_docker.py
glances/plugins/glances_docker.py
+34
-26
未找到文件。
glances/plugins/glances_docker.py
浏览文件 @
58f03687
...
...
@@ -161,8 +161,9 @@ class Plugin(GlancesPlugin):
# Create the stats instance for the current container
try
:
self
.
docker_stats
[
c
[
'Id'
]]
=
self
.
docker_client
.
stats
(
c
[
'Id'
],
decode
=
True
)
logger
.
debug
(
"Create Docker stats object for container {}"
.
format
(
c
[
'Id'
]))
except
AttributeError
as
e
:
logger
.
debug
(
"Can not call Docker stats method {}"
.
format
(
e
))
logger
.
error
(
"Can not call Docker stats method {}"
.
format
(
e
))
# Get the docker stats
try
:
...
...
@@ -170,9 +171,6 @@ class Plugin(GlancesPlugin):
except
:
all_stats
=
{}
# !!! DEBUG
# logger.info(all_stats)
c
[
'cpu'
]
=
self
.
get_docker_cpu
(
c
[
'Id'
],
all_stats
)
c
[
'memory'
]
=
self
.
get_docker_memory
(
c
[
'Id'
],
all_stats
)
# c['network'] = self.get_docker_network(c['Id'], all_stats)
...
...
@@ -210,14 +208,19 @@ class Plugin(GlancesPlugin):
all_stats is the output of the stats method of the Docker API
Output: a dict {'total': 1.49}"""
ret
=
{}
# Read the stats
try
:
ret
[
'total'
]
=
all_stats
[
'cpu_stats'
][
'total_usage'
]
except
KeyError
as
e
:
# all_stats do not have CPU information
logger
.
debug
(
"Can not grab CPU usage for container {0} ({1})"
.
format
(
container_id
,
e
))
# Trying fallback to old grab method
ret
=
self
.
get_docker_cpu_old
(
container_id
)
# try:
# ret['total'] = all_stats['cpu_stats']['cpu_usage']['total_usage']
# except KeyError as e:
# # all_stats do not have CPU information
# logger.error("Can not grab CPU usage for container {0} ({1})".format(container_id, e))
# # Trying fallback to old grab method
# ret = self.get_docker_cpu_old(container_id)
# Did not work has expected, replace by the old method...
ret
=
self
.
get_docker_cpu_old
(
container_id
)
# Get the user ticks
ticks
=
self
.
get_user_ticks
()
for
k
in
ret
.
keys
():
...
...
@@ -247,15 +250,17 @@ class Plugin(GlancesPlugin):
"""Return the container MEMORY
Input: id is the full container id
all_stats is the output of the stats method of the Docker API
Output: a dict {'rss': 1015808, 'cache': 356352}"""
Output: a dict {'rss': 1015808, 'cache': 356352
, 'usage': ..., 'max_usage': ...
}"""
ret
=
{}
# Read the stats
try
:
ret
[
'rss'
]
=
all_stats
[
'memory_stats'
][
'stats'
][
'rss'
]
ret
[
'cache'
]
=
all_stats
[
'memory_stats'
][
'stats'
][
'cache'
]
ret
[
'usage'
]
=
all_stats
[
'memory_stats'
][
'usage'
]
ret
[
'max_usage'
]
=
all_stats
[
'memory_stats'
][
'max_usage'
]
except
KeyError
as
e
:
# all_stats do not have MEM information
logger
.
debug
(
"Can not grab MEM usage for container {0} ({1})"
.
format
(
container_id
,
e
))
logger
.
error
(
"Can not grab MEM usage for container {0} ({1})"
.
format
(
container_id
,
e
))
# Trying fallback to old grab method
ret
=
self
.
get_docker_memory_old
(
container_id
)
# Return the stats
...
...
@@ -286,7 +291,8 @@ class Plugin(GlancesPlugin):
self
.
netiocounters_old
[
container_id
]
=
netiocounters
except
(
IOError
,
UnboundLocalError
):
pass
elif
container_id
not
in
self
.
netiocounters_old
:
if
container_id
not
in
self
.
netiocounters_old
:
try
:
self
.
netiocounters_old
[
container_id
]
=
netiocounters
except
(
IOError
,
UnboundLocalError
):
...
...
@@ -298,6 +304,8 @@ class Plugin(GlancesPlugin):
network_new
[
'time_since_update'
]
=
getTimeSinceLastUpdate
(
'docker_net'
)
network_new
[
'rx'
]
=
netiocounters
[
"rx_bytes"
]
-
self
.
netiocounters_old
[
container_id
][
"rx_bytes"
]
network_new
[
'tx'
]
=
netiocounters
[
"tx_bytes"
]
-
self
.
netiocounters_old
[
container_id
][
"tx_bytes"
]
network_new
[
'cumulative_rx'
]
=
netiocounters
[
"rx_bytes"
]
network_new
[
'cumulative_tx'
]
=
netiocounters
[
"tx_bytes"
]
# Save stats to compute next bitrate
self
.
netiocounters_old
[
container_id
]
=
netiocounters
...
...
@@ -340,10 +348,10 @@ class Plugin(GlancesPlugin):
ret
.
append
(
self
.
curse_add_line
(
msg
))
msg
=
'{0:>7}'
.
format
(
_
(
"MEM"
))
ret
.
append
(
self
.
curse_add_line
(
msg
))
msg
=
'{0:>6}'
.
format
(
_
(
"Rx/s"
))
ret
.
append
(
self
.
curse_add_line
(
msg
))
msg
=
'{0:>6}'
.
format
(
_
(
"Tx/s"
))
ret
.
append
(
self
.
curse_add_line
(
msg
))
#
msg = '{0:>6}'.format(_("Rx/s"))
#
ret.append(self.curse_add_line(msg))
#
msg = '{0:>6}'.format(_("Tx/s"))
#
ret.append(self.curse_add_line(msg))
msg
=
' {0:8}'
.
format
(
_
(
"Command"
))
ret
.
append
(
self
.
curse_add_line
(
msg
))
# Data
...
...
@@ -373,18 +381,18 @@ class Plugin(GlancesPlugin):
ret
.
append
(
self
.
curse_add_line
(
msg
))
# MEM
try
:
msg
=
'{0:>7}'
.
format
(
self
.
auto_unit
(
container
[
'memory'
][
'
rss
'
]))
msg
=
'{0:>7}'
.
format
(
self
.
auto_unit
(
container
[
'memory'
][
'
usage
'
]))
except
KeyError
:
msg
=
'{0:>7}'
.
format
(
'?'
)
ret
.
append
(
self
.
curse_add_line
(
msg
))
# NET RX/TX
for
r
in
[
'rx'
,
'tx'
]:
try
:
value
=
self
.
auto_unit
(
int
(
container
[
'network'
][
r
]
//
container
[
'network'
][
'time_since_update'
]
*
8
))
+
"b"
msg
=
'{0:>6}'
.
format
(
value
)
except
KeyError
:
msg
=
'{0:>6}'
.
format
(
'?'
)
ret
.
append
(
self
.
curse_add_line
(
msg
))
#
for r in ['rx', 'tx']:
#
try:
#
value = self.auto_unit(int(container['network'][r] // container['network']['time_since_update'] * 8)) + "b"
#
msg = '{0:>6}'.format(value)
#
except KeyError:
#
msg = '{0:>6}'.format('?')
#
ret.append(self.curse_add_line(msg))
# Command
msg
=
' {0}'
.
format
(
container
[
'Command'
])
ret
.
append
(
self
.
curse_add_line
(
msg
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录