Kriss
1
Hi
I have identified from the host a process by its PID. How to easily determine in which container it is running?
I know “ps fauxww”, or even looping each CT+ps -ef + filtering, but I’d prefer something more efficient.
Same question if I have identified a or several process by their user ID. How to identify to which container this user ID belongs to ?
Happy New Year!
stgraber
(Stéphane Graber)
2
You could try to guess from the cgroup in /proc/PID/cgroup
hi-ko
(Heiko Robert)
4
would be nice to have such a thing directly available in the lxc command like
lxc pidinfo list <container>
lxc pidinfo getcontainer <pid>
Would it be worth to create a ticket in github?
At the moment I use custom bash functions like
lxc_get_container_pids(){
CONTAINER=$1
find /sys/fs/cgroup/lxc.payload.${CONTAINER}/ -name cgroup.procs -exec cat {} \;
}
lxc_get_container_by_pid(){
PID=$1
cat /proc/${PID}/cgroup|awk -F '/' '{ split($2,a,".");print a[3] }'
}
Maybe related to systemd-cgtop and lxc-top for one or more lxd hosts #822
2 Likes