Created
September 12, 2016 15:56
-
-
Save jbbarth/615292963e13249d7abf838578376d64 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
def children(ps, pid) | |
ps.select do |p| | |
p.split[2] == pid | |
end | |
end | |
def pid_from_line(line) | |
line.split[1] | |
end | |
def display_proc(line) | |
line.split[7..-1].join " " | |
end | |
ps = %x(ps -edf).lines.map(&:strip) | |
ps.grep(/pytho[n].*supervisord -c/).each do |main_proc| | |
puts display_proc(main_proc) | |
children(ps, pid_from_line(main_proc)).each do |child| | |
puts " \\_ [#{children(ps, pid_from_line(child)).count.to_s.rjust(2)}] #{display_proc(child)}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment