Skip to content

show-busy-java-threads#__top_threadId_cpu在top v3.2下提取不正确 #71

@geekMessi

Description

@geekMessi
HOME="$tmp_store_dir" top -H -b -d $top_delay -n 2 |
    awk '{
            if (idx == 3 && $NF == "java")    # $NF is command
                # only print 4th text block(idx == 3), aka. process info of second top update
                print $1 " " $9    # $1 is thread id, $9 is %cpu
            if ($0 == "")
                idx++
    }' | sort -k2,2nr

这部分逻辑是不是有些问题?为什么只抓4th? 执行了一下,没有输出
改成下面是OK的

HOME="$tmp_store_dir" top -H -b -d $top_delay -n 2 |
    awk '{
            if ($NF == "java")    # $NF is command
                # only print 4th text block(idx == 3), aka. process info of second top update
                print $1 " " $9    # $1 is thread id, $9 is %cpu
    }' | sort -k2,2nr

awk语句

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions