Skip to content

Instantly share code, notes, and snippets.

@bsmile
Last active August 29, 2015 14:15
Show Gist options
  • Save bsmile/987dfb2e1a6e0dd66c77 to your computer and use it in GitHub Desktop.
Save bsmile/987dfb2e1a6e0dd66c77 to your computer and use it in GitHub Desktop.
docker1.5の新機能[stats]を使用して、外部からリソース状況を拾ってみる。 ref: http://qiita.com/_BSmile_/items/0a02d28911f77898bf89
# Modify these options if you want to change the way the docker daemon runs
# OPTIONS=--selinux-enabled -H fd://
OPTIONS=--selinux-enabled -H fd:// -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock
# Location used for temporary files, such as those created by
# docker load and build operations. Default is /var/lib/docker/tmp
# Can be overriden by setting the following environment variable.
# DOCKER_TMPDIR=/var/tmp
# docker stats cadvisor
CONTAINER CPU % MEM USAGE/LIMIT MEM % NET I/O
cadvisor 1.66% 25.3 MiB/3.704 GiB 0.67% 11.23 MiB/27.22 MiB
# systemctl restart docker.service
# firewall-cmd --add-port=2375/tcp
$ curl -X GET http://127.0.0.1:2375/containers/[container id]/stats
$ curl -X GET http://127.0.0.1:2375/containers/[container id]/stats --max-time 1 | jq '.cpu_stats'
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1961 0 1961 0 0 1210 0 --:--:-- 0:00:01 --:--:-- 1210
curl: (28) Operation timed out after 1620 milliseconds with 1961 out of -1 bytes received
{
"throttling_data": {
"throttled_time": 0,
"throttled_periods": 0,
"periods": 0
},
"system_cpu_usage": 1.01798489e+15,
"cpu_usage": {
"usage_in_usermode": 1.0411e+11,
"usage_in_kernelmode": 5.916e+10,
"percpu_usage": [
99302252799,
101617606123
],
"total_usage": 200919858922
}
}
# curl -s -X GET http://127.0.0.1:2375/containers/[container id]/stats --max-time 1 | jq '.cpu_stats'
{
"throttling_data": {
"throttled_time": 0,
"throttled_periods": 0,
"periods": 0
},
"system_cpu_usage": 2.03790306e+15,
"cpu_usage": {
"usage_in_usermode": 5.0961e+11,
"usage_in_kernelmode": 3.5196e+11,
"percpu_usage": [
445562955080,
439404240147
],
"total_usage": 884967195227
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment