Skip to content

Key Error: Online CPU's  #13

Description

@ninjakitteh69

Hi.
When running the script, I get the following Error message:
`Exception in thread worker-0:
Traceback (most recent call last):
File "./docker_check.py", line 51, in get_cpu_pct
online_cpus = stats['cpu_stats']['online_cpus']
KeyError: 'online_cpus'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib64/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/usr/lib64/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "./docker_check.py", line 98, in get_ct_metrics
cpu_pct = get_cpu_pct(stats)
File "./docker_check.py", line 54, in get_cpu_pct
for item in stats['cpu_stats']['percpu_usage']
KeyError: 'percpu_usage'
`
I tried printing out the stats array and see that online_cpu's does not exist as an object. heres the info I received in the stats array:

{'read': '2020-04-21T07:54:56.333536076Z', 'preread': '2020-04-21T07:54:55.33374394Z', 'pids_stats': {'current': 57}, 'blkio_stats': {'io_service_bytes_recursive': [{'major': 259, 'minor': 1, 'op': 'Read', 'value': 106120192}, {'major': 259, 'minor': 1, 'op': 'Write', 'value': 1006592}, {'major': 259, 'minor': 1, 'op': 'Sync', 'value': 1006592}, {'major': 259, 'minor': 1, 'op': 'Async', 'value': 106120192}, {'major': 259, 'minor': 1, 'op': 'Total', 'value': 107126784}], 'io_serviced_recursive': [{'major': 259, 'minor': 1, 'op': 'Read', 'value': 4194}, {'major': 259, 'minor': 1, 'op': 'Write', 'value': 150}, {'major': 259, 'minor': 1, 'op': 'Sync', 'value': 150}, {'major': 259, 'minor': 1, 'op': 'Async', 'value': 4194}, {'major': 259, 'minor': 1, 'op': 'Total', 'value': 4344}], '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': 121886265974, 'percpu_usage': [20679024994, 19793020434, 20161164268, 19731874702, 9364159767, 10402687577, 10354012984, 11400321248], 'usage_in_kernelmode': 18590000000, 'usage_in_usermode': 99040000000}, 'system_cpu_usage': 32568440000000, 'throttling_data': {'periods': 0, 'throttled_periods': 0, 'throttled_time': 0}}, 'precpu_stats': {'cpu_usage': {'total_usage': 121856939212, 'percpu_usage': [20678291651, 19791125917, 20160307167, 19710490568, 9363719958, 10402619352, 10350564513, 11399820086], 'usage_in_kernelmode': 18580000000, 'usage_in_usermode': 99020000000}, 'system_cpu_usage': 32560440000000, 'throttling_data': {'periods': 0, 'throttled_periods': 0, 'throttled_time': 0}}, 'memory_stats': {'usage': 337207296, 'max_usage': 338665472, 'stats': {'active_anon': 216981504, 'active_file': 28659712, 'cache': 119627776, 'hierarchical_memory_limit': 9223372036854771712, 'hierarchical_memsw_limit': 9223372036854771712, 'inactive_anon': 36864, 'inactive_file': 90931200, 'mapped_file': 19828736, 'pgfault': 2276291, 'pgmajfault': 344, 'pgpgin': 913112, 'pgpgout': 849839, 'rss': 216981504, 'rss_huge': 23068672, 'swap': 0, 'total_active_anon': 216981504, 'total_active_file': 28659712, 'total_cache': 119627776, 'total_inactive_anon': 36864, 'total_inactive_file': 90931200, 'total_mapped_file': 19828736, 'total_pgfault': 2276291, 'total_pgmajfault': 344, 'total_pgpgin': 913112, 'total_pgpgout': 849839, 'total_rss': 216981504, 'total_rss_huge': 23068672, 'total_swap': 0, 'total_unevictable': 0, 'unevictable': 0}, 'limit': 21344292864}, 'name': '/graphite', 'id': '81928a7459607a24314bb46b97c4b11841f789098ab8040b43e6a71d1961ca7e', 'networks': {'eth0': {'rx_bytes': 16878682, 'rx_packets': 47103, 'rx_errors': 0, 'rx_dropped': 0, 'tx_bytes': 28533655, 'tx_packets': 35619, 'tx_errors': 0, 'tx_dropped': 0}}}

I am using an Ec2 instance on aws to run the container and have installed docker via pip like in the docs. Please let me know if you require anymore info

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions