lxc-ps2 is a wrapper of the 'ps' command that can show the names of the lxc VMs where processes are running.
lxc-ps2 behaves identically to the 'ps' command except that it adds support the following format specifiers:
ipcnsn, mntnsn, netnsn, pidnsn, usrnsn, utsnsn
which will list the respective lxc VM names in which a process is running.
The lxc project itself had a lxc-ps implementation which was removed.
There was a virt-ps tool by Richard W.M. Jones floating around once, but that also seems to have been dropped.
lxc-ps2 is implemented in shell and is very rough, but it could certainly be improved and it could also be extended to other namespace based virtualisation techniques like f.ex. docker.
root@host ~ # lxc-ps2 -eo user,pid,pidnsn,args
USER PID PIDNS COMMAND
root 1 HOST_MACHINE init [2]
root 2 HOST_MACHINE [kthreadd]
root 3 HOST_MACHINE [ksoftirqd/0]
[...etc...]
1003 733 guest-vm1 nc 192.168.138.1 22
root 734 test-vm sshd: root@pts/3,pts/4
root 758 test-vm -bash
[...etc...]
procps-ng-3.3.9 or higher
Tomas Pospisek tpo_deb@sourcepole.ch