Linux under the Multithreaded viewing tool (Pstree, PS, pstack), Linux command-pstree instructions, Linux view thread status. Do not specify

Source: Internet
Author: User
Tags fpm stack trace

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

  1. [Email protected]*:~# pstree
  2. Init─┬─networkmanager
  3. ├─abrt-dump-oops
  4. ├─abrtd
  5. ├─atd
  6. ├─AUDITD───{AUDITD}
  7. ├─automount───4*[{automount}]
  8. ├─certmonger
  9. ├─crond
  10. ├─dbus-daemon
  11. ├─hald─┬─hald-runner─┬─hald-addon-acpi
  12. ││└─hald-addon-inpu
  13. │└─{hald}
  14. ├─httpd─┬─httpd
  15. │└─4*[HTTPD───26*[{HTTPD}]]
  16. ├─irqbalance
  17. ├─mcelog
  18. ├─6*[mingetty]
  19. ├─modem-manager
  20. ├─MYSQLD_SAFE───MYSQLD───38*[{MYSQLD}]
  21. ├─nginx───13*[nginx]
  22. ├─PHP-FPM───76*[PHP-FPM]
  23. ├─portreserve
  24. ├─rpc.idmapd
  25. ├─rpc.statd
  26. ├─rpcbind
  27. ├─RSYSLOGD───3*[{RSYSLOGD}]
  28. ├─2*[sendmail]
  29. ├─sshd───sshd───bash───pstree
  30. ├─UDEVD───2*[UDEVD]
  31. ├─wpa_supplicant
  32. └─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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.