Skip to content

Commit 58d529f

Browse files
hkajtruthbk
authored andcommitted
[docker] fix net metrics in host mode (#3313)
1 parent a595b5e commit 58d529f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

utils/dockerutil.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,12 @@ def get_container_network_mapping(cls, container):
482482

483483
docker_gateways = {}
484484
for netname, netconf in container['NetworkSettings']['Networks'].iteritems():
485+
486+
if netname == 'host' or netconf.get(u'Gateway') == '':
487+
log.debug("Empty network gateway, container %s is in network host mode, "
488+
"its network metrics are for the whole host." % container['Id'][:12])
489+
return {'eth0': 'bridge'}
490+
485491
docker_gateways[netname] = struct.unpack('<L', socket.inet_aton(netconf.get(u'Gateway')))[0]
486492

487493
mapping = {}

0 commit comments

Comments
 (0)