Does anyone know how Docker calculates its memory usage, cpu usage and network/o usage? i am aware that some metrics can be obtained from the cgroup but upon calculating CPU usage and Memory usage, i realise that my metrics do not tally with the metrics shown when i run docker stats. can anyone help me with this?
for memory usage, i obtained metrics from the memory.stat file and used the following to calculate:(anon+inactive_anon+kernel_stack+active_anon+file+inactive_file+pagetables+slab ) / memory limit x100
for cpu usage, i obtained metrics from the cpu.stat and cpu.max file :
user_usec / (cpu quota * cpu max) * 100
still was unable to obtain a value that corresponds to docker stats though.