How to know the number of active threads in Puma

前端 未结 6 1968
太阳男子
太阳男子 2021-02-19 03:59

I am trying to see the number of active puma threads on my server.

I can not see it through ps:

$ ps aux | grep puma
healthd   2623  0.0  1.         


        
6条回答
  •  日久生厌
    2021-02-19 04:47

    If you are just looking for number of threads that are spawned by the process, you can see the number of task folders created under /proc/[pid-of-process]/task because each thread creates a folder under this path. So counting the number of folders would be sufficient.

    In fact the ps utility itself reads the information from this path, a file /proc/[PID]/cmdline which is represented in a more readable way.

    From Linux Filesystem Hierarchy

    /proc is very special in that it is also a virtual file-system. It's sometimes referred to as a process information pseudo-file system. It doesn't contain 'real' files but run-time system information (e.g. system memory, devices mounted, hardware configuration, etc). For this reason it can be regarded as a control and information center for the kernel. In fact, quite a lot of system utilities are simply calls to files in this directory.

    All you need to get the PID of the process puma, use ps or any utility of your choice

    ps aux | awk '/[p]uma/{print $1}'
    

    or more directly use pidof(8) - Linux man page which gets you the PID directly given the process name as input

    pidof -s puma
    

    Now that you have the PID to count the number of task/ folders your process had created use the find command

    find /proc//task -maxdepth 1 -type d -print | wc -l
    

提交回复
热议问题