# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+. @DATADIR@/lxc/lxc.functions
+
usage()
{
- echo "usage: $(basename $0) [--lxc | --host | --name NAME] [--] [PS_OPTIONS...]" >&2
+ echo "usage: $(basename $0) [-P PATH] [--lxc | --host | --name NAME] [[--] [PS_OPTIONS...]" >&2
}
help() {
echo " --host show processes not related to any container, i.e. to the host" >&2
echo " --name NAME show processes in the specified container" >&2
echo " (multiple containers can be separated by commas)" >&2
+ echo " -P PATH show container in lxcpath PATH" >&2
echo " PS_OPTIONS ps command options (see \`ps --help')" >&2
}
# (do not append '/lxc' if the hierarchy contains the 'ns' subsystem)
case ",$subsystems," in
*,ns,*) parent_cgroup="${mountpoint}${init_cgroup%/}";;
- *) parent_cgroup="${mountpoint}${init_cgroup%/}/lxc";;
+ *) parent_cgroup="${mountpoint}${init_cgroup%/}";;
esac
break
done
list_container_processes=1; shift;;
--host)
list_container_processes=-1; shift;;
+ -P|--lxcpath)
+ lxc_path=$2; shift 2;;
--)
shift; break;;
*)
container_field_width=${#container}
fi
- if [ -f "$parent_cgroup/$container/tasks" ]; then
- tasks_files="$tasks_files $parent_cgroup/$container/tasks"
+ if lxc-info -P $lxc_path -t RUNNING -n $container; then
+ initpid=`lxc-info -P $lxc_path -p -n $container | awk -F: '{ print $2 }' | awk '{ print $1 }'`
+ cgroup=`head -n 1 /proc/$initpid/cgroup | awk -F: '{ print $3}'`
+ if [ -f "$parent_cgroup/$cgroup/tasks" ]; then
+ tasks_files="$tasks_files $parent_cgroup$cgroup/tasks"
+ fi
fi
done