You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-c, --count <num> set the thread count to show, default is 5.
91
95
-a, --append-file <file> specifies the file to append output as log.
92
-
-S, --jstack-file-dir <path> specifies the directory for storing jstack output files, and keep files.
93
-
default store jstack output files at tmp dir, and auto remove after run.
94
-
use this option to keep files so as to review jstack later.
96
+
-S, --store-dir <path> specifies the directory for storing intermediate files, and keep files.
97
+
default store intermediate files at tmp dir, and auto remove after run.
98
+
use this option to keep files so as to review jstack/top/ps output later.
95
99
delay the delay between updates in seconds.
96
100
count the number of updates.
97
101
delay/count arguments imitates the style of vmstat command.
@@ -132,7 +136,7 @@ uname | grep '^Linux' -q || fatal "Error: $PROG only support Linux, not support
132
136
# NOTE: ARGS can not be declared as readonly!!
133
137
# readonly declaration make exit code of assignment to be always 0, aka. the exit code of `getopt` in subshell is discarded.
134
138
# tested on bash 4.2.46
135
-
ARGS=`getopt -n "$PROG" -a -o p:c:a:s:S:Pd:Fmlh -l count:,pid:,append-file:,jstack-path:,jstack-file-dir:,use-ps,top-delay:,force,mix-native-frames,lock-info,help -- "$@"`
139
+
ARGS=`getopt -n "$PROG" -a -o p:c:a:s:S:Pd:Fmlh -l count:,pid:,append-file:,jstack-path:,store-dir:,use-ps,top-delay:,force,mix-native-frames,lock-info,help -- "$@"`
136
140
[ $?-ne 0 ] && { echo; usage 1; }
137
141
evalset -- "${ARGS}"
138
142
@@ -154,8 +158,8 @@ while true; do
154
158
jstack_path="$2"
155
159
shift 2
156
160
;;
157
-
-S|--jstack-file-dir)
158
-
jstack_file_dir="$2"
161
+
-S|--store-dir)
162
+
store_dir="$2"
159
163
shift 2
160
164
;;
161
165
-P|--use-ps)
@@ -208,18 +212,18 @@ if [ -n "$append_file" ]; then
208
212
[ !-d"$append_file_dir" ] && fatal "Error: directory $append_file_dir(specified by option -a, for storing run output files) exists but is not a directory!"
209
213
[ !-w"$append_file_dir" ] && fatal "Error: directory $append_file_dir(specified by option -a, for storing run output files) exists but is not writable!"
210
214
else
211
-
mkdir -p "$append_file_dir"&& fatal "Error: fail to create directory $append_file_dir(specified by option -a, for storing run output files)!"
215
+
mkdir -p "$append_file_dir"|| fatal "Error: fail to create directory $append_file_dir(specified by option -a, for storing run output files)!"
212
216
fi
213
217
fi
214
218
fi
215
219
216
-
# check jstack-file directory(-S) mode, create directory if not exsit.
217
-
if [ -n"$jstack_file_dir" ];then
218
-
if [ -e"$jstack_file_dir" ];then
219
-
[ !-d"$jstack_file_dir" ] && fatal "Error: $jstack_file_dir(specified by option -S, for storing jstack output files) exists but is not a directory!"
220
-
[ !-w"$jstack_file_dir" ] && fatal "Error: directory $jstack_file_dir(specified by option -S, for storing jstack output files) exists but is not writable!"
220
+
# check store directory(-S) mode, create directory if not exsit.
221
+
if [ -n"$store_dir" ];then
222
+
if [ -e"$store_dir" ];then
223
+
[ !-d"$store_dir" ] && fatal "Error: $store_dir(specified by option -S, for storing output files) exists but is not a directory!"
224
+
[ !-w"$store_dir" ] && fatal "Error: directory $store_dir(specified by option -S, for storing output files) exists but is not writable!"
221
225
else
222
-
mkdir -p "$jstack_file_dir"&& fatal "Error: fail to create directory $jstack_file_dir(specified by option -S, for storing jstack output files)!"
226
+
mkdir -p "$store_dir"|| fatal "Error: fail to create directory $store_dir(specified by option -S, for storing output files)!"
0 commit comments