0. Most commonly used Pstree:
[Email protected] temp]# Pstree-a|grep Multe
| | '-multepoolser
| | '-multepoolser
| | ' -2*[{multepoolser}]
1. > Top
All system processes can be displayed
Press U, and then enter the appropriate execution user name, such as Tom
You can see all the processes that Tom user started and the corresponding PID
2. > Pstack pid
You can see the running state of each thread under this PID,
[[email protected] multepoolserver]# pstack 14944 (PID number of the process)
Thread 2 (thread 0x41ed5940 (LWP 14945)):
#0 0X0000003C9AE0D5CB in read () from/lib64/libpthread.so.0
#1 0x00000000004017b6 in Sync_additional_writing_worker ()
#2 0x0000003c9ae064a7 in Start_thread () from/lib64/libpthread.so.0
#3 0x0000003c9a2d3c2d in Clone () from/lib64/libc.so.6
Thread 1 (thread 0x2b24b3094250 (LWP 14944)):
#0 0x0000003c9a2d4018 in epoll_wait () from/lib64/libc.so.6
#1 0x0000000000401d59 in Process ()
#2 0x00000000004029b8 in Main ()
From: http://blog.csdn.net/wind_324/article/details/6152912
Method One:
Ps-ef F
displaying processes and threads in a tree shape
Under Linux it seems that because there is no real thread, it is simulated with a process, one is a worker thread, so the real program thread should only have one.
Method Two:
[Email protected] dhj]# PS axm|grep httpd
Method Three:
In addition, the same effect can be achieved with pstree-c, but there is no thread number:
[Email protected] dhj]# Pstree-c|grep httpd
From: http://blog.chinaunix.net/uid-346158-id-2131012.html
1. Pstree
Pstree displaying processes in a tree structure
- [Email protected]*:~# pstree
- Init─┬─networkmanager
- ├─abrt-dump-oops
- ├─abrtd
- ├─atd
- ├─AUDITD───{AUDITD}
- ├─automount───4*[{automount}]
- ├─certmonger
- ├─crond
- ├─dbus-daemon
- ├─hald─┬─hald-runner─┬─hald-addon-acpi
- ││└─hald-addon-inpu
- │└─{hald}
- ├─httpd─┬─httpd
- │└─4*[HTTPD───26*[{HTTPD}]]
- ├─irqbalance
- ├─mcelog
- ├─6*[mingetty]
- ├─modem-manager
- ├─MYSQLD_SAFE───MYSQLD───38*[{MYSQLD}]
- ├─nginx───13*[nginx]
- ├─PHP-FPM───76*[PHP-FPM]
- ├─portreserve
- ├─rpc.idmapd
- ├─rpc.statd
- ├─rpcbind
- ├─RSYSLOGD───3*[{RSYSLOGD}]
- ├─2*[sendmail]
- ├─sshd───sshd───bash───pstree
- ├─UDEVD───2*[UDEVD]
- ├─wpa_supplicant
- └─xinetd
2. Ps-lf
$ PS-LF 1892
As follows: The PHP process started a total of 0 threads
[Email protected]**:~# ps-lf 1892
UID PID PPID LWP C nlwp stime TTY STAT time CMD
Root 1892 1 1892 0 1 Jan15? Ss 0:53 Php-fpm:master Process (/usr/local/php/etc/php-fpm.conf)
MySQL Multiple threads:
[Email protected]*:~# ps-lf 3005
UID PID PPID LWP C nlwp stime TTY STAT time CMD
MySQL 3005 3005 0 Jan15? Sl 2:25/usr/local/mysql/bin/mysqld--basedir=/usr/local/mysql--datadir=/data/mysql--plugin-dir=
MySQL 3005 3081 0 Jan15? Sl 0:00/usr/local/mysql/bin/mysqld--basedir=/usr/local/mysql--datadir=/data/mysql--plugin-dir=
MySQL 3005 3082 0 Jan15? Sl 0:05/usr/local/mysql/bin/mysqld--basedir=/usr/local/mysql--datadir=/data/mysql--plugin-dir=
MySQL 3005 3083 0 Jan15? Sl 0:00/usr/local/mysql/bin/mysqld--basedir=/usr/local/mysql--datadir=/data/mysql--plugin-dir=
MySQL 3005 3084 0 Jan15? Sl 0:00/usr/local/mysql/bin/mysqld--basedir=/usr/local/mysql--datadir=/data/mysql--plugin-dir=
MySQL 3005 3085 0 Jan15? Sl 0:00/usr/local/mysql/bin/mysqld--basedir=/usr/local/mysql--datadir=/data/mysql--plugin-dir=
MySQL 3005 3086 0 Jan15? Sl 0:00/usr/local/mysql/bin/mysqld--basedir=/usr/local/mysql--datadir=/data/mysql--plugin-dir=
MySQL 3005 3087 0 Jan15? Sl 0:05/usr/local/mysql/bin/mysqld--basedir=/usr/local/mysql--datadir=/data/mysql--plugin-dir=
3. Pstack
Pstack shows the stack trace for each process, PHP's FPM master process, found that this thing is walking epoll:
[Email protected]:~# pstack 1892
#0 0x00000030e9ae8fb3 in __epoll_wait_nocancel () from/lib64/libc.so.6
#1 0x0000000000856a74 in Fpm_event_epoll_wait ()
#2 0x000000000084afff in Fpm_event_loop ()
#3 0x0000000000845ee7 in Fpm_run ()
#4 0x000000000084d900 in Main ()
You have new mail in/var/spool/mail/root
justwinit@ to the East blog focus on the beauty of Web application Architecture---Architecture is the beauty of the state | The beauty of application lies in the charm
Address: http://www.justwinit.cn/post/7737/
All rights reserved. The author and original source and this statement must be indicated in the form of a link in the reprint!
Linux under the Multithreaded viewing tool (Pstree, PS, pstack), Linux command-pstree instructions, Linux view thread status. Do not specify