温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Linux系统如何使用Dstat综合性能诊断

发布时间:2022-01-25 09:20:40 来源:亿速云 阅读:114 作者:小新 栏目:开发技术

这篇文章主要为大家展示了“Linux系统如何使用Dstat综合性能诊断”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“Linux系统如何使用Dstat综合性能诊断”这篇文章吧。

Linux系统管理员工作的重点就是对系统进行性能测试、评估和优化,使用Dstat可以对系统进行快速性能检查,还可以查看虚拟内存网络连接和接口CPU活动。

Linux系统如何使用Dstat综合性能诊断

Dstat选项和默认值

首先,让我们从一个相当简单的命令开始。 使用dstat -c(CPU)选项,dstat显示CPU统计信息。 在下面的示例中,我们要求两秒间隔和六个报告

linuxidc@linuxidc:~/www.linuxidc.com/Linux公社$ dstat -c 2 6–total-cpu-usage–usr sys idl wai stl 4 2 94 0 0 29 6 65 0 0 26 14 60 0 0 48 13 39 0 0 68 20 13 0 0 38 10 52 1 0

Linux系统如何使用Dstat综合性能诊断

请注意,此报告中的第一行数据看起来与其他数据非常不同,它们为您提供自系统上次引导以来的平均值,并且无论指定的时间间隔如何立即返回。 在这个例子中,我们看到系统平均空闲(96%),但现在在用户和系统处理任务之间忙着工作

如果您没有为dstat提供任何选项,该命令将使用默认设置(-cdngy)选项集。 这些包括:

  • c – cpu

  • d – 磁盘

  • n – 网络

  • g – 分页统计

  • y – 系统统计数据

此命令的输出将类似于您在下面看到的内容。

linuxidc@linuxidc:~/www.linuxidc.com/Linux公社$ dstat 2 10You did not select any stats, using -cdngy by default.–total-cpu-usage– -dsk/total- -net/total- —paging– —system–usr sys idl wai stl| read writ| recv send| in out | int csw 4 2 94 0 0| 220k 216k| 0  0 |4407B 27k| 129 662 28 6 66 0 0| 0  0 | 0  0 | 0  0 | 431 1184 50 17 33 0 0|2048B 12k| 0 193B|2048B  0 | 430 1507 33 8 59 0 0| 0  0 | 0  0 | 0  0 | 440 1324 31 11 58 0 0|2048B  0 | 0  0 | 0  0 | 410 1373 26 4 69 1 0|4096B 28k| 0  0 | 0  0 | 354 1074 63 34 4 0 0| 0 128k| 90B  0 | 0  0 | 302 2154 32 10 58 0 0| 0 152k| 60B  0 | 0  0 | 402 1508 16 14 69 0 0| 0  0 | 75B 45B| 0  0 | 495 1763 15 6 79 0 0| 0  70k| 90B  0 | 0  0 | 263 931

Linux系统如何使用Dstat综合性能诊断

您可能已经注意到上面显示的输出顶部附近的“您没有选择任何统计信息”消息。 要轻松解决这个问题,只需添加-a选项即可。 它将选择默认选项并省略警告消息。

linuxidc@linuxidc:~/www.linuxidc.com/Linux公社$ dstat -a 2 5–total-cpu-usage– -dsk/total- -net/total- —paging– —system–usr sys idl wai stl| read writ| recv send| in out | int csw 4 2 94 0 0| 218k 215k| 0  0 |4386B 26k| 130 663 8 5 88 0 0| 0  24k| 30B  0 | 0  0 | 229 724 27 5 68 0 0| 0  0 | 60B  0 | 0  0 | 372 993 26 5 68 0 0| 0  0 | 60B  0 | 0  0 | 478 1410 32 8 60 0 0| 0  0 | 30B  0 | 0  0 | 453 1585

Linux系统如何使用Dstat综合性能诊断

在这种“无选项”方法中,您仍然可以设置每个时间间隔的时间(以秒为单位)以及要查看的时间间隔数。 如果未指定间隔数,则命令将继续运行,直到您使用^ c停止它。

告诉你什么?

在上面显示的输出中,我们看到了被查询的系统相当繁忙证据。 没有报告空闲时间; CPU将所有时间都花在用户和系统任务之间。 将此与报告进行比较,报告显示系统闲置的时间是一半。

linuxidc@linuxidc:~/www.linuxidc.com/Linux公社$ dstat -a 2–total-cpu-usage– -dsk/total- -net/total- —paging– —system–usr sys idl wai stl| read writ| recv send| in out | int csw 4 2 94 0 0| 218k 215k| 0  0 |4369B 26k| 130 661 16 7 77 0 0| 0  26k| 0  0 | 0  0 | 325 1159 13 3 84 0 0|2048B 6144B| 0  0 |2048B  0 | 215 515 64 13 23 0 0|2048B 10k| 0  0 |2048B  0 | 388 1576 32 9 59 0 0| 0  0 | 0  0 | 0  0 | 496 1414

Linux系统如何使用Dstat综合性能诊断

另一方面,磁盘一点也不繁忙,读写为零。

要想熟练地评估系统性能,一个关键就是定期运行这些命令——即使你不知道有必要质疑系统运行得有多好。如果您了解了服务器的正常性能,您将更容易发现问题。

这是另一个例子,这个有一些磁盘活动:

