apt install sar
vim /etc/default/sysstat # 打开性能收集工具的开关
# 设置 ENABLED=”true”
/etc/init.d/sysstat start # 启动Sar来收集系统性能数据
是一个系统活动报告工具,既可以实时查看系统的当前活动,又可以配置保存和报告历史统计数据。sar是目前Linux上最为全面的系统性能分析工具之一,可以从14个大方面对系统的活动进行报告,包括文件的读写情况、系统调用的使用情况、串口、CPU效率、内存使用状况、进程活动及IPC有关的活动等,使用也是较为复杂。
sar -u 1 3
Linux 4.15.0-47-generic (ubuntu) 05/03/19 _x86_64_ (4 CPU)
09:19:03 CPU %user %nice %system %iowait %steal %idle
09:19:04 all 0.25 0.00 0.75 0.00 0.00 99.00
09:19:05 all 0.25 0.00 0.50 0.00 0.00 99.25
09:19:06 all 0.25 0.00 0.25 0.00 0.00 99.50
Average: all 0.25 0.00 0.50 0.00 0.00 99.25
sar -q 1 3
Linux 4.15.0-47-generic (ubuntu) 05/03/19 _x86_64_ (4 CPU)
09:19:52 runq-sz plist-sz ldavg-1 ldavg-5 ldavg-15 blocked
09:19:53 0 204 0.07 0.05 0.04 0
09:19:54 0 204 0.07 0.05 0.04 0
09:19:55 0 204 0.07 0.05 0.04 0
Average: 0 204 0.07 0.05 0.04 0
sar -r 1 3
Linux 4.15.0-47-generic (ubuntu) 05/03/19 _x86_64_ (4 CPU)
09:21:14 kbmemfree kbavail kbmemused %memused kbbuffers kbcached kbcommit %commit kbactive kbinact kbdirty
09:21:15 4932260 7430684 3071392 38.37 159248 2346044 762576 6.25 1175072 1470804 0
09:21:16 4932260 7430684 3071392 38.37 159248 2346044 762576 6.25 1175072 1470804 0
09:21:17 4932260 7430684 3071392 38.37 159248 2346044 762576 6.25 1175072 1470804 0
Average: 4932260 7430684 3071392 38.37 159248 2346044 762576 6.25 1175072 1470804 0
sar -W 1 3
Linux 4.15.0-47-generic (ubuntu) 05/03/19 _x86_64_ (4 CPU)
09:23:23 pswpin/s pswpout/s
09:23:24 0.00 0.00
09:23:25 0.00 0.00
09:23:26 0.00 0.00
Average: 0.00 0.00
sar -n DEV 1 1
Linux 4.15.0-47-generic (ubuntu) 05/03/19 _x86_64_ (4 CPU)
09:26:25 IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s %ifutil
09:26:26 docker0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
09:26:26 lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
09:26:26 eno1 10.00 5.00 0.67 2.74 0.00 0.00 1.00 0.02
09:26:26 wlp2s0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
原文:https://www.cnblogs.com/warrior/p/12617548.html