Linux thread process creation View

Foreword

Check the online server status, sometimes you find a few machines high memory usage. Generally this situation is certainly Telnet server, and then view the memory usage of each process. When they find too high a process of memory occupied,The primary checkpoint is typically the case in the process of creating a threadThe following is a Linux process has a view of the thread-related commands

1. ps command

  1. ps -T p <pid>
    In the pscommand, "- T" option to open a thread view. ps -T p 16241Command output as follows, wherein SPIDthe column is the thread ID. This command is connected to the back of wcthe total number of threads can be created under statistical processps -T p 16241 | wc -l
    Here Insert Picture Description

  2. ps p <pid> -L -o pcpu,pmem,pid,tid,time,tname,cmd
    Example command ps p 16241 -L -o pcpu,pmem,pid,tid,time,tname,cmdto view all the threads belonging to the process 16241, in which TIDthe column isThread ID. Similarly, after command connect wccan count the total number of threads belonging to the process
    Here Insert Picture Description

  3. pstree -p <pid>
    Command pstree -pa 25393displays threads in a process 25393 created a tree way
    Here Insert Picture Description

2. top command

topCommand can display real-time individual threads. To topopen a thread view the output, you can call the top command of the "-H" option, which lists all the Linux thread.In the top run, may be switched on or off by pressing the "H" key thread view mode, each line of the display when open are thread

top -H p <pid>Command to check the status of threads running within this process, the following example. You can see information about the total number of threads, and each thread's ID, etc.
Here Insert Picture Description

3. Check System Files

cat /proc/<pid>/status Command system can be directly read the saved process state files, which you can see the number of threads owned by the process, and the memory size.It should be noted, use this command to ensure access to the account used to log system files have
Here Insert Picture Description

Published 100 original articles · won praise 94 · views 10000 +

Guess you like

Origin blog.csdn.net/weixin_45505313/article/details/104574823