[systemd-devel] systemd-cgtop vs docker-stats

Tiago Alves tiagoalves83 at gmail.com
Sat Dec 5 19:10:13 PST 2015


>
>
> I am not convinced that "bash" is the right language to do such
> calculations in.
>

You are right! But I have tried "systemd-cgtop -n 2 -b > test" and it
doesn't return CPU usage (actually I believe it just returns the first
interaction. I tried increase the number of interactions without success -
shell returns almost immediately ).

"top -n2 > test" works fine (It shows cpu usage event with -n1).  I dont
know if cgtop should behave the same as "top". Does it ?


> cpuacct.usage is the right place to look for systemd's own cgroups. No
> idea how docker uses cgroups though.
>

docker stores containers info at:
sys/fs/cgroup/cpu,cpuacct/system.slice/docker-*/cpuacct.usage


>
> I don't see why you'd ever use /proc/stat. Just use the top-level
> cpuacct.usage file in the cgroup tree, it should cover the whole tree,
> and hence the entire system.
>

Nice. I have done as you suggested. Easier and cleaner now.


>
> No idea how you would query the CLOCK_MONOTONIC clock for the time
> passed though from bash.


The bash script is actually working (I just call a "sleep 1" between 2
cpuacct.usage calls). The cpu usage seems ok. But I believe there is a more
accurate way of doing.
cgtop looks very accurate, but I wasn't able to write a bash script that
reads from cgtop directly.
"systemd-cgtop -n2 -b > test" is not showing cpu usage, neither
"var=$(systemd-cgtop -n2 -b)

My intention is just build something that Zabbix Server can use to monitor
docker containers CPU/Memory usage.

I will upload the project to https://github.com/tiagoalves83/docker-zabbix
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20151206/1f2c5c2d/attachment.html>


More information about the systemd-devel mailing list