排序命令的简单用法

我想检查每个 CPU 内核的利用率, 所以我输入了 top 命令并按下 1, 但它不能不显示.

whth the warningSorry, terminal is not big enough

So I should use mpstat command , just input “mpstat -P 全部”, it can oupt utlization of each cups.

If I need to query real time utilization for 1000 times,interval is 2 秒.

mpstat -P 全部 2 1000

[root@rac02 ~]# mpstat -P 全部 2 1000

Linux 2.6.32-431.el6.x86_64 (rac02.itas.com.na) 08/16/2018 _x86_64_ (80 中央处理器)

09:07:53 AM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %idle

09:07:53 AM all 1.99 0.00 0.34 0.06 0.00 0.02 0.00 0.00 97.59

09:07:53 AM 0 11.57 0.00 1.28 1.35 0.00 0.27 0.00 0.00 85.52

09:07:53 AM 1 20.69 0.00 2.09 0.16 0.00 0.27 0.00 0.00 76.78

09:07:53 AM 2 8.83 0.00 1.30 0.08 0.00 0.00 0.00 0.00 89.79

09:07:53 AM 3 2.40 0.00 0.52 0.05 0.00 0.00 0.00 0.00 97.03

09:07:53 AM 4 2.43 0.00 0.17 0.03 0.00 0.00 0.00 0.00 97.37

09:07:53 AM 5 1.43 0.00 0.08 0.02 0.00 0.00 0.00 0.00 98.47

but I want to show utilization of %user by descending order.I can use

sort command. As shown in the following.

[root@rac02 ~]# mpstat -P 全部 | grep -v “的Linux” |排序-k4nr

09:11:51 AM 42 25.88 0.00 2.96 0.01 0.00 0.61 0.00 0.00 70.54

09:11:51 AM 1 20.70 0.00 2.09 0.16 0.00 0.27 0.00 0.00 76.78

09:11:51 AM 9 16.43 0.00 1.85 0.01 0.00 0.26 0.00 0.00 81.45

09:11:51 AM 40 14.72 0.00 1.82 0.11 0.00 0.15 0.00 0.00 83.20

09:11:51 AM 0 11.57 0.00 1.28 1.35 0.00 0.27 0.00 0.00 85.53

09:11:51 AM 46 8.85 0.00 0.81 0.83 0.00 0.12 0.00 0.00 89.39

 

排序-k4nr

-k4: oder by forth column. By default, each column is delimited by a space

If you want to delimit by other characters, use the -t: delimiter, 如

sort -k4nr-t: with a colon as the delimiter

ñ: order by number value

[R: decesending orader

 

发表评论