mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-06-07 08:37:57 +00:00
lxc-ps: fix order of output and fix --lxc opt
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@alpinelinux.org> Acked-by: Stéphane Graber <stgraber@ubuntu.com>
This commit is contained in:
parent
bc2333ebec
commit
bd9a66b20c
@ -114,7 +114,8 @@ for container in ${containers}; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
# first file is stdin, the rest are the container tasks
|
# 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
|
# first line is PS header
|
||||||
NR == 1 {
|
NR == 1 {
|
||||||
# find pid field index
|
# find pid field index
|
||||||
@ -133,7 +134,8 @@ NR == 1 {
|
|||||||
|
|
||||||
# store lines from ps with pid as index
|
# store lines from ps with pid as index
|
||||||
NR == FNR {
|
NR == FNR {
|
||||||
ps[$pididx] = $0
|
ps_line[NR] = $0
|
||||||
|
pid_of_line[NR] = $pididx
|
||||||
next
|
next
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,8 +153,11 @@ FNR == 1 {
|
|||||||
|
|
||||||
END {
|
END {
|
||||||
printf("%-" container_field_width "s %s\n", "CONTAINER", header)
|
printf("%-" container_field_width "s %s\n", "CONTAINER", header)
|
||||||
for (pid in container_of_pid)
|
for (i in ps_line) {
|
||||||
printf("%-" container_field_width "s %s\n", container_of_pid[pid], ps[pid])
|
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
|
' - $tasks_files
|
||||||
|
Loading…
Reference in New Issue
Block a user