[lxc-devel] [PATCH] lxc-ps: fix order of output and fix --lxc opt
Stéphane Graber
stgraber at ubuntu.com
Fri Jan 4 15:11:47 UTC 2013
On 01/04/2013 03:39 AM, Natanael Copa wrote:
> We must output the lines from 'ps' in same order for tree views.
>
> Fix also --lxc option to only show processes from containers.
>
> Signed-off-by: Natanael Copa <ncopa at alpinelinux.org>
That looks much better, thanks.
Acked-by: Stéphane Graber <stgraber at ubuntu.com>
> ---
>
> The logic was wrong. Sorry.
>
> src/lxc/lxc-ps.in | 13 +++++++++----
> 1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/src/lxc/lxc-ps.in b/src/lxc/lxc-ps.in
> index 25e843b..5f7cf4d 100644
> --- a/src/lxc/lxc-ps.in
> +++ b/src/lxc/lxc-ps.in
> @@ -114,7 +114,8 @@ for container in ${containers}; do
> done
>
> # first file is stdin, the rest are the container tasks
> -ps "$@" | awk -v container_field_width="$container_field_width" '
> +ps "$@" | awk -v container_field_width="$container_field_width" \
> + -v list_container_processes="$list_container_processes" '
> # first line is PS header
> NR == 1 {
> # find pid field index
> @@ -133,7 +134,8 @@ NR == 1 {
>
> # store lines from ps with pid as index
> NR == FNR {
> - ps[$pididx] = $0
> + ps_line[NR] = $0
> + pid_of_line[NR] = $pididx
> next
> }
>
> @@ -151,8 +153,11 @@ FNR == 1 {
>
> END {
> printf("%-" container_field_width "s %s\n", "CONTAINER", header)
> - for (pid in container_of_pid)
> - printf("%-" container_field_width "s %s\n", container_of_pid[pid], ps[pid])
> + for (i in ps_line) {
> + container = container_of_pid[pid_of_line[i]]
> + if (list_container_processes == 0 || container != "")
> + printf("%-" container_field_width "s %s\n", container, ps_line[i])
> + }
> }
>
> ' - $tasks_files
>
--
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 899 bytes
Desc: OpenPGP digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20130104/714f8475/attachment.pgp>
More information about the lxc-devel
mailing list