[20230323]ps命令檢視thread.txt
[20230323]ps命令檢視thread.txt
--//前一段時間遇到的問題,ps -fp <pid> ,沒有查詢到對應程式,當時有點蒙.
--//現在想想可能對應的是執行緒,不能透過這樣的方式查詢.應該加入-L引數.
--//看了一些文件順便學習相關內容.
$ ps -o nlwp,pid,lwp,user,args -u grid | awk '$1>1 { print $0}'
NLWP PID LWP USER COMMAND
28 8870 8870 grid /u01/app/11.2.0/grid/bin/oraagent.bin
9 11035 11035 grid /u01/app/11.2.0/grid/bin/gipcd.bin
4 11037 11037 grid /u01/app/11.2.0/grid/bin/mdnsd.bin
18 11163 11163 grid /u01/app/11.2.0/grid/bin/ocssd.bin
17 11949 11949 grid /u01/app/11.2.0/grid/bin/evmd.bin
6 12285 12285 grid /u01/app/11.2.0/grid/bin/gpnpd.bin
54 14183 14183 grid /u01/app/11.2.0/grid/jdk/bin/java -server -Xcheck:jni -Xms128M -Xmx384M
-Djava.awt.headless=true -Ddisable.checkForUpdate=true -Dstdstream.filesize=100 -Dstdstream.filenumber=10
-DTRACING.ENABLED=false -Doracle.wlm.dbwlmlogger.logging.level=INFO -Dport.rmi=23792 -jar
/u01/app/11.2.0/grid/oc4j/j2ee/home/oc4j.jar -config /u01/app/11.2.0/grid/oc4j/j2ee/home/OC4J_DBWLM_config/server.xml
-out /u01/app/11.2.0/grid/oc4j/j2ee/home/log/oc4j.out -err /u01/app/11.2.0/grid/oc4j/j2ee/home/log/oc4j.err
23 15261 15261 grid /u01/app/11.2.0/grid/bin/oraagent.bin
3 24695 24695 grid /u01/app/11.2.0/grid/bin/tnslsnr dbrayw -inherit
16 30995 30995 grid /u01/app/11.2.0/grid/opmn/bin/ons -d
3 31146 31146 grid /u01/app/11.2.0/grid/bin/tnslsnr LISTENER_SCAN2 -inherit
3 31152 31152 grid /u01/app/11.2.0/grid/bin/tnslsnr LISTENER_SCAN3 -inherit
3 31268 31268 grid /u01/app/11.2.0/grid/bin/tnslsnr LISTENER -inherit
--//nlwp等於對應執行緒的數量.
$ ps -o nlwp,pid,lwp,user,args -u oracle | awk '$1>1 { print $0}'
NLWP PID LWP USER COMMAND
16 15415 15415 oracle /u01/app/11.2.0/grid/bin/oraagent.bin
--//奇怪怎麼兩個使用者oracle,grid下都有這個程式執行.
--//在測試環境檢視:
$ ps -o nlwp,pid,lwp,args -e | awk '$1>1 { print $0}'
NLWP PID LWP COMMAND
2 4049 4049 auditd
2 4051 4051 /sbin/audispd
5 4384 4384 automount --pid-file /var/run/autofs.pid
6 9290 9290 /sbin/rsyslogd -i /var/run/rsyslogd.pid -c3 -x
3 44997 44997 /u01/app/oracle/product/11.2.0.4/dbhome_1/bin/tnslsnr LISTENER -inherit
--//如果要想顯示全部執行緒,可以加入-L引數加上grep過濾就可以得到程式號.
$ ps -eLf | grep "tnslsn[r]"
oracle 44997 1 44997 0 3 Mar20 ? 00:10:23 /u01/app/oracle/product/11.2.0.4/dbhome_1/bin/tnslsnr LISTENER -inherit
oracle 44997 1 44998 0 3 Mar20 ? 00:00:05 /u01/app/oracle/product/11.2.0.4/dbhome_1/bin/tnslsnr LISTENER -inherit
oracle 44997 1 44999 0 3 Mar20 ? 00:00:00 /u01/app/oracle/product/11.2.0.4/dbhome_1/bin/tnslsnr LISTENER -inherit
--//第5列3表示執行緒數量.
$ ps -eLf | grep "rsyslog[d]"
root 9290 1 9290 0 6 2021 ? 00:00:00 /sbin/rsyslogd -i /var/run/rsyslogd.pid -c3 -x
root 9290 1 33554 0 6 Mar11 ? 00:00:00 /sbin/rsyslogd -i /var/run/rsyslogd.pid -c3 -x
root 9290 1 33555 0 6 Mar11 ? 00:00:01 /sbin/rsyslogd -i /var/run/rsyslogd.pid -c3 -x
root 9290 1 33556 0 6 Mar11 ? 00:00:23 /sbin/rsyslogd -i /var/run/rsyslogd.pid -c3 -x
root 9290 1 33557 0 6 Mar11 ? 00:00:00 /sbin/rsyslogd -i /var/run/rsyslogd.pid -c3 -x
root 9290 1 3272 0 6 10:35 ? 00:00:00 /sbin/rsyslogd -i /var/run/rsyslogd.pid -c3 -x
--//還可以執行如下:
$ ps -Lfp 44997
UID PID PPID LWP C NLWP STIME TTY TIME CMD
oracle 44997 1 44997 0 3 Mar20 ? 00:10:24 /u01/app/oracle/product/11.2.0.4/dbhome_1/bin/tnslsnr LISTENER -inherit
oracle 44997 1 44998 0 3 Mar20 ? 00:00:12 /u01/app/oracle/product/11.2.0.4/dbhome_1/bin/tnslsnr LISTENER -inherit
oracle 44997 1 44999 0 3 Mar20 ? 00:00:00 /u01/app/oracle/product/11.2.0.4/dbhome_1/bin/tnslsnr LISTENER -inherit
--//透過pstack觀察.
$ pstack 44997
Thread 3 (Thread 0x7f23ea92c940 (LWP 44998)):
#0 0x000000379909a221 in nanosleep () from /lib64/libc.so.6
#1 0x000000379909a044 in sleep () from /lib64/libc.so.6
#2 0x00007f23ebe1398a in ons_receivethread () from /u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libons.so
#3 0x000000379a00683d in start_thread () from /lib64/libpthread.so.0
#4 0x00000037990d503d in clone () from /lib64/libc.so.6
Thread 2 (Thread 0x7f23ea8eb940 (LWP 44999)):
#0 0x000000379a00b019 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
#1 0x00007f23ebe13289 in ons_recvthread_getsocket () from /u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libons.so
#2 0x00007f23ebe14ef2 in ons_sendthread () from /u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libons.so
#3 0x000000379a00683d in start_thread () from /lib64/libpthread.so.0
#4 0x00000037990d503d in clone () from /lib64/libc.so.6
Thread 1 (Thread 0x7f23ebc096e0 (LWP 44997)):
#0 0x00000037990cc116 in poll () from /lib64/libc.so.6
#1 0x00007f23ee3a62bd in ntevpque () from /u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libclntsh.so.11.1
#2 0x00007f23ee3a5f20 in ntevque () from /u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libclntsh.so.11.1
#3 0x00007f23ee3a1d71 in nsevwait () from /u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libclntsh.so.11.1
#4 0x000000000040842e in nsglma ()
#5 0x00000000004063cb in main ()
--//如果檢視執行緒執行如下.
$ pstack 44998
Thread 1 (process 44998):
#0 0x000000379909a221 in nanosleep () from /lib64/libc.so.6
#1 0x000000379909a044 in sleep () from /lib64/libc.so.6
#2 0x00007f23ebe1398a in ons_receivethread () from /u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libons.so
#3 0x000000379a00683d in start_thread () from /lib64/libpthread.so.0
#4 0x00000037990d503d in clone () from /lib64/libc.so.6
--//缺點不知道程式號.
--//另外執行緒有1個特點,如果你kill其中1個執行緒,整個程式也會kill掉,測試看看.
$ kill -URG 44998
$ ps -Lfp 44997
UID PID PPID LWP C NLWP STIME TTY TIME CMD
oracle 44997 1 44997 0 3 Mar20 ? 00:10:24 /u01/app/oracle/product/11.2.0.4/dbhome_1/bin/tnslsnr LISTENER -inherit
oracle 44997 1 44998 0 3 Mar20 ? 00:00:12 /u01/app/oracle/product/11.2.0.4/dbhome_1/bin/tnslsnr LISTENER -inherit
oracle 44997 1 44999 0 3 Mar20 ? 00:00:00 /u01/app/oracle/product/11.2.0.4/dbhome_1/bin/tnslsnr LISTENER -inherit
$ kill -9 44998
$ ps -Lfp 4499
UID PID PPID LWP C NLWP STIME TTY TIME CMD
$ ps -eLf | grep "tnslsn[r]"
--//沒有任何輸出.
$ lsnrctl start
....
$ ps -eLf | grep "tnslsn[r]"
oracle 34299 1 34299 0 3 10:07 ? 00:00:00 /u01/app/oracle/product/11.2.0.4/dbhome_1/bin/tnslsnr LISTENER -inherit
oracle 34299 1 34300 0 3 10:07 ? 00:00:00 /u01/app/oracle/product/11.2.0.4/dbhome_1/bin/tnslsnr LISTENER -inherit
oracle 34299 1 34301 0 3 10:07 ? 00:00:00 /u01/app/oracle/product/11.2.0.4/dbhome_1/bin/tnslsnr LISTENER -inherit
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2941980/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- adbshelldumpsys命令檢視記憶體記憶體
- Linux中常用來檢視程式的命令PSLinux
- Linux ps命令詳解,Linux檢視程序。Linux
- Linux基礎命令---lpstat檢視列印任務Linux
- Linux程式之如何檢視程式詳情?(ps命令)Linux
- Linux檢視程序命令ps和top示例詳解Linux
- oracleasm命令檢視OracleASM
- centos 檢視硬碟命令CentOS硬碟
- mysql狀態檢視 QPSTPS快取命中率檢視MySql快取
- mysql狀態檢視 QPS/TPS/快取命中率檢視MySql快取
- centos 檢視命令原始碼CentOS原始碼
- git檢視歷史命令Git
- Oracle物化檢視及SnapshotOracle
- Oracle中檢視sql命令歷史,檢視rman命令歷史OracleSQL
- 每天一個Linux命令之ps-檢視系統程式資訊Linux
- docker檢視容器日誌命令Docker
- linux檢視裝置命令Linux
- Linux 系統檢視命令Linux
- kafka 0.11檢視offset命令Kafka
- windows檢視埠占用命令Windows
- aix系統檢視WWNN命令AI
- linux系統檢視命令Linux
- 檢視程序的啟動命令
- ps -ef 檢視正在活動的程式ps -ef |grep abc 檢視含有"abc"的活動程式 ps -ef |grep -v abc 檢視不含abc的活動程式
- Linux下使用ps命令來檢視Oracle DB以及EBS相關的程式LinuxOracle
- DB2 snapshot 管理檢視DB2
- Wireshark檢視https的通訊HTTP
- Eclipse 如何檢視jdk原始碼EclipseJDK原始碼
- 效能檢視 V$Session_LONGOPSSessionGo
- Linux檢視環境變數當前資訊和檢視命令Linux變數
- Oracle常用檢視錶結構命令Oracle
- GDB檢視記憶體(x 命令)記憶體
- 檢視hp小型機命令集
- 磁碟陣列檢視命令 RAID陣列AI
- Cmd命令 檢視埠被佔用
- navicat檢視mysql安裝位置命令MySql
- LINUX 檢視硬體配置命令Linux
- git檢視和操作commit命令GitMIT