Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

My favourite ps invocation is:

ps -efww ef

as I need to watch all processes (-e), get extended information about them (-f), see the environment (e) they operate within, wrapping lines (-w -w) so I don't lose any part of that, and visually group (f) child processes under their parents, for an at-a-glance overview.

I have "wasted" the whole morning trying to get any thread information to appear as well, following the same visualisation logic above. I must have tried 40 different combinations of options. (Actually, I just checked my .bash_history and I have tried more!). Combinations included swapping f and -H for forest display, for instance. Sometimes I even tried permutations to check insidious "orderings"...

None of the threading options seem to be compatible with my "monitoring screen" setup. I am talking about H, -L, m, -m and -T.

I am baffled. Am I doing it wrong? How are you guys doing it?

Specifically: I need to watch for processes like download managers who go funky with 30 to 80 threads all of a sudden...

share|improve this question
1  
I don't understand what you're trying to achieve. Yes, there are many ps options, and the syntax is confusing. But you're only saying what you don't want, not what you want. Are you trying to monitor the number of threads per process? –  Gilles Oct 24 '12 at 21:35
add comment

1 Answer

To watch for processes that create a lot of threads, I think all that's relevant is the number of threads per process, so go with

ps -o pid -o thcount

plus any option to select which processes to match, such as -e or -C. Run the command periodically and watch for sudden changes in thcount. This will give you approximate results (for example, you won't detect if a PID is reused between calls) but that should be good enough for your purpose.

Note that you can limit the number of threads per process:

(ulimit -T 20; downloadmanager)
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.