# 帮助信息 $ show-busy-java-threads -h Usage: show-busy-java-threads [OPTION]... [delay [count]] Find out the highest cpu consumed threads of java processes, and print the stack of these threads.
Example: show-busy-java-threads # show busy java threads info show-busy-java-threads 1 # update every 1 second, (stop by eg: CTRL+C) show-busy-java-threads 3 10 # update every 3 seconds, update 10 times
Output control: -p, --pid <java pid> find out the highest cpu consumed threads from the specified java process. default from all java process. -c, --count <num> set the thread count to show, default is 5. set count 0 to show all threads. -a, --append-file <file> specifies the file to append output as log. -S, --store-dir <dir> specifies the directory for storing the intermediate files, and keep files. default store intermediate files at tmp dir, and auto remove after run. use this option to keep files so as to review jstack/top/ps output later. delay the delay between updates in seconds. count the number of updates. delay/count arguments imitates the style of vmstat command.
jstack control: -s, --jstack-path <path> specifies the path of jstack command. -F, --force set jstack to force a thread dump. use when jstack does not respond (process is hung). -m, --mix-native-frames set jstack to print both java and native frames (mixed mode). -l, --lock-info set jstack with long listing. prints additional information about locks.
CPU usage calculation control: -d, --top-delay specifies the delay between top samples. default is 0.5 (second). get thread cpu percentage during this delay interval. more info see top -d option. eg: -d 1 (1 second). -P, --use-ps use ps command to find busy thread(cpu usage) instead of top command. default use top command, because cpu usage of ps command is expressed as the percentage of time spent running during the *entire lifetime* of a process, this is not ideal in general.
Miscellaneous: -h, --help display this help and exit.
$ show-busy-java-threads [1] Busy(57.0%) thread(23355/0x5b3b) stack of java process(23269) under user(admin): "pool-1-thread-1" prio=10 tid=0x000000005b5c5000 nid=0x5b3b runnable [0x000000004062c000] java.lang.Thread.State: RUNNABLE at java.text.DateFormat.format(DateFormat.java:316) at com.xxx.foo.services.common.DateFormatUtil.format(DateFormatUtil.java:41) at com.xxx.foo.shared.monitor.schedule.AppMonitorDataAvgScheduler.run(AppMonitorDataAvgScheduler.java:127) at com.xxx.foo.services.common.utils.AliTimer$2.run(AliTimer.java:128) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662)
[2] Busy(26.1%) thread(24018/0x5dd2) stack of java process(23269) under user(admin): "pool-1-thread-2" prio=10 tid=0x000000005a968800 nid=0x5dd2 runnable [0x00000000420e9000] java.lang.Thread.State: RUNNABLE at java.util.Arrays.copyOf(Arrays.java:2882) at java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:100) at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:572) at java.lang.StringBuffer.append(StringBuffer.java:320) - locked <0x00000007908d0030> (a java.lang.StringBuffer) at java.text.SimpleDateFormat.format(SimpleDateFormat.java:890) at java.text.SimpleDateFormat.format(SimpleDateFormat.java:869) at java.text.DateFormat.format(DateFormat.java:316) at com.xxx.foo.services.common.DateFormatUtil.format(DateFormatUtil.java:41) at com.xxx.foo.shared.monitor.schedule.AppMonitorDataAvgScheduler.run(AppMonitorDataAvgScheduler.java:126) at com.xxx.foo.services.common.utils.AliTimer$2.run(AliTimer.java:128) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662)
# 帮助信息 $ find-in-jars -h Usage: find-in-jars [OPTION]... PATTERN Find files in the jar files under specified directory, search jar files recursively(include subdirectory). The pattern default is *extended* regex.
Example: find-in-jars 'log4j\.properties' # search file log4j.properties/log4j.xml at zip root find-in-jars '^log4j\.(properties|xml)$' find-in-jars 'log4j\.properties$' -d /path/to/find/directory find-in-jars '\.properties$' -d /path/to/find/dir1 -d path/to/find/dir2 find-in-jars 'Service\.class$' -e jar -e zip find-in-jars 'Mon[^$/]*Service\.class$' -s ' <-> '
Find control: -d, --dir the directory that find jar files. default is current directory. this option can specify multiply times to find in multiply directories. -e, --extension set find file extension, default is jar. this option can specify multiply times to find multiply extension. -E, --extended-regexp PATTERN is an extended regular expression (*default*) -F, --fixed-strings PATTERN is a set of newline-separated strings -G, --basic-regexp PATTERN is a basic regular expression -P, --perl-regexp PATTERN is a Perl regular expression -i, --ignore-case ignore case distinctions
Output control: -a, --absolute-path always print absolute path of jar file -s, --separator specify the separator between jar file and zip entry. default is `!'. Miscellaneous: -h, --help display this help and exit