File tree Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -316,21 +316,20 @@ __top_threadId_cpu() {
316316 # HOME="$tmp_store_dir" top -H -b -n 1 -o '%CPU'
317317 # 2. change HOME env var when run top,
318318 # so as to prevent top command output format being change by .toprc user config file unexpectedly
319- # 3. use option `-d 0.1 `(interval 0.1 second) and `-n 2`(show 2 times), and use second time update data
320- # to get cpu percentage of thread in 0.1 second interval
319+ # 3. use option `-d 0.5 `(interval 0.5 second) and `-n 2`(show 2 times), and use second time update data
320+ # to get cpu percentage of thread in 0.5 second interval
321321 HOME=" $tmp_store_dir " top -H -b -d $top_delay -n 2 |
322322 awk ' {
323- if (idx == 3 && $0 != "")
324- # only print 4th text block
325- # aka. process info of second top update
326- print
323+ if (idx == 3 && $NF == "java") # $NF is command
324+ # only print 4th text block(idx == 3)
325+ # aka. process info of second top update
326+ print $1 " " $9 # $1 is thread id, $9 is %cpu
327327 if($0 == "")
328328 idx++
329- }' |
330- awk ' $NF=="java"{print $1 " " $9}' | sort -k2,2nr
329+ }' | sort -k2,2nr
331330}
332331
333- # output is same as function findBusyJavaThreadsByPs
332+ # output format is same as function findBusyJavaThreadsByPs
334333findBusyJavaThreadsByTop () {
335334 if [ -n " ${pid} " ]; then
336335 local -r ps_options=" -p $pid "
You can’t perform that action at this time.
0 commit comments