linux如何查看线程信息命令是什么



linux如何查看线程信息命令是什么?linux线程命令介绍。

linux 查看线程信息 

在linux操作系统中可以使用ps -eLf命令来查看线程信息:

下面的数据为db2数据库的db2sysc进程中所包括的线程:

192.168.100.228 [sde ~]$ ps -eLf |grep db2sysc|grep -v grep

UID PID PPID LWP C NLWP STIME TTY TIME CMD
root 1 0 1 0 1 Jun03 ? 00:00:00 /sbin/init
root 2 0 2 0 1 Jun03 ? 00:00:00 [kthreadd]
root 3 2 3 0 1 Jun03 ? 00:00:00 [migration/0]
root 4 2 4 0 1 Jun03 ? 00:00:00 [ksoftirqd/0]
root 5 2 5 0 1 Jun03 ? 00:00:00 [migration/0]
root 6 2 6 0 1 Jun03 ? 00:00:00 [watchdog/0]
root 7 2 7 0 1 Jun03 ? 00:00:04 [events/0]
root 8 2 8 0 1 Jun03 ? 00:00:00 [cgroup]
root 9 2 9 0 1 Jun03 ? 00:00:00 [khelper]
root 10 2 10 0 1 Jun03 ? 00:00:00 [netns]
root 11 2 11 0 1 Jun03 ? 00:00:00 [async/mgr]
root 12 2 12 0 1 Jun03 ? 00:00:00 [pm]
root 13 2 13 0 1 Jun03 ? 00:00:00 [xenwatch]
root 14 2 14 0 1 Jun03 ? 00:00:00 [xenbus]
root 15 2 15 0 1 Jun03 ? 00:00:00 [sync_supers]
root 16 2 16 0 1 Jun03 ? 00:00:00 [bdi-default]
root 17 2 17 0 1 Jun03 ? 00:00:00 [kintegrityd/0]
root 18 2 18 0 1 Jun03 ? 00:00:00 [kblockd/0]
root 19 2 19 0 1 Jun03 ? 00:00:00 [kacpid]
root 20 2 20 0 1 Jun03 ? 00:00:00 [kacpi_notify]
root 21 2 21 0 1 Jun03 ? 00:00:00 [kacpi_hotplug]
root 22 2 22 0 1 Jun03 ? 00:00:00 [ata/0]
root 23 2 23 0 1 Jun03 ? 00:00:00 [ata_aux]
root 24 2 24 0 1 Jun03 ? 00:00:00 [ksuspend_usbd]
root 25 2 25 0 1 Jun03 ? 00:00:00 [khubd]
root 26 2 26 0 1 Jun03 ? 00:00:00 [kseriod]
root 27 2 27 0 1 Jun03 ? 00:00:00 [md/0]
root 28 2 28 0 1 Jun03 ? 00:00:00 [md_misc/0]
root 29 2 29 0 1 Jun03 ? 00:00:00 [khungtaskd]
root 30 2 30 0 1 Jun03 ? 00:00:00 [kswapd0]
root 31 2 31 0 1 Jun03 ? 00:00:00 [ksmd]
root 32 2 32 0 1 Jun03 ? 00:00:02 [khugepaged]
root 33 2 33 0 1 Jun03 ? 00:00:00 [aio/0]
root 34 2 34 0 1 Jun03 ? 00:00:00 [crypto/0]
root 39 2 39 0 1 Jun03 ? 00:00:00 [kthrotld/0]
root 41 2 41 0 1 Jun03 ? 00:00:00 [kpsmoused]
root 42 2 42 0 1 Jun03 ? 00:00:00 [usbhid_resumer]
root 178 2 178 0 1 Jun03 ? 00:00:00 [scsi_eh_0]
root 179 2 179 0 1 Jun03 ? 00:00:00 [scsi_eh_1]
root 223 2 223 0 1 Jun03 ? 00:00:00 [kjournald]
root 288 1 288 0 1 Jun03 ? 00:00:00 /sbin/udevd -d
root 519 2 519 0 1 Jun03 ? 00:00:00 [flush-202:0]
root 520 2 520 0 1 Jun03 ? 00:00:00 [flush-202:16]
root 533 288 533 0 1 Jun03 ? 00:00:00 /sbin/udevd -d
root 536 2 536 0 1 Jun03 ? 00:00:00 [kstriped]
root 565 2 565 0 1 Jun03 ? 00:00:02 [jbd2/xvdb1-8]
root 566 2 566 0 1 Jun03 ? 00:00:00 [ext4-dio-unwrit]
root 596 2 596 0 1 Jun03 ? 00:00:00 [kauditd]
root 828 1 828 0 4 Jun03 ? 00:00:00 /sbin/rsyslogd -i /var/run/syslogd.pid -c 5
root 828 1 829 0 4 Jun03 ? 00:00:00 /sbin/rsyslogd -i /var/run/syslogd.pid -c 5
root 828 1 831 0 4 Jun03 ? 00:00:00 /sbin/rsyslogd -i /var/run/syslogd.pid -c 5
root 828 1 832 0 4 Jun03 ? 00:00:00 /sbin/rsyslogd -i /var/run/syslogd.pid -c 5
root 844 1 844 0 1 Jun03 ? 00:00:03 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)
root 852 1 852 0 1 Jun03 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
www 855 852 855 0 1 Jun03 ? 00:02:43 nginx: worker process
root 864 1 864 0 1 Jun03 ? 00:00:00 /usr/sbin/sshd

其中

UID为User ID.

PID为process id,进程标识符

PPID为 parent process id,父进程标识符2,


LWP为light weight process or thread, 轻量级进程,即线程标识符

NLWP为,number of lwps(threads) in the process, 线程的数量

现在的db2sysc进程一共包含40个线程,它们的线程号为:

192.168.100.228 [sde ~]$ ps -eLf |grep db2sysc|grep -v grep|awk ‘{print $4}’
4865
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
5156
5662
5663
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6191
6205
6337
7131
7578
7596
7622
7908
10637
25427
27917
30815
30816
利用数据库的命令可以查看到更详细的线程信息:
192.168.100.228 [sde ~]$ db2pd -edus|awk ‘{print $3,$4}’

0 –

all EDUs

4865
4863
4880

TID Kernel

30816 db2agntdp
30815 db2agntdp
27917 db2agntdp
25427 db2agntdp
10637 db2agntdp
7908 db2agent
7622 db2agent
7596 db2agent
7578 db2agent
7131 db2agent
6337 db2agent
6205 db2agent
6191 db2agntdp
6137 db2evmgi
6136 db2fw1
6135 db2fw0
6134 db2lused
6133 db2wlmd
6132 db2pfchr
6131 db2pfchr
6130 db2pfchr
6129 db2pclnr
6128 db2dlock
6127 db2lfr
6126 db2loggw
6125 db2loggr
5663 db2stmm
5662 db2agent
5156 db2taskd
4878 db2spmlw
4877 db2spmrsy
4876 db2resync
4875 db2tcpcm
4874 db2tcpcm
4873 db2ipccm
4872 db2licc
4871 db2thcln
4870 db2alarm
4869 db2sysc