
9.53 9.12 8.37 3/889 28165us:user,统计nice小于等于0的用户空间进程,也即优先级为100~120。ni:nice,统计nice大于0的用户空间进程,也即优先级为121~139。sys:system,统计内核态运行时间,不包括中断。id:idle,几系统处于空闲态。wa:iowait,统计io等待时间。hi:hardware interrupt,统计硬件中断时间。si:software interrupt,统计软中断时间。st:steal

# 将 ENABLED=“false“ 改为ENABLED=“true“$ sudo gedit /etc/default/sysstat# 修改sar的周期等配置$ sudo gedit /etc/cron.d/sysstat# 重启sar服务$ sudo /etc/init.d/sysstat restart# sar log存放目录$ ls -l /var/log/sysstat/LC_ALL=C sar -A > sar.txt
sar 1100-----------------所有cpu合一的统计信息sar -P ALL 1100--------包括cpu合一以及单个cpu的统计信息sar -B 1100---------------paging统计信息sar -b 1100---------------块设备IO统计信息sar -d 1100---------------块设备活动统计信息sar -F 1100----------------挂载的文件系统统计信息sar -r ALL------------------ 显示详细的内存使用统计信息sar -S ------------------------显示swap空间使用情况统计信息sar -w----------------------- 显示进程创建以及进程切换统计信息sar -W-----------------------显示swap换入换出统计信息。$ mpstat -P ALL 1020
11:15:41 up 82 days, 20:34, 8 users, load average: 0.28, 0.40, 0.43procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu----- r b swpd free buff cache si so bi bo in cs us sy id wa st104725762286885590921061756009391084870010472576228184559100106175600013153233951068400104725762293085591001061616000014463449105850000472576229592559108106161600061419347410585001047257622980455910810616160000144634391058500

# 显示所有的进程统计信息,包括idle进程。pidstat -p ALL# 更加详细的显示了线程统计信息。pidstat -p ALL -t# 周期采样和采样次数pidstat [option] interval [count]15时18分21秒 UID PID minflt/s majflt/s VSZ RSS %MEM Command15时18分21秒 010.020.0018531630280.08 systemd15时18分21秒 020.000.00000.00 kthreadd15时18分21秒 040.000.00000.00 kworker/0:0H15时18分21秒 060.000.00000.00 mm_percpu_wq15时18分21秒 070.000.00000.00 ksoftirqd/015时18分21秒 080.000.00000.00 rcu_sched15时20分40秒 UID PID kB_rd/s kB_wr/s kB_ccwr/s iodelay Command15时20分40秒 01 -1.00 -1.00 -1.00243523129 systemd15时20分40秒 02 -1.00 -1.00 -1.000 kthreadd15时20分40秒 04 -1.00 -1.00 -1.000 kworker/0:0H15时20分40秒 06 -1.00 -1.00 -1.000 mm_percpu_wq15时20分40秒 07 -1.00 -1.00 -1.00714512328679 ksoftirqd/015时20分40秒 08 -1.00 -1.00 -1.00417757303594 rcu_sched240194063832606752 nomachine_6.0.80_1.exe# 整个操作总耗时,0.263-0.094-0.011=0.158是IO等待耗时。real 0m0.263s# 用户态耗时user 0m0.094s# 内核态耗时sys 0m0.011s240194063832606752 nomachine_6.0.80_1.exe# 第二次执行就可以看出等待IO操作的时间基本上没有了。real 0m0.098suser 0m0.097ssys 0m0.000s# 显示Load Avg信息和平均频率等LoadAvg0.660.540.49, FreqAvg. 1.46GHz, 4CPUs online# 进程切换次数、硬中断、软中断等等统计信息。# CPU占用率、用户空间和内核空间占用率等。3791.1Ctxt/s, 1709.9 IRQ/s, 1800.0 softIRQ/s, 0.0new tasks/s, 1 running, 0 blocked %CPU %USR %SYS PID S CPU TimeTask25.7425.740.0011435 R 32.29w /usr/bin/python315.8415.840.009445 S 01.49w /usr/lib/xorg/Xorg10.899.900.992722 S 11.05w compiz7.920.007.9232352 S 216.60s [kworker/2:1]0.990.000.9932397 R 10.01s cpustat0.990.990.0011046 S 216.20h compiz0.990.990.001317 S 08.76h /usr/NX/bin/nxnode.bin0.990.000.9910293 S 11.24m [kworker/1:2]64.3653.4710.89TotalLoadAvg0.660.540.49, FreqAvg. 1.75GHz, 4CPUs online2834.8Ctxt/s, 1190.9 IRQ/s, 1183.3 softIRQ/s, 0.0new tasks/s, 4 running, 0 blocked %CPU %USR %SYS PID S CPU TimeTask25.7625.760.0011435 R 32.29w /usr/bin/python318.1818.180.009445 S 01.49w /usr/lib/xorg/Xorg7.587.580.002722 S 11.05w compiz6.060.006.0632352 S 216.64s [kworker/2:1]1.520.001.5232397 R 10.02s cpustat1.520.001.528 S 03.00h [rcu_sched]1.520.001.5218409 S 01.16m update-notifier62.1251.5210.61TotalDistribution of CPU utilisation (per Task):% CPU UtilisationCount (%)0.00 - 1.9770698.881.97 - 3.9400.003.94 - 5.9100.005.91 - 7.8820.287.88 - 9.8500.009.85 - 11.8200.0011.82 - 13.7910.1413.79 - 15.7600.0015.76 - 17.7310.1417.73 - 19.7010.1419.70 - 21.6700.0021.67 - 23.6400.0023.64 - 25.6120.2825.61 - 27.5700.0027.58 - 29.5400.0029.55 - 31.5100.0031.52 - 33.4800.0033.48 - 35.4500.0035.45 - 37.4200.0037.42 - 39.3910.14Distribution of CPU utilisation (per CPU):----------------------------------------------各CPU占用率,分用户空间和内核空间。 CPU# USR% SYS%017.371.2018.982.4020.607.19325.750.00



