ps -T -p [pid] and top -H -p [pid] can only display the first 15 characters like http-nio-8080-e, but I would like to get the whole thread name like http-nio-8080-exec-9, What should I do? thank you!
for example:
[root@localhost ~]# ps -T -p 2251
PID SPID TTY TIME CMD
2251 2251 ? 00:00:00 java
2251 2808 ? 00:00:03 java
2251 2821 ? 00:00:00 VM Thread
2251 2822 ? 00:00:00 Reference Handl
2251 2823 ? 00:00:00 Finalizer
2251 2824 ? 00:00:00 Signal Dispatch
2251 2825 ? 00:00:02 C2 CompilerThre
2251 2832 ? 00:00:02 C1 CompilerThre
2251 2835 ? 00:00:00 Sweeper thread
2251 2851 ? 00:00:00 Service Thread
2251 2866 ? 00:00:00 VM Periodic Tas
2251 2867 ? 00:00:00 Common-Cleaner
2251 6518 ? 00:00:00 Catalina-utilit
2251 6520 ? 00:00:00 Catalina-utilit
2251 6531 ? 00:00:00 container-0
2251 7370 ? 00:00:00 NioBlockingSele
2251 7374 ? 00:00:00 http-nio-8080-e
2251 7375 ? 00:00:00 http-nio-8080-e
2251 7376 ? 00:00:00 http-nio-8080-e
2251 7377 ? 00:00:00 http-nio-8080-e
2251 7378 ? 00:00:00 http-nio-8080-e
2251 7379 ? 00:00:00 http-nio-8080-e
2251 7380 ? 00:00:00 http-nio-8080-e
2251 7381 ? 00:00:00 http-nio-8080-e
2251 7382 ? 00:00:00 http-nio-8080-e
2251 7383 ? 00:00:00 http-nio-8080-e
2251 7384 ? 00:00:00 http-nio-8080-C
2251 7395 ? 00:00:00 http-nio-8080-A
and
[root@localhost ~]# top -H -p 2251
top - 12:00:38 up 15 min, 1 user, load average: 0.06, 0.11, 0.19
Threads: 28 total, 0 running, 28 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 3880412 total, 2276824 free, 903836 used, 699752 buff/cache
KiB Swap: 1581052 total, 1581052 free, 0 used. 2745864 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
2251 root 20 0 3043676 152880 14232 S 0.0 3.9 0:00.07 java
2808 root 20 0 3043676 152880 14232 S 0.0 3.9 0:03.00 java
2821 root 20 0 3043676 152880 14232 S 0.0 3.9 0:00.27 VM Thread
2822 root 20 0 3043676 152880 14232 S 0.0 3.9 0:00.00 Reference Handl
2823 root 20 0 3043676 152880 14232 S 0.0 3.9 0:00.00 Finalizer
2824 root 20 0 3043676 152880 14232 S 0.0 3.9 0:00.00 Signal Dispatch
2825 root 20 0 3043676 152880 14232 S 0.0 3.9 0:02.76 C2 CompilerThre
2832 root 20 0 3043676 152880 14232 S 0.0 3.9 0:02.07 C1 CompilerThre
2835 root 20 0 3043676 152880 14232 S 0.0 3.9 0:00.01 Sweeper thread
2851 root 20 0 3043676 152880 14232 S 0.0 3.9 0:00.00 Service Thread
2866 root 20 0 3043676 152880 14232 S 0.0 3.9 0:00.74 VM Periodic Tas
2867 root 20 0 3043676 152880 14232 S 0.0 3.9 0:00.00 Common-Cleaner
6518 root 20 0 3043676 152880 14232 S 0.0 3.9 0:00.02 Catalina-utilit
6520 root 20 0 3043676 152880 14232 S 0.0 3.9 0:00.12 Catalina-utilit
6531 root 20 0 3043676 152880 14232 S 0.0 3.9 0:00.00 container-0
7370 root 20 0 3043676 152880 14232 S 0.0 3.9 0:00.05 NioBlockingSele
7374 root 20 0 3043676 152880 14232 S 0.0 3.9 0:00.14 http-nio-8080-e
7375 root 20 0 3043676 152880 14232 S 0.0 3.9 0:00.00 http-nio-8080-e
7376 root 20 0 3043676 152880 14232 S 0.0 3.9 0:00.03 http-nio-8080-e
7377 root 20 0 3043676 152880 14232 S 0.0 3.9 0:00.00 http-nio-8080-e
7378 root 20 0 3043676 152880 14232 S 0.0 3.9 0:00.00 http-nio-8080-e
7379 root 20 0 3043676 152880 14232 S 0.0 3.9 0:00.00 http-nio-8080-e
7380 root 20 0 3043676 152880 14232 S 0.0 3.9 0:00.00 http-nio-8080-e
7381 root 20 0 3043676 152880 14232 S 0.0 3.9 0:00.00 http-nio-8080-e
7382 root 20 0 3043676 152880 14232 S 0.0 3.9 0:00.00 http-nio-8080-e
7383 root 20 0 3043676 152880 14232 S 0.0 3.9 0:00.00 http-nio-8080-e
7384 root 20 0 3043676 152880 14232 S 0.0 3.9 0:00.06 http-nio-8080-C
7395 root 20 0 3043676 152880 14232 S 0.0 3.9 0:00.00 http-nio-8080-A
It can only display the first 15 characters like http-nio-8080-e, I would like to get the whole thread name like http-nio-8080-exec-9, What should I do?
"http-nio-8080-exec-9" #25 daemon prio=5 os_prio=0 cpu=0.13ms elapsed=1013.48s tid=0x00007fc0708d9000 nid=0x1f waiting on condition [0x00007fc0506b1000]
java.lang.Thread.State: WAITING (parking)
at jdk.internal.misc.Unsafe.park([email protected]/Native Method)
- parking to wait for <0x00000000c5c22c20> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.park([email protected]/LockSupport.java:194)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await([email protected]/AbstractQueuedSynchronizer.java:2081)
at java.util.concurrent.LinkedBlockingQueue.take([email protected]/LinkedBlockingQueue.java:433)
at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:107)
at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:33)
at java.util.concurrent.ThreadPoolExecutor.getTask([email protected]/ThreadPoolExecutor.java:1054)
at java.util.concurrent.ThreadPoolExecutor.runWorker([email protected]/ThreadPoolExecutor.java:1114)
at java.util.concurrent.ThreadPoolExecutor$Worker.run([email protected]/ThreadPoolExecutor.java:628)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run([email protected]/Thread.java:834)
The thread name length is restricted to 16 characters (including the terminating null byte \0). If the length, including the \0, exceeds 16 bytes, the string is silently truncated before storing it.
See pthread_setname_np and proc.5 -> find /proc/[pid]/task/[tid]/comm.
Related:
How to get the full executable name of a running process in Linux
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With