{"id":581,"date":"2011-03-16T01:11:25","date_gmt":"2011-03-15T17:11:25","guid":{"rendered":"http:\/\/www.strongd.net\/?p=581"},"modified":"2011-03-16T01:11:25","modified_gmt":"2011-03-15T17:11:25","slug":"%e8%b0%83%e6%9f%a5%e6%9c%8d%e5%8a%a1%e5%99%a8%e5%93%8d%e5%ba%94%e6%97%b6%e9%97%b4%e7%9a%84%e5%88%a9%e5%99%a8-tcprstat","status":"publish","type":"post","link":"https:\/\/www.strongd.net\/?p=581","title":{"rendered":"\u8c03\u67e5\u670d\u52a1\u5668\u54cd\u5e94\u65f6\u95f4\u7684\u5229\u5668 tcprstat"},"content":{"rendered":"<h1><\/h1>\n<div>\n<p>\u6211\u4eec\u5728\u505a\u670d\u52a1\u5668\u7a0b\u5e8f\u7684\u65f6\u5019\uff0c\u7ecf\u5e38\u8981\u77e5\u9053\u4e00\u4e2a\u8bf7\u6c42\u7684\u54cd\u5e94\u65f6\u95f4\uff0c\u501f\u4ee5\u4f18\u5316\u6216\u8005\u5b9a\u4f4d\u95ee\u9898\u3002 \u901a\u5e38\u7684\u505a\u6cd5\u662f\u5728\u4ee3\u7801\u91cc\u9762\u52a0\u5165\u65e5\u5fd7\u8ba1\u7b97\u65f6\u95f4\uff0c\u8fd9\u4e2a\u65b9\u6cd5\u6709\u95ee\u9898\uff0c\u65f6\u95f4\u4e0d\u51c6\u786e\u3002\u56e0\u4e3a\u6570\u636e\u4ece\u7f51\u5361\u5230\u5e94\u7528\u7a0b\u5e8f\uff0c\u4ece\u5e94\u7528\u5230\u7f51\u5361\u7684\u65f6\u95f4\u6ca1\u6709\u88ab\u8ba1\u7b97\u5728\u5185\u3002 \u800c\u4e14\u8fd9\u4e2a\u65f6\u95f4\u968f\u7740\u7cfb\u7edf\u7684\u8d1f\u8f7d\u6709\u5f88\u5927\u7684\u53d8\u5316\u3002<br \/>\n\u90a3\u540c\u5b66\u8bf4\uff0c\u6211wireshark, tcpdump\u6293\u5305\u4eba\u8089\u7edf\u8ba1\u4e0d\u884c\u5417\u3002 \u53ef\u4ee5\u7684\uff0c\u53ea\u4e0d\u8fc7\u6211\u4f1a\u5f88\u540c\u60c5\u4f60\uff0c\u6b64\u4e3e\u9700\u8981\u8010\u5fc3\u4e14\u4e0d\u5177\u53ef\u6301\u7eed\u6027\u3002 \u6240\u4ee5\u6211\u4eec\u5e0c\u671b\u6709\u4e2a\u5de5\u5177\u80fd\u591f\u6700\u5c11\u8d39\u529b\u7684\u505a\u8fd9\u4e2a\u4e8b\u60c5\u3002<\/p>\n<p>\u8fd9\u65f6\u5019\u6765\u81eapercona\u7684tcprstat\u6765\u6551\u52a9\u4e86\uff01 \u8fd9\u4e2a\u5de5\u5177\u539f\u672c\u5f00\u53d1\u7528\u6765\u8c03\u67e5mysqld\u7684\u6027\u80fd\u95ee\u9898\uff0c\u6240\u4ee5\u4e0d\u8981\u5947\u602a\u5b83\u7684\u9ed8\u8ba4\u7aef\u53e3\u662f3306, \u4f46\u662f\u6211\u4eec\u53ef\u4ee5\u7528\u8fd9\u4e2a\u5de5\u5177\u6765\u8c03\u67e5\u5178\u578b\u7684request-&gt;response\u7c7b\u578b\u7684\u670d\u52a1\u5668\u3002<\/p>\n<p>\u4ec0\u4e48\u662ftcprstat:<\/p>\n<blockquote><p>tcprstat is a free, open-source TCP analysis tool that watches network traffic and computes the delay between requests and responses. From this it derives response-time statistics and prints them out. The output is similar to other Unix -stat tools such as vmstat, iostat, and mpstat. The tool can optionally watch traffic to only a specified port, which makes it practical for timing requests and responses to a single daemon process such as mysqld, httpd, memcached, or any of a variety of other server processes.<\/p><\/blockquote>\n<p>\u6587\u6863\u5f88\u8be6\u7ec6\uff1a \u8bf7\u53c2\u8003\uff1a\u00a0<a href=\"http:\/\/www.percona.com\/docs\/wiki\/tcprstat:start\" target=\"_blank\">http:\/\/www.percona.com\/docs\/wiki\/tcprstat:start<\/a><\/p>\n<p>\u4e0d\u613f\u610f\u7f16\u8bd1\u7684\u540c\u5b66\u76f4\u63a5\u4ece\u8fd9\u91cc\u4e0b\u8f7d64\u4f4d\u7cfb\u7edf\u7684\u7f16\u8bd1\u597d\u7684\u4e8c\u8fdb\u5236\uff1a<a href=\"http:\/\/github.com\/downloads\/Lowercases\/tcprstat\/tcprstat-static.v0.3.1.x86_64\" target=\"_blank\">http:\/\/github.com\/downloads\/Lowercases\/tcprstat\/tcprstat-static.v0.3.1.x86_64<\/a><\/p>\n<p>\u6e90\u7801\u7f16\u8bd1\u4e5f\u633a\u5bb9\u6613\u7684\uff1a \u7531\u4e8e\u5b83\u81ea\u5e26libpcap\u5305\uff0c \u8fd9\u4e2a\u5305\u6709\u53ef\u80fd\u5728configure\u7684\u65f6\u5019\u6ca1\u8ba4\u8bc6\u597dnetlink, \u53ea\u8981\u628aconfig.h\u91cc\u9762\u7684netlink\u90a3\u4e2adefine\u6ce8\u91ca\u6389\u5c31\u597d\u3002<\/p>\n<p>\u7f16\u8bd1\u597d\u4e86\uff0c \u5178\u578b\u4f7f\u7528\u5f88\u7b80\u5355\uff1a<\/p>\n<p># tcprstat -p 3306 -t 1 -n 5<br \/>\ntimestamp\tcount\tmax\tmin\tavg\tmed\tstddev\t95_max\t95_avg\t95_std\t99_max\t99_avg\t99_std<br \/>\n1283261499\t1870\t559009\t39\t883\t153\t13306\t1267\t201\t150\t6792\t323\t685<br \/>\n1283261500\t1865\t25704\t29\t578\t142\t2755\t889\t175\t107\t23630\t333\t1331<br \/>\n1283261501\t1887\t26908\t33\t583\t148\t2761\t714\t176\t94\t23391\t339\t1340<br \/>\n1283261502\t2015\t304965\t35\t624\t151\t7204\t564\t171\t79\t8615\t237\t507<br \/>\n1283261503\t1650\t289087\t35\t462\t146\t7133\t834\t184\t120\t3565\t244\t358<\/p>\n<p>\u4f46\u662f\u8fd9\u4e2atcprstat\u5728bonding\u7684\u7f51\u5361\u4e0b\u6709\u70b9\u95ee\u9898\uff1a<\/p>\n<p># \/sbin\/ifconfig<br \/>\nbond0 Link encap:Ethernet HWaddr A4:BA:DB:28:B5:AB<br \/>\ninet addr:10.232.31.19 Bcast:10.232.31.255 Mask:255.255.255.0<br \/>\ninet6 addr: fe80::a6ba:dbff:fe28:b5ab\/64 Scope:Link<br \/>\nUP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1<br \/>\nRX packets:19451951688 errors:0 dropped:4512 overruns:0 frame:0<br \/>\nTX packets:26522074966 errors:0 dropped:0 overruns:0 carrier:0<br \/>\ncollisions:0 txqueuelen:0<br \/>\nRX bytes:6634368171533 (6.0 TiB) TX bytes:32576206882863 (29.6 TiB)<br \/>\n\u2026<br \/>\n# tcprstat -p 3306 -t 1 -n 5<br \/>\npcap: SIOCGIFFLAGS: bonding_masters: No such device<\/p>\n<p>\u89e3\u51b3\u65b9\u6848\u662f:<\/p>\n<p># sudo tcprstat -p 3306 -t 1 -n 0 -l `\/sbin\/ifconfig | grep \u2018addr:[^ ]\\+\u2019 -o | cut -f 2 -d : | xargs echo | sed -e \u2019s\/ \/,\/g\u2019`<\/p>\n<p>\u5728\u5178\u578b\u6ee1\u8d1f\u8f7d\u7684mysql\u670d\u52a1\u5668\u4e0a\u6293\u5305\u7684\u5f00\u9500\u662f\uff1a<\/p>\n<p>26163 root 18 0 104m 5304 4696 S\u00a018.3\u00a00.0 49:47.58 tcprstat<\/p>\n<p>\u7528IP\u65b9\u5f0f\uff0c\u800c\u4e0d\u662f\u7f51\u7edc\u63a5\u53e3\u65b9\u5f0f\u641e\u5b9a\u3002<\/p>\n<p>\u795d\u5927\u5bb6\u73a9\u7684\u5f00\u5fc3\u3002<\/p>\n<\/div>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6211\u4eec\u5728\u505a\u670d\u52a1\u5668\u7a0b\u5e8f\u7684\u65f6\u5019\uff0c\u7ecf\u5e38\u8981\u77e5\u9053\u4e00\u4e2a\u8bf7\u6c42\u7684\u54cd\u5e94\u65f6\u95f4\uff0c\u501f\u4ee5\u4f18\u5316\u6216\u8005\u5b9a\u4f4d\u95ee\u9898\u3002 \u901a\u5e38\u7684\u505a\u6cd5\u662f\u5728\u4ee3\u7801\u91cc\u9762\u52a0\u5165\u65e5\u5fd7\u8ba1\u7b97\u65f6\u95f4\uff0c\u8fd9\u4e2a\u65b9\u6cd5\u6709\u95ee\u9898\uff0c\u65f6\u95f4\u4e0d\u51c6\u786e\u3002\u56e0\u4e3a\u6570\u636e\u4ece\u7f51\u5361\u5230\u5e94\u7528\u7a0b\u5e8f\uff0c\u4ece\u5e94\u7528\u5230\u7f51\u5361\u7684\u65f6\u95f4\u6ca1\u6709\u88ab\u8ba1\u7b97\u5728\u5185\u3002 \u800c\u4e14\u8fd9\u4e2a\u65f6\u95f4\u968f\u7740\u7cfb\u7edf\u7684\u8d1f\u8f7d\u6709\u5f88\u5927\u7684\u53d8\u5316\u3002 \u90a3\u540c\u5b66\u8bf4\uff0c\u6211wireshark, tcpdump\u6293\u5305\u4eba\u8089\u7edf\u8ba1\u4e0d\u884c\u5417\u3002 \u53ef\u4ee5\u7684\uff0c\u53ea\u4e0d\u8fc7\u6211\u4f1a\u5f88\u540c\u60c5\u4f60\uff0c\u6b64\u4e3e\u9700\u8981\u8010\u5fc3\u4e14\u4e0d\u5177\u53ef\u6301\u7eed\u6027\u3002 \u6240\u4ee5\u6211\u4eec\u5e0c\u671b\u6709\u4e2a\u5de5\u5177\u80fd\u591f\u6700\u5c11\u8d39\u529b\u7684\u505a\u8fd9\u4e2a\u4e8b\u60c5\u3002 \u8fd9\u65f6\u5019\u6765\u81eapercona\u7684tcprstat\u6765\u6551\u52a9\u4e86\uff01 \u8fd9\u4e2a\u5de5\u5177\u539f\u672c\u5f00\u53d1\u7528\u6765\u8c03\u67e5mysqld\u7684\u6027\u80fd\u95ee\u9898\uff0c\u6240\u4ee5\u4e0d\u8981\u5947\u602a\u5b83\u7684\u9ed8\u8ba4\u7aef\u53e3\u662f3306, \u4f46\u662f\u6211\u4eec\u53ef\u4ee5\u7528\u8fd9\u4e2a\u5de5\u5177\u6765\u8c03\u67e5\u5178\u578b\u7684request-&gt;response\u7c7b\u578b\u7684\u670d\u52a1\u5668\u3002 \u4ec0\u4e48\u662ftcprstat: tcprstat is a free, open-source TCP analysis tool that watches network traffic and computes the delay between requests and responses. From this it derives response-time statistics and prints them out. The output is similar to other Unix -stat tools such as vmstat, iostat, and &hellip; <a href=\"https:\/\/www.strongd.net\/?p=581\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">\u8c03\u67e5\u670d\u52a1\u5668\u54cd\u5e94\u65f6\u95f4\u7684\u5229\u5668 tcprstat<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-581","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/581","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=581"}],"version-history":[{"count":1,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/581\/revisions"}],"predecessor-version":[{"id":582,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/581\/revisions\/582"}],"wp:attachment":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=581"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=581"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=581"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}