$ sudo apt install pcp pcp-gui
sudo apt-get install collectl
b – buddy info (内存碎片)c – 所有CPU的合一统计信息;C - 单个CPU的统计信息。d – 整个文件系统Disk合一统计信息;C - 单个磁盘的统计信息。f – NFS V3 Datai – InodeandFileSystemj – 显示每个CPU的Interrupts触发情况;J - 显示每个中断详细触发情况。l – Lustrem – 显示整个系统Memory使用情况;M - 按node显示内存使用情况。n – 显示整个系统的Networks使用情况;N - 分网卡显示网络使用情况。s – Socketst – TCPx – Interconnecty – 对系统所有Slabs (系统对象缓存)使用统计信息;Y - 每个slab使用的详细信息。


$suod systemctl reload apache2$ sudo systemctl restart apache2

[1] /proc/stat: https://www.cnblogs.com/arnoldlu/p/9187775.html#system_proc_stat[2] /proc//stat: https://www.cnblogs.com/arnoldlu/p/9187775.html#process_proc_stat[3] 系统级性能分析工具perf的介绍与使用: https://www.cnblogs.com/arnoldlu/p/6241297.html[4] ksar: https://sourceforge.net/projects/ksar/[5] How To Create sar Graphs With kSar To Identifying Linux Bottlenecks: https://www.cyberciti.biz/tips/identifying-linux-bottlenecks-sar-graphs-with-ksar.html[6] Collect and report Linux System Activity Information with sar: https://www.thomas-krenn.com/en/wiki/Collect_and_report_Linux_System_Activity_Information_with_sar[7] Linux Performance Measurements using vmstat: https://www.thomas-krenn.com/en/wiki/Linux_Performance_Measurements_using_vmstat[8] Collectl: Linux 性能监控的全能冠军: https://linux.cn/article-3154-1.html[9] Collectl Documentation: http://collectl.sourceforge.net/Documentation.html[10] Collectl Examples - An Awesome Performance Analysis Tool in Linux: https://linoxide.com/monitoring-2/collectl-tool-install-examples/


认准红帽官方授权
微思-红帽官方授权合作伙伴!


— Linux文章推荐 —






