{"id":2770,"date":"2019-03-10T20:28:40","date_gmt":"2019-03-10T12:28:40","guid":{"rendered":"http:\/\/www.liangliang.org.cn\/?p=2770"},"modified":"2023-08-23T17:47:07","modified_gmt":"2023-08-23T09:47:07","slug":"dstat%e5%91%bd%e4%bb%a4-%e6%80%a7%e8%83%bd%e7%9b%91%e6%b5%8b%e4%b8%8e%e4%bc%98%e5%8c%96","status":"publish","type":"post","link":"https:\/\/www.liangliang.org.cn\/?p=2770","title":{"rendered":"dstat\u547d\u4ee4&#8211;\u6027\u80fd\u76d1\u6d4b\u4e0e\u4f18\u5316"},"content":{"rendered":"<div id=\"title\" class=\"clearfix\">\n<div><\/div>\n<\/div>\n<div id=\"arc-body\">\n<p><strong>dstat\u547d\u4ee4<\/strong>\u662f\u4e00\u4e2a\u7528\u6765\u66ff\u6362<span class=\"wp_keywordlink\">vmstat<\/span>\u3001<span class=\"wp_keywordlink\">iostat<\/span>\u3001<span class=\"wp_keywordlink\">netstat<\/span>\u3001<span class=\"wp_keywordlink\">nfsstat<\/span>\u548c<span class=\"wp_keywordlink\">ifstat<\/span>\u8fd9\u4e9b\u547d\u4ee4\u7684\u5de5\u5177\uff0c\u662f\u4e00\u4e2a\u5168\u80fd\u7cfb\u7edf\u4fe1\u606f\u7edf\u8ba1\u5de5\u5177\u3002\u4e0esysstat\u76f8\u6bd4\uff0cdstat\u62e5\u6709\u4e00\u4e2a\u5f69\u8272\u7684\u754c\u9762\uff0c\u5728\u624b\u52a8\u89c2\u5bdf\u6027\u80fd\u72b6\u51b5\u65f6\uff0c\u6570\u636e\u6bd4\u8f83\u663e\u773c\u5bb9\u6613\u89c2\u5bdf\uff1b\u800c\u4e14dstat\u652f\u6301\u5373\u65f6\u5237\u65b0\uff0c\u8b6c\u5982\u8f93\u5165<code>dstat 3<\/code>\u5373\u6bcf\u4e09\u79d2\u6536\u96c6\u4e00\u6b21\uff0c\u4f46\u6700\u65b0\u7684\u6570\u636e\u90fd\u4f1a\u6bcf\u79d2\u5237\u65b0\u663e\u793a\u3002\u548csysstat\u76f8\u540c\u7684\u662f\uff0cdstat\u4e5f\u53ef\u4ee5\u6536\u96c6\u6307\u5b9a\u7684\u6027\u80fd\u8d44\u6e90\uff0c\u8b6c\u5982<code>dstat -c<\/code>\u5373\u663e\u793aCPU\u7684\u4f7f\u7528\u60c5\u51b5\u3002<\/p>\n<h3>\u4e0b\u8f7d\u5b89\u88c5<\/h3>\n<p><strong>\u65b9\u6cd5\u4e00<\/strong><\/p>\n<pre>apt-get install dstat<\/pre>\n<p>\u5b98\u7f51\u4e0b\u8f7d\u5730\u5740\uff1ahttp:\/\/dag.wieers.com\/<span class=\"wp_keywordlink\">rpm<\/span>\/packages\/dstat<\/p>\n<h3>\u4f7f\u7528\u8bf4\u660e<\/h3>\n<p>\u5b89\u88c5\u5b8c\u540e\u5c31\u53ef\u4ee5\u4f7f\u7528\u4e86\uff0cdstat\u975e\u5e38\u5f3a\u5927\uff0c\u53ef\u4ee5\u5b9e\u65f6\u7684\u76d1\u63a7cpu\u3001\u78c1\u76d8\u3001\u7f51\u7edc\u3001IO\u3001\u5185\u5b58\u7b49\u4f7f\u7528\u60c5\u51b5\u3002<\/p>\n<p>\u76f4\u63a5\u4f7f\u7528dstat\uff0c\u9ed8\u8ba4\u4f7f\u7528\u7684\u662f<code>-cdngy<\/code>\u53c2\u6570\uff0c\u5206\u522b\u663e\u793acpu\u3001disk\u3001net\u3001page\u3001system\u4fe1\u606f\uff0c\u9ed8\u8ba4\u662f1s\u663e\u793a\u4e00\u6761\u4fe1\u606f\u3002\u53ef\u4ee5\u5728\u6700\u540e\u6307\u5b9a\u663e\u793a\u4e00\u6761\u4fe1\u606f\u7684\u65f6\u95f4\u95f4\u9694\uff0c\u5982<code>dstat\u00a05<\/code>\u662f\u6ca15s\u663e\u793a\u4e00\u6761\uff0c<code>dstat\u00a05\u00a010<\/code>\u8868\u793a\u6ca15s\u663e\u793a\u4e00\u6761\uff0c\u4e00\u5171\u663e\u793a10\u6761\u3002<\/p>\n<pre>[root@iZ23uulau1tZ ~]# dstat\n----total-cpu-usage---- -dsk\/total- -net\/total- ---paging-- ---system--\nusr sys idl wai hiq siq| <span class=\"wp_keywordlink\">read<\/span>  writ| recv  send|  in   out | int   csw\n  0   0  99   0   0   0|7706B  164k|   0     0 |   0     0 | 189   225\n  0   0 100   0   0   0|   0     0 |4436B  826B|   0     0 | 195   248\n  1   0  99   0   0   0|   0     0 |4744B  346B|   0     0 | 203   242\n  0   0 100   0   0   0|   0     0 |5080B  346B|   0     0 | 206   242\n  0   1  99   0   0   0|   0     0 |5458B  444B|   0     0 | 214   244\n  1   0  99   0   0   0|   0     0 |5080B  346B|   0     0 | 208   242<\/pre>\n<p>\u4e0b\u9762\u5bf9\u663e\u793a\u51fa\u6765\u7684\u90e8\u5206\u4fe1\u606f\u4f5c\u4e00\u4e9b\u8bf4\u660e\uff1a<\/p>\n<ol>\n<li>cpu\uff1ahiq\u3001siq\u5206\u522b\u4e3a\u786c\u4e2d\u65ad\u548c\u8f6f\u4e2d\u65ad\u6b21\u6570\u3002<\/li>\n<li>system\uff1aint\u3001csw\u5206\u522b\u4e3a\u7cfb\u7edf\u7684\u4e2d\u65ad\u6b21\u6570\uff08interrupt\uff09\u548c\u4e0a\u4e0b\u6587\u5207\u6362\uff08context\u00a0switch\uff09\u3002<\/li>\n<\/ol>\n<p>\u5176\u4ed6\u7684\u90fd\u5f88\u597d\u7406\u89e3\u3002<\/p>\n<h3>\u8bed\u6cd5<\/h3>\n<pre>dstat [-afv] [options..] [delay [count]]<\/pre>\n<h3>\u5e38\u7528\u9009\u9879<\/h3>\n<pre>-c\uff1a\u663e\u793aCPU\u7cfb\u7edf\u5360\u7528\uff0c\u7528\u6237\u5360\u7528\uff0c\u7a7a\u95f2\uff0c\u7b49\u5f85\uff0c\u4e2d\u65ad\uff0c\u8f6f\u4ef6\u4e2d\u65ad\u7b49\u4fe1\u606f\u3002\n-C\uff1a\u5f53\u6709\u591a\u4e2aCPU\u65f6\u5019\uff0c\u6b64\u53c2\u6570\u53ef\u6309\u9700\u5206\u522b\u663e\u793acpu\u72b6\u6001\uff0c\u4f8b\uff1a-C 0,1 \u662f\u663e\u793acpu0\u548ccpu1\u7684\u4fe1\u606f\u3002\n-d\uff1a\u663e\u793a\u78c1\u76d8\u8bfb\u5199\u6570\u636e\u5927\u5c0f\u3002\n-D hda,total\uff1ainclude hda and total\u3002\n-n\uff1a\u663e\u793a\u7f51\u7edc\u72b6\u6001\u3002\n-N eth1,total\uff1a\u6709\u591a\u5757\u7f51\u5361\u65f6\uff0c\u6307\u5b9a\u8981\u663e\u793a\u7684\u7f51\u5361\u3002\n-l\uff1a\u663e\u793a\u7cfb\u7edf\u8d1f\u8f7d\u60c5\u51b5\u3002\n-m\uff1a\u663e\u793a\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\u3002\n-g\uff1a\u663e\u793a\u9875\u9762\u4f7f\u7528\u60c5\u51b5\u3002\n-p\uff1a\u663e\u793a\u8fdb\u7a0b\u72b6\u6001\u3002\n-s\uff1a\u663e\u793a\u4ea4\u6362\u5206\u533a\u4f7f\u7528\u60c5\u51b5\u3002\n-S\uff1a\u7c7b\u4f3cD\/N\u3002\n-r\uff1aI\/O\u8bf7\u6c42\u60c5\u51b5\u3002\n-y\uff1a\u7cfb\u7edf\u72b6\u6001\u3002\n--ipc\uff1a\u663e\u793aipc\u6d88\u606f\u961f\u5217\uff0c\u4fe1\u53f7\u7b49\u4fe1\u606f\u3002\n--socket\uff1a\u7528\u6765\u663e\u793atcp udp\u7aef\u53e3\u72b6\u6001\u3002\n-a\uff1a\u6b64\u4e3a\u9ed8\u8ba4\u9009\u9879\uff0c\u7b49\u540c\u4e8e-cdngy\u3002\n-v\uff1a\u7b49\u540c\u4e8e -pmgdsc -D total\u3002\n--output \u6587\u4ef6\uff1a\u6b64\u9009\u9879\u4e5f\u6bd4\u8f83\u6709\u7528\uff0c\u53ef\u4ee5\u628a\u72b6\u6001\u4fe1\u606f\u4ee5csv\u7684\u683c\u5f0f\u91cd\u5b9a\u5411\u5230\u6307\u5b9a\u7684\u6587\u4ef6\u4e2d\uff0c\u4ee5\u4fbf\u65e5\u540e\u67e5\u770b\u3002\u4f8b\uff1adstat --output \/root\/dstat.csv &amp; \u6b64\u65f6\u8ba9\u7a0b\u5e8f\u9ed8\u9ed8\u7684\u5728\u540e\u53f0\u8fd0\u884c\u5e76\u628a\u7ed3\u679c\u8f93\u51fa\u5230\/root\/dstat.csv\u6587\u4ef6\u4e2d\u3002<\/pre>\n<p>\u5f53\u7136dstat\u8fd8\u6709\u5f88\u591a\u66f4\u9ad8\u7ea7\u7684\u7528\u6cd5\uff0c\u5e38\u7528\u7684\u57fa\u672c\u8fd9\u4e9b\u9009\u9879\uff0c\u66f4\u9ad8\u7ea7\u7684\u7528\u6cd5\u53ef\u4ee5\u7ed3\u5408<span class=\"wp_keywordlink\"><a title=\"man\u547d\u4ee4\" href=\"http:\/\/man.linuxde.net\/man\" target=\"_blank\" rel=\"noopener\">man<\/a><\/span>\u6587\u6863\u3002<\/p>\n<h3>\u5b9e\u4f8b<\/h3>\n<p>\u5982\u60f3\u76d1\u63a7swap\uff0cprocess\uff0csockets\uff0cfilesystem\u5e76\u663e\u793a\u76d1\u63a7\u7684\u65f6\u95f4\uff1a<\/p>\n<pre>[root@iZ23uulau1tZ ~]# dstat -tsp --socket --fs\n----system---- ----swap--- ---procs--- ------sockets------ --filesystem-\n  <span class=\"wp_keywordlink\">date<\/span>\/<span class=\"wp_keywordlink\">time<\/span>   | used  <span class=\"wp_keywordlink\">free<\/span>|run blk new|tot tcp udp raw frg|files  inodes\n26-07 09:23:48|   0     0 |  0   0 0.0|104   8   5   0   0|  704   6488\n26-07 09:23:49|   0     0 |  0   0   0|104   8   5   0   0|  704   6488\n26-07 09:23:50|   0     0 |  0   0   0|104   8   5   0   0|  704   6489\n26-07 09:23:51|   0     0 |  0   0   0|104   8   5   0   0|  704   6489\n26-07 09:23:52|   0     0 |  0   0   0|104   8   5   0   0|  704   6489\n26-07 09:23:53|   0     0 |  0   0   0|104   8   5   0   0|  704   6489<\/pre>\n<p>\u82e5\u8981\u5c06\u7ed3\u679c\u8f93\u51fa\u5230\u6587\u4ef6\u53ef\u4ee5\u52a0<code>--output\u00a0filename<\/code>\uff1a<\/p>\n<pre>[root@iZ23uulau1tZ ~]# dstat -tsp --socket --fs --output \/tmp\/ds.csv\n----system---- ----swap--- ---procs--- ------sockets------ --filesystem-\n  date\/time   | used  free|run blk new|tot tcp udp raw frg|files  inodes\n26-07 09:25:31|   0     0 |  0   0 0.0|104   8   5   0   0|  736   6493\n26-07 09:25:32|   0     0 |  0   0   0|104   8   5   0   0|  736   6493\n26-07 09:25:33|   0     0 |  0   0   0|104   8   5   0   0|  736   6493\n26-07 09:25:34|   0     0 |  0   0   0|104   8   5   0   0|  736   6493\n26-07 09:25:35|   0     0 |  0   0   0|104   8   5   0   0|  736   6494\n26-07 09:25:36|   0     0 |  0   0   0|104   8   5   0   0|  736   6494<\/pre>\n<p>\u8fd9\u6837\u751f\u6210\u7684csv\u6587\u4ef6\u53ef\u4ee5\u7528excel\u6253\u5f00\uff0c\u7136\u540e\u751f\u6210\u56fe\u8868\u3002<\/p>\n<p>\u901a\u8fc7<code>dstat\u00a0--list<\/code>\u53ef\u4ee5\u67e5\u770bdstat\u80fd\u4f7f\u7528\u7684\u6240\u6709\u53c2\u6570\uff0c\u5176\u4e2d\u4e0a\u9762internal\u662fdstat\u672c\u8eab\u81ea\u5e26\u7684\u4e00\u4e9b\u76d1\u63a7\u53c2\u6570\uff0c\u4e0b\u9762<code>\/usr\/share\/dstat<\/code>\u4e2d\u662fdstat\u7684\u63d2\u4ef6\uff0c\u8fd9\u4e9b\u63d2\u4ef6\u53ef\u4ee5\u6269\u5c55dstat\u7684\u529f\u80fd\uff0c\u5982\u53ef\u4ee5\u76d1\u63a7\u7535\u6e90\uff08battery\uff09\u3001<span class=\"wp_keywordlink\">mysql<\/span>\u7b49\u3002<\/p>\n<p>\u4e0b\u9762\u8fd9\u4e9b\u63d2\u4ef6\u5e76\u4e0d\u662f\u90fd\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\u7684\uff0c\u6709\u7684\u8fd8\u4f9d\u8d56\u5176\u4ed6\u5305\uff0c\u5982\u60f3\u76d1\u63a7mysql\uff0c\u5fc5\u987b\u8981\u88c5python\u8fde\u63a5mysql\u7684\u4e00\u4e9b\u5305\u3002<\/p>\n<pre>[root@iZ23uulau1tZ ~]# dstat --list\ninternal:\n        aio, cpu, cpu24, disk, disk24, disk24old, epoch, fs, int, int24, io, ipc, load, lock, mem, net, page, page24, proc, raw, socket, swap, swapold, sys, tcp, time, udp, unix, vm\n\/usr\/share\/dstat:\n        battery, battery-remain, cpufreq, dbus, disk-util, fan, freespace, gpfs, gpfs-ops, helloworld, innodb-buffer, innodb-io, innodb-ops, lustre, memcache-hits, mysql-io, mysql-keys, mysql5-cmds, mysql5-conn, mysql5-io, mysql5-keys,\n        net-packets, nfs3, nfs3-ops, nfsd3, nfsd3-ops, ntp, postfix, power, proc-count, rpc, rpcd, <span class=\"wp_keywordlink\"><a title=\"sendmail\u547d\u4ee4\" href=\"http:\/\/man.linuxde.net\/sendmail\" target=\"_blank\" rel=\"noopener\">sendmail<\/a><\/span>, snooze, thermal, <span class=\"wp_keywordlink\"><a title=\"top\u547d\u4ee4\" href=\"http:\/\/man.linuxde.net\/top\" target=\"_blank\" rel=\"noopener\">top<\/a><\/span>-bio, top-cpu, top-cputime, top-cputime-avg, top-io, top-latency, top-latency-avg, top-mem, top-oom, utmp,\n        vm-memctl, vmk-hba, vmk-int, vmk-nic, vz-cpu, vz-io, vz-ubc, wifi<\/pre>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>dstat\u547d\u4ee4\u662f\u4e00\u4e2a\u7528\u6765\u66ff\u6362vmstat\u3001iostat\u3001netstat\u3001nfsstat\u548cifstat\u8fd9\u4e9b\u547d\u4ee4\u7684\u5de5\u5177\uff0c\u662f\u4e00\u4e2a\u5168\u80fd\u7cfb\u7edf\u4fe1\u606f\u7edf\u8ba1\u5de5\u5177\u3002\u4e0esysstat\u76f8\u6bd4\uff0cdstat\u62e5\u6709\u4e00\u4e2a\u5f69\u8272\u7684\u754c\u9762\uff0c\u5728\u624b&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"class_list":["post-2770","post","type-post","status-publish","format-standard","hentry","category-linux-gnu"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.liangliang.org.cn\/index.php?rest_route=\/wp\/v2\/posts\/2770","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.liangliang.org.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.liangliang.org.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.liangliang.org.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.liangliang.org.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2770"}],"version-history":[{"count":2,"href":"https:\/\/www.liangliang.org.cn\/index.php?rest_route=\/wp\/v2\/posts\/2770\/revisions"}],"predecessor-version":[{"id":2772,"href":"https:\/\/www.liangliang.org.cn\/index.php?rest_route=\/wp\/v2\/posts\/2770\/revisions\/2772"}],"wp:attachment":[{"href":"https:\/\/www.liangliang.org.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2770"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.liangliang.org.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2770"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.liangliang.org.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2770"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}