DjoDjo
(Johann)
January 4, 2018, 7:42pm
1
Hello,
I try to get the list of the CT, including a colimn with the process number in each CT.
With “lxc info $CT” I can see:
Resources:
Processes: 3
But with “lxc list” I can not find any config key for the process number to specify with the “-c” option.
I checked on https://github.com/lxc/lxd/blob/master/doc/containers.md with no success.
Any ideas ?
simos
(Simos Xenitellis)
January 4, 2018, 8:36pm
2
Indeed, there is no key to show the current number of processes in a container. The number of processes is just one of the many datapoints you would need from a container. Ideally, you would want much more insight on what is going on in a container.
You would need a dedicated tool instead, such as sysdig
. See more at https://blog.simos.info/how-to-use-sysdig-and-falco-with-lxd-containers/
ernstae
(Andrew Ernst)
January 4, 2018, 8:44pm
3
Are you attempting to just get a list of running processes from each of the running containers? If so, this is a simple hacky way to do just that:
for x in $(lxc list | grep RUNNING | awk -F'|' {'print $2'}); do lxc exec $x -- ps; done;
PID TTY TIME CMD
3873 ? 00:00:00 ps
PID TTY TIME CMD
2282 ? 00:00:00 ps
PID TTY TIME CMD
24408 ? 00:00:00 ps
PID TTY TIME CMD
5763 ? 00:00:00 ps
PID TTY TIME CMD
21181 ? 00:00:00 ps
PID TTY TIME CMD
27492 ? 00:00:00 ps
PID TTY TIME CMD
26054 ? 00:00:00 ps
PID TTY TIME CMD
4791 ? 00:00:00 ps
PID TTY TIME CMD
1703 ? 00:00:00 ps
PID TTY TIME CMD
13684 ? 00:00:00 ps
Hopefully, that might help? If I misread what you’re attempting, please let me know.
You might want to use the command ps auxf
instead of just ps, to get the full process tree of all user processes inside the containers, btw.
Cheers,
Dnegreira
(David Negreira)
January 5, 2018, 10:46am
4
You can also use ‘htop’ displaying the cgroups column, which shows which cgroup is the process running.
DjoDjo
(Johann)
January 5, 2018, 10:53am
5
Ok thank you all for the alternatives !
Regards
stgraber
(Stéphane Graber)
January 6, 2018, 12:01am
6
It’d be a reasonable thing to add to lxc list
as an optional column, feel free to file a bug at https://github.com/lxc/lxd/issues or better yet, send a pull-request for it.
Dnegreira
(David Negreira)
January 6, 2018, 3:03pm
7
1 Like