1. pstree
pstree以树结构显示进程
root@119.10.6.*:~# 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]
├─-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
如下:PHP进程共启动了0个线程
root@119.10.6.**:~# 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多个线程:
root@119.10.6.*:~# ps -Lf 3005
UID PID PPID LWP C NLWP STIME TTY STAT TIME CMD
3005 2011 3005 0 39 Jan15 ? Sl 2:25 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=
mysql 3005 2011 3081 0 39 Jan15 ? Sl 0:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=
mysql 3005 2011 3082 0 39 Jan15 ? Sl 0:05 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=
mysql 3005 2011 3083 0 39 Jan15 ? Sl 0:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=
mysql 3005 2011 3084 0 39 Jan15 ? Sl 0:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=
mysql 3005 2011 3085 0 39 Jan15 ? Sl 0:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=
mysql 3005 2011 3086 0 39 Jan15 ? Sl 0:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=
mysql 3005 2011 3087 0 39 Jan15 ? Sl 0:05 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=
3. pstack
pstack显示每个进程的栈跟踪,PHP的fpm主进程,发现这玩意是走的epoll:
root@119.10.6.23:~# 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 in /var/spool/mail/root