Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > get number of threads from a running process

Reply
Thread Tools

get number of threads from a running process

 
 
Skellington
Guest
Posts: n/a
 
      12-11-2012
Hello,
is it possible to get a count on the number of threads a process is
using? For example lets say I have Apache "httpd" and it has 66
threads running according to top. Is there a way to get the number
using ruby?

Thanks,
Charlie
 
Reply With Quote
 
 
 
 
Robert Klemme
Guest
Posts: n/a
 
      12-11-2012
On 12/11/2012 05:49 PM, Skellington wrote:

> is it possible to get a count on the number of threads a process is
> using? For example lets say I have Apache "httpd" and it has 66
> threads running according to top. Is there a way to get the number
> using ruby?


On Linux

def thread_count(pid)
Dir["/proc/#{pid}/task/*"].size
end

Kind regards

robert
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Java Threads - Get running threads Pedro Pinto Java 2 04-08-2008 11:44 PM
Number of threads with respect to JVM memory (1.5b2 running on 2.6 linux) Soeren Gerlach Java 0 07-15-2004 11:01 AM
Re: How to increase number of threads per process? John Lenton Python 0 07-14-2004 11:22 AM
RE: How to increase number of threads per process? Ronnan-Ian Viernes Python 0 07-14-2004 03:29 AM
How to increase number of threads per process? Ronan Viernes Python 3 07-14-2004 03:14 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57