I have installed Docker in CentOS 7.0 bare metal. I have instantiated 2 Ubuntu containers. What I need to do is monitor the CPU, memory utilization ( amongst others) and spin off a new container if certain threshold is crossed ( e.g. more than 60% CPU util). I want to know if there is any automated way of doing this or even manualy how do I do this ?
[root@localhost system.slice]# pwd
/sys/fs/cgroup/cpu/system.slice
Under the above ditrectory, I see 3 files - there are 2 docker files with container ID and one docker.service. Would the resource utilized be populated real time in the files like cpuacct.usage under it’s docker container file and will the cpuacct.usage under docker.service tell me the cumulative cpu uage for all containers ?
[root@localhost system.slice]# ls -al docker*
docker-c778c39b6d69369190fb4376afb9a2bf30abca2ce9a8718b53bb38c0fe487af8.scope:
total 0
drwxr-xr-x. 2 root root 0 Nov 5 17:20 .
drwxr-xr-x. 102 root root 0 Nov 6 12:31 ..
-rw-r--r--. 1 root root 0 Nov 5 17:20 cgroup.clone_children
--w--w--w-. 1 root root 0 Nov 5 17:20 cgroup.event_control
-rw-r--r--. 1 root root 0 Nov 5 17:20 cgroup.procs
-r--r--r--. 1 root root 0 Nov 5 17:20 cpuacct.stat
-rw-r--r--. 1 root root 0 Nov 5 17:20 cpuacct.usage
-r--r--r--. 1 root root 0 Nov 5 17:20 cpuacct.usage_percpu
-rw-r--r--. 1 root root 0 Nov 5 17:20 cpu.cfs_period_us
-rw-r--r--. 1 root root 0 Nov 5 17:20 cpu.cfs_quota_us
-rw-r--r--. 1 root root 0 Nov 5 17:20 cpu.rt_period_us
-rw-r--r--. 1 root root 0 Nov 5 17:20 cpu.rt_runtime_us
-rw-r--r--. 1 root root 0 Nov 6 12:26 cpu.shares
-r--r--r--. 1 root root 0 Nov 5 17:20 cpu.stat
-rw-r--r--. 1 root root 0 Nov 5 17:20 notify_on_release
-rw-r--r--. 1 root root 0 Nov 5 17:20 tasks
docker-f9f30d08ddb4f5e7e847e3afeb3b9e3bf3a6ef540fa052e0e820022c8966e906.scope:
total 0
drwxr-xr-x. 2 root root 0 Nov 5 17:20 .
drwxr-xr-x. 102 root root 0 Nov 6 12:31 ..
-rw-r--r--. 1 root root 0 Nov 5 17:20 cgroup.clone_children
--w--w--w-. 1 root root 0 Nov 5 17:20 cgroup.event_control
-rw-r--r--. 1 root root 0 Nov 5 17:20 cgroup.procs
-r--r--r--. 1 root root 0 Nov 5 17:20 cpuacct.stat
-rw-r--r--. 1 root root 0 Nov 5 17:20 cpuacct.usage
-r--r--r--. 1 root root 0 Nov 5 17:20 cpuacct.usage_percpu
-rw-r--r--. 1 root root 0 Nov 5 17:20 cpu.cfs_period_us
-rw-r--r--. 1 root root 0 Nov 5 17:20 cpu.cfs_quota_us
-rw-r--r--. 1 root root 0 Nov 5 17:20 cpu.rt_period_us
-rw-r--r--. 1 root root 0 Nov 5 17:20 cpu.rt_runtime_us
-rw-r--r--. 1 root root 0 Nov 6 12:26 cpu.shares
-r--r--r--. 1 root root 0 Nov 5 17:20 cpu.stat
-rw-r--r--. 1 root root 0 Nov 5 17:20 notify_on_release
-rw-r--r--. 1 root root 0 Nov 5 17:20 tasks
docker.service:
total 0
drwxr-xr-x. 2 root root 0 Nov 5 17:20 .
drwxr-xr-x. 102 root root 0 Nov 6 12:31 ..
-rw-r--r--. 1 root root 0 Nov 5 17:20 cgroup.clone_children
--w--w--w-. 1 root root 0 Nov 5 17:20 cgroup.event_control
-rw-r--r--. 1 root root 0 Nov 5 17:20 cgroup.procs
-r--r--r--. 1 root root 0 Nov 5 17:20 cpuacct.stat
-rw-r--r--. 1 root root 0 Nov 5 17:20 cpuacct.usage
-r--r--r--. 1 root root 0 Nov 5 17:20 cpuacct.usage_percpu
-rw-r--r--. 1 root root 0 Nov 5 17:20 cpu.cfs_period_us
-rw-r--r--. 1 root root 0 Nov 5 17:20 cpu.cfs_quota_us
-rw-r--r--. 1 root root 0 Nov 5 17:20 cpu.rt_period_us
-rw-r--r--. 1 root root 0 Nov 5 17:20 cpu.rt_runtime_us
-rw-r--r--. 1 root root 0 Nov 6 12:26 cpu.shares
-r--r--r--. 1 root root 0 Nov 5 17:20 cpu.stat
Under the above ditrectory, I see 3 files - there are 2 docker files with container ID and one docker.service. Would the resource utilized be populated real time in the files like cpuacct.usage under it’s docker container file and will the cpuacct.usage under docker.service tell me the cumulative cpu uage for all containers ?
-rw-r--r--. 1 root root 0 Nov 5 17:20 notify_on_release
-rw-r--r--. 1 root root 0 Nov 5 17:20 tasks
[root@localhost system.slice]#
[root@localhost system.slice]#
[root@localhost system.slice]# pwd
/sys/fs/cgroup/cpu/system.slice