Here's a patch to the ps command included with FreeBSD. This patch adds two command line options to ps to support listing processes within jails:
-J jailname: List only processes belonging to jailname
-H: List only processes belonging to the host system.
Here's a quick install and patch, which keeps the previous ps binaries, etc... Use psj instead for the patched version.
# cd /usr/src # patch < /path/to/patch/psj.x.x.patch # cd bin/ps # make # cd /usr/obj/usr/src/bin/ps/ # cp ps /bin/psj # cp ps.1.gz /usr/share/man/man1/psj.1.gz
Source:
psj.5.0.patch (for FreeBSD 5.0)
psj.4.7.patch (for FreeBSD 4.7)
psj.4.6.patch (for FreeBSD 4.6)
psj.4.5.patch (for FreeBSD 4.5)
See license. Contact me when bugs are found.