docker container.stats(stream=False) not found networks key-value in centos
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.2k
- Forks
- 1.7k
- Avg merge
- 13d 8h
- Merged PRs (30d)
- 2
Description
I found i cannot find networks key-value in docker client stats
docker sdk for python =
docker==4.1.0
centos7.5
centos version
# lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 7.5.1804 (Core)
Release: 7.5.1804
Codename: Core
centos docker version
# docker version
Client:
Version: 17.12.1-ce
API version: 1.35
Go version: go1.9.4
Git commit: 7390fc6
Built: Tue Feb 27 22:15:20 2018
OS/Arch: linux/amd64
Server:
Engine:
Version: 17.12.1-ce
API version: 1.35 (minimum version 1.12)
Go version: go1.9.4
Git commit: 7390fc6
Built: Tue Feb 27 22:17:54 2018
OS/Arch: linux/amd64
Experimental: false
python code
docker sdk for python
import docker
client = docker.from_env()
stats = container.stats(stream=False)
print(stats)
print(str(list(stats['networks'].values())[0]['rx_bytes']))
stdout
{'read': '2020-03-30T13:22:01.786097801Z', 'preread': '2020-03-30T13:22:00.786132317Z',
'pids_stats': {'current': 10}, 'blkio_stats': {'io_service_bytes_recursive': [], 'io_serviced_recursive': [],
'io_queue_recursive': [], 'io_service_time_recursive': [], 'io_wait_time_recursive': [],
'io_merged_recursive': [], 'io_time_recursive': [], 'sectors_recursive': []}, 'num_procs': 0, 'storage_stats':
{}, 'cpu_stats': {'cpu_usage': {'total_usage': 1364516186, 'percpu_usage': [65757133, 62557842,
66162812, 382085241, 167700841, 436523454, 119855237, 63873626], 'usage_in_kernelmode':
400000000, 'usage_in_usermode': 850000000}, 'system_cpu_usage': 2370139470000000,
'online_cpus': 8, 'throttling_data': {'periods': 0, 'throttled_periods': 0, 'throttled_time': 0}},
'precpu_stats': {'cpu_usage': {'total_usage': 1364424315, 'percpu_usage': [65665262, 62557842,
66162812, 382085241, 167700841, 436523454, 119855237, 63873626], 'usage_in_kernelmode':
400000000, 'usage_in_usermode': 850000000}, 'system_cpu_usage': 2370131490000000,
'online_cpus': 8, 'throttling_data': {'periods': 0, 'throttled_periods': 0, 'throttled_time': 0}},
'memory_stats': {'usage': 75448320, 'max_usage': 76050432, 'stats': {'active_anon': 75448320,
'active_file': 0, 'cache': 0, 'dirty': 0, 'hierarchical_memory_limit': 9223372036854771712,
'hierarchical_memsw_limit': 9223372036854771712, 'inactive_anon': 0, 'inactive_file': 0, 'mapped_file':
0, 'pgfault': 28619, 'pgmajfault': 0, 'pgpgin': 20295, 'pgpgout': 8518, 'rss': 75448320, 'rss_huge':
27262976, 'total_active_anon': 75448320, 'total_active_file': 0, 'total_cache': 0, 'total_dirty': 0,
'total_inactive_anon': 0, 'total_inactive_file': 0, 'total_mapped_file': 0, 'total_pgfault': 28619,
'total_pgmajfault': 0, 'total_pgpgin': 20295, 'total_pgpgout': 8518, 'total_rss': 75448320,
'total_rss_huge': 27262976, 'total_unevictable': 0, 'total_writeback': 0, 'unevictable': 0, 'writeback': 0},
'limit': 66312925184}, 'name': '/xxxx', 'id':
'xxxx'}
ERROR:collect_data:'networks'
But When I run it in ubuntu
ubuntu18.04
ubuntu version
# lsb_release -a
LSB Version: core-9.20170808ubuntu1-noarch:security-9.20170808ubuntu1-noarch
Distributor ID: Ubuntu
Description: Ubuntu 18.04.3 LTS
Release: 18.04
Codename: bionic
ubuntu docker version
# docker version
Client:
Version: 18.09.7
API version: 1.39
Go version: go1.10.1
Git commit: 2d0083d
Built: Fri Aug 16 14:20:06 2019
OS/Arch: linux/amd64
Experimental: false
Server:
Engine:
Version: 18.09.7
API version: 1.39 (minimum version 1.12)
Go version: go1.10.1
Git commit: 2d0083d
Built: Wed Aug 14 19:41:23 2019
OS/Arch: linux/amd64
Experimental: false
python code
docker sdk for python
import docker
client = docker.from_env()
stats = container.stats(stream=False)
print(stats)
print(str(list(stats['networks'].values())[0]['rx_bytes']))
stdout
{'read': '2020-03-30T13:07:01.094199037Z', 'preread': '2020-03-30T13:07:00.093103158Z',
'pids_stats': {'current': 7}, 'blkio_stats': {'io_service_bytes_recursive': [{'major': 252, 'minor': 0, 'op':
'Read', 'value': 0}, {'major': 252, 'minor': 0, 'op': 'Write', 'value': 385507328}, {'major': 252, 'minor': 0,
'op': 'Sync', 'value': 241664}, {'major': 252, 'minor': 0, 'op': 'Async', 'value': 385265664}, {'major': 252,
'minor': 0, 'op': 'Total', 'value': 385507328}], 'io_serviced_recursive': [{'major': 252, 'minor': 0, 'op':
'Read', 'value': 0}, {'major': 252, 'minor': 0, 'op': 'Write', 'value': 11678}, {'major': 252, 'minor': 0, 'op':
'Sync', 'value': 1334}, {'major': 252, 'minor': 0, 'op': 'Async', 'value': 10344}, {'major': 252, 'minor': 0,
'op': 'Total', 'value': 11678}], 'io_queue_recursive': [], 'io_service_time_recursive': [],
'io_wait_time_recursive': [], 'io_merged_recursive': [], 'io_time_recursive': [], 'sectors_recursive': []},
'num_procs': 0, 'storage_stats': {}, 'cpu_stats': {'cpu_usage': {'total_usage': 9756934763,
'percpu_usage': [666952634, 478812429, 671823468, 485544816, 614203641, 552001733,
581142364, 532484924, 575376052, 553035730, 577174864, 534464066, 666433643, 896704712,
649666882, 721112805], 'usage_in_kernelmode': 5720000000, 'usage_in_usermode': 3040000000},
'system_cpu_usage': 135329085230000000, 'online_cpus': 16, 'throttling_data': {'periods': 0,
'throttled_periods': 0, 'throttled_time': 0}}, 'precpu_stats': {'cpu_usage': {'total_usage': 9756934763,
'percpu_usage': [666952634, 478812429, 671823468, 485544816, 614203641, 552001733,
581142364, 532484924, 575376052, 553035730, 577174864, 534464066, 666433643, 896704712,
649666882, 721112805], 'usage_in_kernelmode': 5720000000, 'usage_in_usermode': 3040000000},
'system_cpu_usage': 135329069510000000, 'online_cpus': 16, 'throttling_data': {'periods': 0,
'throttled_periods': 0, 'throttled_time': 0}}, 'memory_stats': {'usage': 80257024, 'max_usage':
82989056, 'stats': {'active_anon': 6430720, 'active_file': 9003008, 'cache': 62849024, 'dirty': 0,
'hierarchical_memory_limit': 9223372036854771712, 'hierarchical_memsw_limit': 0, 'inactive_anon':
9228288, 'inactive_file': 41926656, 'mapped_file': 11341824, 'pgfault': 1095805, 'pgmajfault': 0,
'pgpgin': 635702, 'pgpgout': 619445, 'rss': 3739648, 'rss_huge': 0, 'total_active_anon': 6430720,
'total_active_file': 9003008, 'total_cache': 62849024, 'total_dirty': 0, 'total_inactive_anon': 9228288,
'total_inactive_file': 41926656, 'total_mapped_file': 11341824, 'total_pgfault': 1095805,
'total_pgmajfault': 0, 'total_pgpgin': 635702, 'total_pgpgout': 619445, 'total_rss': 3739648,
'total_rss_huge': 0, 'total_unevictable': 0, 'total_writeback': 0, 'unevictable': 0, 'writeback': 0}, 'limit':
65419714560}, 'name': '/xxxx', 'id':
'xxxx', 'networks': {'eth0':
{'rx_bytes': 4950, 'rx_packets': 115, 'rx_errors': 0, 'rx_dropped': 0, 'tx_bytes': 0, 'tx_packets': 0,
'tx_errors': 0, 'tx_dropped': 0}}}
4950
Is it because the docker SDK for python 4.1.0 on centos7.5 and docker 17.12 does not support getting the networks parameter?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing container.stats(stream=False) against the CentOS Docker Engine 17.12.1 and the Ubuntu Docker Engine 18.09.7, comparing the returned dictionaries. Read the Docker Engine stats API behavior for these versions and determine whether the missing networks field is expected. Done means the version-dependent behavior is explained and the issue is resolved with a documented limitation or appropriate SDK change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, python
- Domain
- api, devops
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100