For example: to see all threads of non-root processes:

# ps -ef | awk '{ print $1 " " $2 }' | grep -v -E -e 'root' -e "PID" | while read user PID; do pstack "${PID}" | egrep -i "(${PID}|lwpid)" | sed -e 's,-*,,g'; done

Shows at the end of the output file:

2372:   /opt/wbem/lbin/cimservermain
  lwpid : 2958
  lwpid : 2964
  lwpid : 2965
  lwpid : 2966
  lwpid : 2967
  lwpid : 2971
  lwpid : 2994
  lwpid : 2997
  lwpid : 3000
  lwpid : 3003
  lwpid : 3008
  lwpid : 3011
  lwpid : 3015
  lwpid : 3018
  lwpid : 3021
  lwpid : 92273
  lwpid : 94498
  lwpid : 94499
  lwpid : 94500
  lwpid : 94501
  lwpid : 94502
  lwpid : 94503
  lwpid : 94504
11538:  /opt/oracle/product/11.2.0/db_1/bin/tnslsnr
  lwpid : 81921
  lwpid : 81922
  lwpid : 81923
8955:   /opt/psb/db/pgsql/bin/postmaster
  lwpid : 10204
2395:   /opt/psb/db/pgsql/bin/postmaster
  lwpid : 3065
2856:   /opt/psb/db/pgsql/bin/postmaster
...

Comments