linuxidc@linuxidc:~/www.linuxidc.com/Linux公社$ dstat -a 2 5–total-cpu-usage– -dsk/total- -net/total- —paging– —system–usr sys idl wai stl| read writ| recv send| in out | int csw 4 2 94 0 0| 214k 211k| 0  0 |4293B 26k| 130 656 9 6 85 0 0|6144B  0 | 0  0 | 0  0 | 218 752 6 2 92 0 0| 0  20k| 30B  0 | 0  0 | 141 355 3 2 95 0 0| 0  0 | 60B  0 | 0  0 | 79 212 2 1 97 0 0| 0  0 | 60B  0 | 0  0 | 72 194

Linux系统如何使用Dstat综合性能诊断

在所有这些示例中,我们没有看到任何分页(将可执行映像加载到进程的虚拟内存中)活动。 有一个相当恒定的中断和上下文切换正在进行,但数字都非常适度。

在下面的命令中,我们正在查看内存使用情况报告。 请注意与正在使用的内存相比的可用内存量。 这个系统没有受到挑战。

linuxidc@linuxidc:~/www.linuxidc.com/Linux公社$ dstat -m 2 3——memory-usage—– used free buff cach1389M 752M 69.1M 643M1389M 752M 69.1M 643M1389M 752M 69.1M 643M

Linux系统如何使用Dstat综合性能诊断

下一个命令中,我们正在查看高级内存使用情况报告。 提供了一些额外的内存统计信息

linuxidc@linuxidc:~/www.linuxidc.com/Linux公社$ dstat –mem-adv————-advanced-memory-usage————-total used free buff cach dirty shmem recl2912M 1392M 748M 69.3M 644M 32.0k 14.4M 71.8M2912M 1392M 748M 69.3M 644M 32.0k 14.4M 71.8M2912M 1392M 748M 69.3M 644M 44.0k 14.4M 71.8M2912M 1392M 748M 69.3M 644M 44.0k 14.4M 71.8M2912M 1392M 749M 69.3M 644M 44.0k 14.4M 71.8M2912M 1391M 750M 69.3M 644M 44.0k 14.4M 71.8M2912M 1391M 750M 69.3M 644M 44.0k 14.4M 71.8M2912M 1391M 750M 69.3M 644M 44.0k 14.4M 71.8M

Linux系统如何使用Dstat综合性能诊断

在下一个命令中,我们正在查看正在使用的打开文件和inode。

linuxidc@linuxidc:~/www.linuxidc.com/Linux公社$ dstat –fs–filesystem-files inodes10848 3696410848 3696410848 3696410848 3696410848 3696410848 36964

Linux系统如何使用Dstat综合性能诊断

在最后一个示例中,我们生成标准报告,但添加了一个。 我们还将报告写入.csv文件,以便可以在其他工具(如Excel)中使用。

linuxidc@linuxidc:~/www.linuxidc.com/Linux公社$ dstat –output /tmp/stats.csv -a 2 5–total-cpu-usage– -dsk/total- -net/total- —paging– —system–usr sys idl wai stl| read writ| recv send| in out | int csw 4 2 94 0 0| 209k 207k| 0  0 |4229B 25k| 130 653 20 7 73 0 0| 0  0 | 0  0 | 0  0 | 359 1001 15 5 80 0 0| 0  16k| 0  0 | 0  0 | 222 744 3 1 96 0 0| 0  0 | 0  0 | 0  0 | 93 270 1 2 96 1 0| 0 6144B| 0  0 | 0  0 | 80 243

Linux系统如何使用Dstat综合性能诊断

这是csv文件的样例:

linuxidc@linuxidc:~/www.linuxidc.com/Linux公社$ cat /tmp/stats.csv“Dstat 0.7.3 CSV output”“Author:”,”Dag Wieers dag@wieers.com”,,,,”URL:”,”http://dag.wieers.com/home-made/dstat/“Host:”,”linuxidc”,,,,”User:”,”linuxidc”“Cmdline:”,”dstat –output /tmp/stats.csv -a 2 5″,,,,”Date:”,”29 Dec 2018 17:11:59 CST”“total cpu usage”,,,,,”dsk/total”,,”net/total”,,”paging”,,”system”,“usr”,”sys”,”idl”,”wai”,”stl”,”read”,”writ”,”recv”,”send”,”in”,”out”,”int”,”csw”4.491,1.789,93.600,0.121,0,214501.354,212192.427,0,0,4229.474,25991.368,130.227,653.32120.207,6.736,73.057,0,0,0,0,0,0,0,0,359,1000.50015.464,4.639,79.897,0,0,0,16384,0,0,0,0,222,7443.046,1.015,95.939,0,0,0,0,0,0,0,0,92.500,269.5001.015,2.030,96.447,0.508,0,0,6144,0,0,0,0,79.500,242.500

Linux系统如何使用Dstat综合性能诊断

什么是dstat?

如前所述,dstat是一个很好的工具,可用于查看系统性能的所有方面。 但是这个问题的另一个答案它是一个Python脚本如果你想看看它是如何工作的,你可以自由地阅读它。

linuxidc@linuxidc:~/www.linuxidc.com/Linux公社公社 file /usr/bin/dstat/usr/bin/dstat: Python script, ASCII text executablelinuxidc@linuxidc:~/www.linuxidc.com/Linux公社$ more /usr/bin/dstat | head -6#!/usr/bin/env python2

### This program is free software; you can redistribute it and/or### modify it under the terms of the GNU General Public License### as published by the Free Software Foundation; either version 2### of the License, or (at your option) any later version.

Linux系统如何使用Dstat综合性能诊断

以上是“Linux系统如何使用Dstat综合性能诊断”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI