{"id":805,"date":"2020-03-02T10:53:20","date_gmt":"2020-03-02T10:53:20","guid":{"rendered":"http:\/\/www.liutianfeng.com\/?p=805"},"modified":"2020-03-02T13:32:27","modified_gmt":"2020-03-02T13:32:27","slug":"%e8%ae%a1%e7%ae%97%e6%9c%ac%e5%9c%b0%e7%a3%81%e7%9b%98%e5%92%8c%e5%a4%96%e6%8c%82%e7%a3%81%e7%9b%98%e7%9a%84%e8%84%9a%e6%9c%ac","status":"publish","type":"post","link":"https:\/\/www.liutianfeng.com\/?p=805","title":{"rendered":"\u8ba1\u7b97\u672c\u5730\u78c1\u76d8\u548c\u5916\u6302\u78c1\u76d8\u7684\u811a\u672c"},"content":{"rendered":"<p>\u4f7f\u7528mutipath -l\u53ef\u4ee5\u67e5\u770b\u5230\u672c\u5730\u662f\u5426\u6709\u65e5\u7acb\u7684\u5916\u6302\u5b58\u50a8\uff0c\u63a5\u7740\u901a\u8fc7\u8fd9\u4e2a\u6761\u4ef6\uff0c\u8fc7\u6ee4\u51fa\u6211\u4eec\u9700\u8981\u7684\u6240\u6709\u78c1\u76d8\u4fe1\u606f\uff0c\u518d\u52a0\u4ee5\u5904\u7406\uff0c\u5c31\u662f\u6211\u4eec\u9700\u8981\u7684\u7ed3\u679c\uff1a<\/p>\n<pre class=\"pure-highlightjs\"><code class=\"\">touch pysi_size.txt hi_size.txt\r\ncat \/dev\/null &gt; pysi_size.txt\r\ncat \/dev\/null &gt; hi_size.txt\r\n\r\ndm_hit=\"\"\"`sudo multipath -l |grep \"dm-\" |grep HITACHI |awk '{print $2}'`\"\"\"\r\ndm_pysical=\"\"\"`sudo multipath -l |grep \"dm-\" |grep -v HITACHI |awk '{print $2}'`\"\"\"\r\n\r\nfor i in `echo $dm_pysical`; do\r\n    pysi_size=`sudo multipath -l |grep \"$i\" -A1 |grep size |awk '{print $1}' |awk -F= '{if ($2~\/G\/) sub(\/G\/,\"\",$2); print $2}'`\r\n    echo $pysi_size &gt;&gt; pysi_size.txt\r\ndone\r\n\r\nfor i in `echo $dm_hit`; do\r\n    hit_size=`sudo multipath -l |grep \"$i\" -A1 |grep size |awk '{print $1}' |awk -F= '{if ($2~\/G\/) {sub(\/G\/,\"\",$2); print $2} else {sub(\/T\/,\"\",$2); print 1024*$2}}'`\r\n    echo $hit_size &gt;&gt; hi_size.txt\r\ndone\r\n\r\ncat pysi_size.txt |awk '{(pysi_sum+=$1)} END {print pysi_sum}'\r\ncat hi_size.txt |awk '{(hi_sum+=$1)} END {print hi_sum}'<\/code><\/pre>\n<p>\u6211\u4eec\u4f7f\u7528\u7684\u662f\u4e34\u65f6\u6587\u4ef6\u7684\u65b9\u5f0f\uff0c\u8ba9\u8ba1\u7b97\u51fa\u6765\u7684\u6570\u503c\uff0c\u5148\u5b58\u5165\u6587\u4ef6\uff1b<\/p>\n<p>\u53e6\u5916\uff0c\u5c31\u662fawk\u7684\u6761\u4ef6\u5224\u65ad\uff0c\u901a\u8fc7\u5339\u914dG\u548cT\u6765\u8fdb\u884c\u4e0d\u540c\u7684\u8ba1\u7b97\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u4e0a\u9762\u7684\u811a\u672c\u6267\u884c\u65f6\u5019\u6709\u70b9\u95ee\u9898\uff0c\u540e\u7eed\u7814\u7a76\uff0c\u6362\u4e86\u4e00\u79cd\u65b9\u6cd5\uff1a<\/p>\n<pre class=\"pure-highlightjs\"><code class=\"\">#!\/bin\/bash\r\ntouch pysi_size.txt hit_size.txt\r\ncat \/dev\/null &gt; pysi_size.txt\r\ncat \/dev\/null &gt; hit_size.txt\r\n\r\ndm_pysical=\"\"\"`sudo multipath -l |grep \"dm-\" |grep -v HITACHI |awk '{print $2}'`\"\"\"\r\ndm_hit=\"\"\"`sudo multipath -l |grep \"dm-\" |grep HITACHI |awk '{print $2}'`\"\"\"\r\n\r\nfor i in `echo $dm_pysical`; do\r\npysi_size=`sudo multipath -l |egrep \"\\&lt;$i\\&gt;\" -A1 |grep size |awk '{print $1}'`\r\necho $pysi_size &gt;&gt; pysi_size.txt\r\ndone\r\n\r\nfor j in `echo $dm_hit`; do\r\nhit_size=`sudo multipath -l |egrep \"\\&lt;$j\\&gt;\" -A1 |grep size |awk '{print $1}'`\r\necho $hit_size &gt;&gt; hit_size.txt\r\ndone\r\n\r\nsum_pysi=0\r\nfor k in `cat pysi_size.txt`; do\r\n    if echo $k |grep G &amp;&gt; \/dev\/null; then\r\n        pysi_num=`echo $i |tr -d G`\r\n    elif echo $k |grep T &amp;&gt; \/dev\/null; then\r\n        pysi_tr=`echo $k |tr -d T`\r\n        pysi_num=`echo \"1024*${pysi_tr}\" |bc`\r\n    fi\r\n    sum_pysi=`echo \"${sum_pysi}+${pysi_num}\" |bc`\r\ndone\r\n\r\nsum_hi=0\r\nfor l in `cat hit_size.txt`; do\r\n    if echo $l |grep G &amp;&gt; \/dev\/null; then\r\n        hi_num=`echo $l |tr -d G`\r\n    elif echo $l |grep T &amp;&gt; \/dev\/null; then\r\n        hi_tr=`echo $l |tr -d T`\r\n        hi_num=`echo \"1024*${hi_tr}\" |bc`\r\n    fi\r\n    sum_hi=`echo \"${sum_hi}+${hi_num}\" |bc`\r\ndone\r\necho $sum_pysi $sum_hi\r\n\r\nrm pysi_size.txt hit_size.txt<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>\u8f6c\u8f7d\u8bf7\u6ce8\u660e\uff1a<a href=\"https:\/\/www.liutianfeng.com\">liutianfeng.com<\/a> &raquo; <a href=\"https:\/\/www.liutianfeng.com\/?p=805\">\u8ba1\u7b97\u672c\u5730\u78c1\u76d8\u548c\u5916\u6302\u78c1\u76d8\u7684\u811a\u672c<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>\u4f7f\u7528mutipath -l\u53ef\u4ee5\u67e5\u770b\u5230\u672c\u5730\u662f\u5426\u6709\u65e5\u7acb\u7684\u5916\u6302\u5b58\u50a8\uff0c\u63a5\u7740\u901a\u8fc7\u8fd9\u4e2a\u6761\u4ef6\uff0c\u8fc7\u6ee4\u51fa\u6211\u4eec\u9700\u8981\u7684\u6240\u6709\u78c1\u76d8\u4fe1\u606f\uff0c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[31],"tags":[],"_links":{"self":[{"href":"https:\/\/www.liutianfeng.com\/index.php?rest_route=\/wp\/v2\/posts\/805"}],"collection":[{"href":"https:\/\/www.liutianfeng.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.liutianfeng.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.liutianfeng.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.liutianfeng.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=805"}],"version-history":[{"count":2,"href":"https:\/\/www.liutianfeng.com\/index.php?rest_route=\/wp\/v2\/posts\/805\/revisions"}],"predecessor-version":[{"id":807,"href":"https:\/\/www.liutianfeng.com\/index.php?rest_route=\/wp\/v2\/posts\/805\/revisions\/807"}],"wp:attachment":[{"href":"https:\/\/www.liutianfeng.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=805"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.liutianfeng.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=805"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.liutianfeng.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=805"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}