Skip to content

Commit

Permalink
[docker] fix net metrics in host mode (#3313)
Browse files Browse the repository at this point in the history
  • Loading branch information
hkaj authored and truthbk committed Apr 20, 2017
1 parent a595b5e commit 58d529f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions utils/dockerutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,12 @@ def get_container_network_mapping(cls, container):

docker_gateways = {}
for netname, netconf in container['NetworkSettings']['Networks'].iteritems():

if netname == 'host' or netconf.get(u'Gateway') == '':
log.debug("Empty network gateway, container %s is in network host mode, "
"its network metrics are for the whole host." % container['Id'][:12])
return {'eth0': 'bridge'}

docker_gateways[netname] = struct.unpack('<L', socket.inet_aton(netconf.get(u'Gateway')))[0]

mapping = {}
Expand Down

0 comments on commit 58d529f

Please sign in to comment.