I often want to know why a process in the middle of a pipeline is sleeping and not busy processing data. My current method is:
- find the
pid
of interest sudo strace -pt pid
to get the blocking syscall and object (fd, child, futex, etc.)- hit Ctrlc to detach strace
- look up the appropriate object in
/proc/pid
grep /proc/
or uselsof
to find the other end of the pipe or process being waited on- repeat from #1 with the new
pid
This is a pretty slow process that combines a lot of tools that don't play well together (strace
in particular is hard to automate). Is there a tool that will do this loop for me and plot out the wait chain of a process, or at least make one iteration less awkward?
Linux 3.2, Ubuntu LTS 12, x64, under VirtualBox, if it matters.
Best Answer
most
ps
s now include a tree option, or a very aptly name related utility,ptree
.As my current work system doesn't have ptree, I currently use
I think I also had a
Finally some ps have options to also include a programs threads in the view.
While this isn't the automated solution you (and I) would wish for, my experience is that there emerges a list of 'likely-suspects' in process trees, and just scanning the tree, you can often guess where the problem is.
IHTH