Docker统计,JSON方式
docker-stats的Python项目详细描述
Docker统计
docker stats wrapper,它用json打印输出
用法
从pypi安装并运行
usage: docker-stats [-h] [-a] [container [container ...]] docker stats, json way positional arguments: container IDs or NAMEs of desired containers optional arguments: -h, --help show this help message and exit -a, --all get stats of all available containers -n, --normalize try to normalize stats
标准化
Docker统计的原始输出如下:
{"my_container":{"blkio_stats":{"io_merged_recursive":[],"io_queue_recursive":[],"io_service_bytes_recursive":[{"major":253,"minor":5,"op":"Read","value":7020544},{"major":253,"minor":5,"op":"Write","value":0},*SNIP*]}}}
正如我们可以提到的,在键io_service_bytes_recursive
内有一个数组对象,并且该数组的每个元素都是在值内用键op
展开的json。这种行为可能发生在其他钥匙上。
用键--normalize
调用的docker stats尝试将其jsonify为:
{"my_container":{"blkio_stats":{"io_merged_recursive":[],"io_queue_recursive":[],"io_service_bytes_recursive":{"Read":{"major":253,"minor":5,"value":7020544},"Write":{"major":253,"minor":5,"value":0},*SNIP*}}}}