> > > > See: > > https://github.com/systemd/systemd/blob/master/src/cgtop/cgtop.c#L232 > > It simply divides the CPU time spent by the real time spent, that's all. > > Any suggestion of how to get those times using bash ? I am using "/proc/stat" for system cpu and "/sys/fs/cgroup/cpu, cpuacct/system.slice/docker-${CID}*.scope/cpuacct.usage" for docker container cpu.
> > b) Is it possible to get CPU% using a bash script reading systemd-cgtop ? > > I have tried something like: systemd-cgtop -b -n2 , but it is not > > collecting CPU% info. > > Well, you can only calculate the CPU time spent within a certain > amount of time, hence writing a script that runs once and does not > stay around for that time to watch the CPU time counters cannot work. > Yes. I am doing that (sleep 2 in my bash script *get_container_cpu_percentage() *function ). My doubt is: from where systemd-cgtop gets the CPU info ? Thank you.
_______________________________________________ systemd-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/systemd-devel
