Article Directory
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
-
ps -T p <pid>
In theps
command, "- T" option to open a thread view.ps -T p 16241
Command output as follows, whereinSPID
the column is the threadID
. This command is connected to the back ofwc
the total number of threads can be created under statistical processps -T p 16241 | wc -l
-
ps p <pid> -L -o pcpu,pmem,pid,tid,time,tname,cmd
Example commandps p 16241 -L -o pcpu,pmem,pid,tid,time,tname,cmd
to view all the threads belonging to the process 16241, in whichTID
the column isThread ID. Similarly, after command connectwc
can count the total number of threads belonging to the process
-
pstree -p <pid>
Commandpstree -pa 25393
displays threads in a process 25393 created a tree way
2. top command
top
Command can display real-time individual threads. To top
open 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.
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