get number of threads from a running process

Discussion in 'Ruby' started by Skellington, Dec 11, 2012.

  1. Skellington

    Skellington Guest

    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
     
    Skellington, Dec 11, 2012
    #1
    1. Advertising

  2. 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
     
    Robert Klemme, Dec 11, 2012
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Soeren Gerlach
    Replies:
    0
    Views:
    464
    Soeren Gerlach
    Jul 15, 2004
  2. Ronan Viernes
    Replies:
    3
    Views:
    991
    John Lenton
    Jul 14, 2004
  3. Ronnan-Ian Viernes
    Replies:
    0
    Views:
    429
    Ronnan-Ian Viernes
    Jul 14, 2004
  4. John Lenton
    Replies:
    0
    Views:
    556
    John Lenton
    Jul 14, 2004
  5. Pedro Pinto

    Java Threads - Get running threads

    Pedro Pinto, Apr 8, 2008, in forum: Java
    Replies:
    2
    Views:
    1,524
    Arne Vajhøj
    Apr 9, 2008
Loading...

Share This Page