Monitoring cpu and memory usage of Docker containers on Centos 7

Balaji asked:

I’m trying to run application builds inside docker containers and gather resource usage stats.

I can gather usage metrics for example memory usage details for a container with id foobar running docker on Ubuntu 14.04 host by inspecting:

/sys/fs/cgroups/memory/docker/foobar/memory.stat

but on Centos 7 host, ‘/sys/fs/cgroups/memory/docker’ directory is missing.

How to find out about container specific memory or cpu usage on Centos 7 Host.
Thanks

My answer:


Well, first you misspelled cgroup 🙂

After poking around, I found what you were looking for:

# cat /sys/fs/cgroup/memory/system.slice/docker-88018f8043d00669bbf865855ebc8a6ccc93a04ce588111e01d4e63739250340.scope/memory.stat 
cache 5251072
rss 380928
rss_huge 0
mapped_file 2662400
writeback 0
swap 0
pgpgin 1570
pgpgout 195
pgfault 344
pgmajfault 40
inactive_anon 278528
active_anon 102400
inactive_file 5083136
active_file 167936
unevictable 0
hierarchical_memory_limit 18446744073709551615
hierarchical_memsw_limit 18446744073709551615
total_cache 5251072
total_rss 380928
total_rss_huge 0
total_mapped_file 2662400
total_writeback 0
total_swap 0
total_pgpgin 1570
total_pgpgout 195
total_pgfault 344
total_pgmajfault 40
total_inactive_anon 278528
total_active_anon 102400
total_inactive_file 5083136
total_active_file 167936
total_unevictable 0
recent_rotated_anon 248
recent_rotated_file 41
recent_scanned_anon 248
recent_scanned_file 1495

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.