Linux命令行工具——sar

2020-08-12  本文已影响0人  CokeCode

sar命令的用法如下:

sar [ options ] [ <interval> [ <count> ] ]

其中,intervalcount分别表示采样周期和采样数量,如:

sar -u 1 10

表示每秒采集一次CPU使用情况,采集10次。

darren@DESKTOP-PSPUMSB:~$ sar -u 1 10
Linux 4.19.104-microsoft-standard (DESKTOP-PSPUMSB)     08/12/20        _x86_64_        (4 CPU)

22:37:28        CPU     %user     %nice   %system   %iowait    %steal     %idle
22:37:29        all      0.00      0.00      0.25      0.00      0.00     99.75
22:37:30        all      0.00      0.00      0.00      0.00      0.00    100.00
22:37:31        all      0.00      0.00      0.00      0.00      0.00    100.00
22:37:32        all      0.00      0.00      0.25      0.00      0.00     99.75
22:37:33        all      0.00      0.00      0.00      0.00      0.00    100.00
22:37:34        all      0.00      0.00      0.00      0.00      0.00    100.00
22:37:35        all      0.00      0.00      0.25      0.00      0.00     99.75
22:37:36        all      0.00      0.00      0.00      0.00      0.00    100.00
22:37:37        all      0.00      0.00      0.25      0.00      0.00     99.75
22:37:38        all      0.00      0.00      0.00      0.00      0.00    100.00
Average:        all      0.00      0.00      0.10      0.00      0.00     99.90

常用选项有:

darren@DESKTOP-PSPUMSB:~$ sar -u 1 5
Linux 4.19.104-microsoft-standard (DESKTOP-PSPUMSB)     08/12/20        _x86_64_        (4 CPU)

22:41:53        CPU     %user     %nice   %system   %iowait    %steal     %idle
22:41:54        all      0.00      0.00      0.00      0.00      0.00    100.00
22:41:55        all      0.00      0.00      0.00      0.00      0.00    100.00
22:41:56        all      0.00      0.00      0.00      0.00      0.00    100.00
22:41:57        all      0.00      0.00      0.25      0.00      0.00     99.75
22:41:58        all      0.00      0.00      0.00      0.00      0.00    100.00
Average:        all      0.00      0.00      0.05      0.00      0.00     99.95


darren@DESKTOP-PSPUMSB:~$ sar -d 1 3
Linux 4.19.104-microsoft-standard (DESKTOP-PSPUMSB)     08/12/20        _x86_64_        (4 CPU)

22:42:23          DEV       tps     rkB/s     wkB/s   areq-sz    aqu-sz     await     svctm     %util
22:42:24       dev8-0      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
22:42:24      dev8-16      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00

22:42:24          DEV       tps     rkB/s     wkB/s   areq-sz    aqu-sz     await     svctm     %util
22:42:25       dev8-0      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
22:42:25      dev8-16      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00

22:42:25          DEV       tps     rkB/s     wkB/s   areq-sz    aqu-sz     await     svctm     %util
22:42:26       dev8-0      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
22:42:26      dev8-16      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00

Average:          DEV       tps     rkB/s     wkB/s   areq-sz    aqu-sz     await     svctm     %util
Average:       dev8-0      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
Average:      dev8-16      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00


darren@DESKTOP-PSPUMSB:~$ sar -b 1 3
Linux 4.19.104-microsoft-standard (DESKTOP-PSPUMSB)     08/12/20        _x86_64_        (4 CPU)

22:42:44          tps      rtps      wtps   bread/s   bwrtn/s
22:42:45         0.00      0.00      0.00      0.00      0.00
22:42:46         0.00      0.00      0.00      0.00      0.00
22:42:47         0.00      0.00      0.00      0.00      0.00
Average:         0.00      0.00      0.00      0.00      0.00


darren@DESKTOP-PSPUMSB:~$ sar -r 1 3
Linux 4.19.104-microsoft-standard (DESKTOP-PSPUMSB)     08/12/20        _x86_64_        (4 CPU)

22:43:02    kbmemfree   kbavail kbmemused  %memused kbbuffers  kbcached  kbcommit   %commit  kbactive   kbinact   kbdirty
22:43:03      6146888   6151988    287960      4.48     12200    192500       472      0.01    152816     57160         0
22:43:04      6146888   6151988    287960      4.48     12200    192500       472      0.01    152816     57160         0
22:43:05      6146888   6151988    287960      4.48     12200    192500       472      0.01    152816     57160         0
Average:      6146888   6151988    287960      4.48     12200    192500       472      0.01    152816     57160         0


darren@DESKTOP-PSPUMSB:~$ sar -q 1 3
Linux 4.19.104-microsoft-standard (DESKTOP-PSPUMSB)     08/12/20        _x86_64_        (4 CPU)

22:43:22      runq-sz  plist-sz   ldavg-1   ldavg-5  ldavg-15   blocked
22:43:23            0        83      0.00      0.00      0.00         0
22:43:24            0        83      0.00      0.00      0.00         0
22:43:25            0        83      0.00      0.00      0.00         0
Average:            0        83      0.00      0.00      0.00         0
上一篇下一篇

猜你喜欢

热点阅读