Syndicate
Site (RSS, Atom)
Contact
Weblog status
Total entries: 63
Last entry: 2018-10-15 16:31:39
Last updated: 2018-10-15 16:36:22
powered by vim, bash, cat, grep, sed, and nb 3.4.2

2018-10-01 00:20:33

threadcpu - show CPU usage of threads

threadcpu is a most simple Linux tool to measure CPU usage of threads in user% and system%. It tries to identify Java processes and if it detects a Java process it calls "jstack" for this process to get the NIDs/PIDs of its threads and also the names of the threads. This is the help page:

$ threadcpu -h

threadcpu shows CPU usage of threads in user% \
          and system%

usage:
threadcpu [-h] [-s seconds] [-p path-to-jstack]

options:
  -h display this help page
  -s measuring interval in seconds, default: 10
  -p path to JRE jstack, default: /usr/bin/jstack
example usage:
  threadcpu -s 30 -p /opt/java/bin/jstack \
            2>/dev/null|sort -n|tail -n 12
output columns:
  user percent  system percent  \
               PID/NID [  JVM thread \
               name OR (process name) ]

When a system has a higher load this tool can help you to detect the Java threads which are consuming most CPU times and thus maybe causing the load.

Here are some sample outputs:

$ threadcpu |sort -n|tail -n 8
3 0 33113 (klzagent)
3 0 38518 (klzagent)
3 0 9874 (BESClient)
3 41 6809 (threadcpu)
3 8 27353 VM Periodic Task Thread
6 0 31913 hybrisHTTP4
21 8 27347 C2 CompilerThread0
50 41 3244 (BESClient)

$ threadcpu |sort -n|tail -n 8
0 20 52358 (threadcpu)
0 40 32 (kswapd0)
2 50 2863 (BESClient)
11 0 31861 Gang worker#0 (Parallel CMS Threads)
11 0 31862 Gang worker#1 (Parallel CMS Threads)
11 0 31863 Gang worker#2 (Parallel CMS Threads)
11 0 31864 Gang worker#3 (Parallel CMS Threads)
47 10 31865 Concurrent Mark-Sweep GC Thread

$ threadcpu |sort -n|tail -n 8
2 0 14311 hybrisHTTP33
2 4 60077 ajp-bio-8009-exec-11609
2 8 30657 (klzagent)
4 0 5661 ajp-bio-8009-exec-11649
11 16 28144 (batchman)
15 20 3485 (BESClient)
21 0 7652 ajp-bio-8009-exec-11655
25 0 7611 ajp-bio-8009-exec-11654

You may also want to check the README or the man page. The download archive also contains a precompiled binary for Intel architecture:

threadcpu-20180930.tar.gz


Posted by Frank W. Bergmann | Permanent link | File under: c