Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- ps axo pid,ppid,comm | awk '
- BEGIN {
- getline # remove header
- ign["containerd-shim"]
- ign["sge_execd"]
- ign["sge_shepherd"]
- ign["squashfuse_ll"]
- }
- $2 == 1 && !($3 in ign) { print (pid = $1) }
- ' | xargs -r ps o pid,command | awk -v skip=$$ '
- BEGIN {
- getline # header
- match($0, /COMMAND/) # column
- comm = RSTART # position
- }
- function pstree(pid, cmd, line, child, sp)
- {
- sp = ""
- cmd = sprintf("pstree -ap %d", pid)
- while (cmd | getline line > 0) {
- if (sp != "") {
- if (substr(line, 1, length(sp)) == sp) continue
- else sp = ""
- }
- if (!match(line, /,[0-9]+/)) continue
- child = substr(line, RSTART + 1, RLENGTH - 1)
- if (child == skip) {
- skip = 0
- sp = line
- gsub(/[`-].*/, "", sp)
- } else print child
- line = substr(line, RSTART + RLENGTH)
- }
- close(cmd)
- }
- { print pstree(pid = $1) }
- ' | xargs -r ps fo pid,uid | awk '
- BEGIN { getline } # remove header
- $2 > 1000 { print $1 }
- ' | xargs -r ps ${*:-uf}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement