busybox-1-mpstat

一、简介

mpstat 可以看到所有CPU和每个CPU上的各种负载、所有CPU和总CPU每秒irq个数。各种软中断每秒触发次数。

busybox mpstat -A 显示所有支持的信息,若是想删减或简化显示,使用其它命令行选项。

使用方法:

/ # busybox mpstat --help
BusyBox v1.31.0 (2019-06-10 15:54:51 CEST) multi-call binary.

Usage: mpstat [-A] [-I SUM|CPU|ALL|SCPU] [-u] [-P num|ALL] [INTERVAL [COUNT]]

Per-processor statistics

        -A                      Same as -I ALL -u -P ALL
        -I SUM|CPU|ALL|SCPU     Report interrupt statistics
        -P num|ALL              Processor to monitor
        -u                      Report CPU utilization

 

二、使用例子

1. 打印所有内容

/ # busybox mpstat -A
Linux 6.1.115-android14-11-maybe-dirty (localhost)      04/18/25        _aarch64_       (8 CPU)

05:51:58     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle //显示总的和每CPU的
05:51:58     all   19.89    3.33   40.74    0.29    4.28    0.76    0.00    0.00   30.70
05:51:58       0   12.99    2.11   36.16    0.25   11.00    0.76    0.00    0.00   36.72
05:51:58       1   14.91    2.33   40.83    0.20    5.23    0.74    0.00    0.00   35.76
05:51:58       2   14.69    2.31   38.77    0.29    5.36    0.77    0.00    0.00   37.82
05:51:58       3   15.64    2.72   37.06    0.35    5.14    0.73    0.00    0.00   38.37
05:51:58       4   26.75    2.72   51.47    0.32    1.73    0.58    0.00    0.00   16.43
05:51:58       5   22.09    3.07   40.03    0.32    1.84    0.71    0.00    0.00   31.94
05:51:58       6   24.30    3.39   39.57    0.40    1.67    1.26    0.00    0.00   29.42
05:51:58       7   26.96    7.79   41.76    0.17    2.59    0.54    0.00    0.00   20.19

05:51:58     CPU    intr/s
05:51:58     all  14642.39
05:51:58       0   3643.96
05:51:58       1   2047.62
05:51:58       2   2137.41
05:51:58       3   2183.16
05:51:58       4   1014.02
05:51:58       5   1141.62
05:51:58       6   1052.24
05:51:58       7   1337.20

...

05:51:58     CPU      HI/s   TIMER/s  NET_TX/s  NET_RX/s   BLOCK/s IRQ_POLL/s TASKLET/s  SCHED/s HRTIMER/s     RCU/s
05:51:58       0      0.00     44.56      0.00      0.59     15.28      0.00      0.00    129.30      0.00    183.13
05:51:58       1      0.00     28.09      0.00      0.43     11.81      0.00      0.00    112.57      0.00    175.70
05:51:58       2      0.00     27.41      0.00      0.89     16.08      0.00      0.00    107.58      0.00    186.68
05:51:58       3      0.00     28.11      0.00      0.56     14.73      0.00      0.01    103.25      0.00    194.46
05:51:58       4      0.00     23.47      0.00      0.31      1.80      0.00      0.00     57.81      0.00    272.29
05:51:58       5      0.02     20.13      0.00      0.36     57.78      0.00      0.11     68.98      0.00    302.59
05:51:58       6      0.00     18.56      0.00     37.48      2.66      0.00      0.00     67.29      0.00    294.45
05:51:58       7      0.00     13.87      0.00     28.79     14.68      0.00      0.42     51.66      0.00    266.01

软中断的统计应该是通过 cat /proc/softirqs 来实现的。

 

三、补充

1. 若是单测某一个irq,可将其绑定到特定的CPU上(例如 /proc/irq/600 # echo 20 > smp_affinity),然后看这个CPU上的irq负载状态,判断是否是此irq异常。

 

posted on 2025-04-18 14:17  Hello-World3  阅读(31)  评论(0)    收藏  举报

导航