{"id":3422,"date":"2012-09-17T11:06:30","date_gmt":"2012-09-17T03:06:30","guid":{"rendered":"http:\/\/jpuyy.com\/?p=3422"},"modified":"2017-12-25T11:55:13","modified_gmt":"2017-12-25T03:55:13","slug":"linux-top","status":"publish","type":"post","link":"https:\/\/jpuyy.com\/?p=3422","title":{"rendered":"linux\u5de5\u5177\u4e4btop\/htop"},"content":{"rendered":"<p>\u4e3b\u8981\u4ecb\u7ecdtop<\/p>\n<p>\u7b2c\u4e00\u884c:<\/p>\n<p>\u65f6\u95f4 \u8fd0\u884c\u65f6\u95f4 \u767b\u9646\u7528\u6237\u6570\u00a0\u7cfb\u7edf\u8d1f\u8f7d\uff08\u4efb\u52a1\u961f\u5217\u7684\u5e73\u5747\u957f\u5ea6\uff0c\u5206\u522b\u4e3a1\u5206\u949f\u30015\u5206\u949f\u300115\u5206\u949f\u524d\u5230\u73b0\u5728\u7684\u5e73\u5747\u503c\u3002\uff09<\/p>\n<pre>top - 08:36:25 up 19 min, 2 users, load average: 1.33, 0.86, 0.60<\/pre>\n<p>\u8d1f\u8f7d\u7684\u610f\u601d\u662f\u5728 run queue \u4e2d\u7684\u8fdb\u7a0b\u6570\u91cf\u9664\u4ee5 cpu \u3002 \u5c0f\u4e8e cpu \u4e2a\u6570\u90fd\u7b97\u6ca1\u6709\u8d85\u8d1f\u8f7d\u3002<\/p>\n<p>\u7b2c\u4e8c\u884c:<\/p>\n<p>\u8fdb\u7a0b\u603b\u6570 \u6b63\u5728\u8fd0\u884c\u8fdb\u7a0b\u6570 \u7761\u7720\u8fdb\u7a0b\u6570 \u505c\u6b62\u8fdb\u7a0b\u6570 \u50f5\u5c38\u8fdb\u7a0b\u6570<\/p>\n<pre>Tasks: 179 total, \u00a0 1 running, 178 sleeping, \u00a0 0 stopped, \u00a0 0 zombie<\/pre>\n<p>\u7b2c\u4e09\u884c:<\/p>\n<p>cpu\u4fe1\u606f\uff0c\u63091\u663e\u793a\u6bcf\u4e2acpu\u7684\u60c5\u51b5\uff0cus\u8868\u793a\u8fdb\u7a0b\u5904\u7406\u6240\u5360\u7684\u767e\u5206\u6bd4\uff0cni\u8868\u793a\u88abnice\u6539\u53d8\u4f18\u5148\u7ea7\u7684\u547d\u4ee4\u5360\u7684\u767e\u5206\u6bd4\uff0cid\u8868\u793aidle\u7a7a\u95f2\uff0c hi \u4ee3\u8868 hardware interrupts\uff0csi \u4ee3\u8868 software interrupst\uff0c \u901a\u8fc7 cat \/proc\/interrupts \u53ef\u4ee5\u67e5\u770b\u4e2d\u65ad\u3002<\/p>\n<pre>Cpu(s): \u00a04.8%us, \u00a01.7%sy, \u00a00.0%ni, 93.2%id, \u00a00.3%wa, \u00a00.0%hi, \u00a00.0%si, \u00a00.0%st<\/pre>\n<p>\u56db\u884c\u3001\u4e94\u884c\u4e3a\u5185\u5b58\u548cswap\u4fe1\u606f<\/p>\n<p>\u5728\u8fdb\u7a0b\u4fe1\u606f\u680f\u4e2d\uff0c\u67e5\u770b\u8fdb\u7a0b\u66f4\u4e30\u5bcc\u7684\u4fe1\u606f\uff0ch\u6216?\uff0c\u4f1a\u663e\u793a\u5e2e\u52a9\u547d\u4ee4<br \/>\n\u5217\u51fa\u5e38\u7528\u7684\u63a7\u5236\u547d\u4ee4\u6709<\/p>\n<p>M \u6839\u636e\u9a7b\u7559\u5185\u5b58\u5927\u5c0f\u8fdb\u884c\u6392\u5e8f\uff08\u5e38\u7528\uff09<br \/>\nP \u6839\u636eCPU\u4f7f\u7528\u767e\u5206\u6bd4\u5927\u5c0f\u8fdb\u884c\u6392\u5e8f\uff08\u5e38\u7528\uff09<br \/>\nT \u6839\u636e\u65f6\u95f4\/\u7d2f\u8ba1\u65f6\u95f4\u8fdb\u884c\u6392\u5e8f\uff08\u5e38\u7528\uff09<br \/>\nR \u5c06\u5f53\u524d\u7684\u6392\u5e8f\u5012\u8f6c\uff08\u5e38\u7528\uff09<br \/>\nN \u6309\u8fdb\u7a0bID\u6392\u5e8f<br \/>\nu \u53ef\u8f93\u5165\u7528\u6237\u8fdb\u884c\u7b5b\u9009<br \/>\n\u7a7a\u683c \u00a0\u7acb\u5373\u5237\u65b0\u4fe1\u606f<br \/>\nk\u8f93\u5165\u60f3\u8981kill\u6389\u7684\u8fdb\u7a0bID\u53f7<\/p>\n<p>\u4e00\u9875\u663e\u793a\u4e0d\u5b8c\u6574\uff0c\u4f7f\u7528&lt;&gt;\u5206\u522b\u4e0a\u4e0b\u7ffb\u9875<\/p>\n<p>\u63a7\u5236\u663e\u793a\u7684\u5217:<\/p>\n<p>f \u00a0\u53ef\u63a7\u5236\u663e\u793a\u5217\u8f93\u51fa\u7684\u5185\u5bb9\uff0c \u5bf9\u5e94a-z<br \/>\no\u952e \u53ef\u6539\u53d8\u5217\u7684\u987a\u5e8f\uff0c\u5927\u5199\u5b57\u6bcd\u5f80\u5de6(\u4e0a)\uff0c\u5c0f\u5199\u5b57\u6bcd\u8eab\u53f3(\u4e0b)<br \/>\n\u5927\u5199O \u8c03\u6574\u6309\u67d0\u5217\u6392\u5e8f<\/p>\n<p>\u8fc7\u6ee4 nginx \u7528\u6237\u6267\u884c\u7684\u7a0b\u5e8f<\/p>\n<p>shift + u \u7136\u540e\u8f93\u5165 nginx<br \/>\n\u6216\u8005\u5728\u5f00\u59cb\u7684\u65f6\u5019\u5c31<\/p>\n<pre>top -u nginx<\/pre>\n<p>\u53ea\u663e\u793a\u67d0\u51e0\u4e2a\u8fdb\u7a0b\uff0c\u8ddf\u8fdb\u7a0b\u53f7<\/p>\n<pre>top -p  9943,11162<\/pre>\n<p>\u53ea\u6253\u5370\u4e00\u6b21\u5e76\u91cd\u5b9a\u5411\u5230\u6587\u4ef6\u4e2d<\/p>\n<pre>top -b -n 1 >> top1.txt<\/pre>\n<p>\u6309 z \u663e\u793a\u989c\u8272<\/p>\n<p>\u5bf9\u4e8e mysqld \u5355\u8fdb\u7a0b\u591a\u7ebf\u7a0b\uff0c\u9ed8\u8ba4\u5176\u4ed6\u7ebf\u7a0b\u4f1a\u6536\u7f29\u8d77\u6765\uff0c\u5982\u679c\u8981\u663e\u793a\u6309 H<\/p>\n<p>\u6309 i \u4e0d\u663e\u793a\u7a7a\u95f2\u7684\u8fdb\u7a0b\u53ca\u50f5\u5c38\u8fdb\u7a0b<\/p>\n<p>top \u9ed8\u8ba4\u6bcf 3 \u79d2\u5237\u65b0\u4e00\u6b21\uff0c\u6309 d \u6216 s \u6309\u63d0\u793a\u53ef\u4ee5\u8f93\u5165\u60f3\u8981\u7684\u5237\u65b0\u95f4\u9694<\/p>\n<p>\u663e\u793a\u67d0\u4e2a\u8fdb\u7a0b\u8fd0\u884c\u5728\u67d0\u4e2a cpu \u4e0a\uff0c\u6309 f \u627e\u5230 Last used cpu \uff0c\u6309 j \u9009\u53d6\u4e0a\uff0c\u8fd9\u6837\u663e\u793a\u5c31\u6709\u6b64\u8fdb\u7a0b\u4f7f\u7528\u54ea\u4e2a cpu \u4e86\u3002\u5982\u679c\u4e00\u4e2a\u8f6f\u4ef6\u957f\u671f\u8fd0\u884c\u5728\u4e00\u4e2a cpu \u4e0a\uff0c\u90a3\u4e48\u6709\u53ef\u80fd\u662f\u8bbe\u7f6e\u9519\u8bef\u3002<\/p>\n<p>\u6309 F \u6839\u636e\u67d0\u4e00\u5217\u6392\u5e8f<\/p>\n<p>\u6309 c \u663e\u793a\u5177\u4f53\u7684\u8fdb\u7a0b\u540d\u5b57<\/p>\n<p>\u5f53\u8fdb\u884c\u5b8c\u4e0a\u9762\u7684\u8bbe\u7f6e\u4e4b\u540e\uff0c\u6309 W \u4fdd\u5b58\u5f53\u524d\u7684\u914d\u7f6e\u5230 ~\/.toprc \u4e0b\u6b21\u4f1a\u76f4\u63a5\u8c03\u7528\u3002<\/p>\n<p>\u663e\u793a\u8fdb\u7a0b\u548c\u7ebf\u7a0b<\/p>\n<pre>top -H<\/pre>\n<p>\u6392\u5e8f\u540e\u53ea\u53d6\u524d n \u4f4d\uff0c\u6309 n\uff0c\u8f93\u5165\u6570\u5b57<\/p>\n<p>\u8bbe\u7f6e filter<\/p>\n<p>\u6309 <code> o <\/code> \u8f93\u5165\u8fc7\u6ee4\u6761\u4ef6\uff0c\u5b57\u6bb5\u4e0a\u9762\u7684\u90fd\u53ef\u4ee5\u8f93\u5165\uff0c\u5982<\/p>\n<pre>%CPU>100.0<\/pre>\n<pre>COMMAND=java<\/pre>\n<p>\u67e5\u770b\u5f53\u524d\u7684 filter<\/p>\n<pre>Ctrl + o <\/pre>\n<p>\u6e05\u7a7a\u5f53\u524d\u7684 filter<\/p>\n<pre>=<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u4e3b\u8981\u4ecb\u7ecdtop \u7b2c\u4e00\u884c: \u65f6\u95f4 \u8fd0\u884c\u65f6\u95f4 \u767b\u9646\u7528\u6237\u6570\u00a0\u7cfb\u7edf\u8d1f\u8f7d\uff08\u4efb\u52a1\u961f\u5217\u7684\u5e73\u5747\u957f\u5ea6\uff0c\u5206\u522b\u4e3a1\u5206\u949f\u30015\u5206\u949f\u300115\u5206\u949f\u524d\u5230\u73b0\u5728\u7684\u5e73\u5747\u503c\u3002\uff09 top &#8211; 08:36:25 up 19 min, 2 users, load average: 1.33, 0.86, 0.60 \u8d1f\u8f7d\u7684\u610f\u601d\u662f\u5728 run queue \u4e2d\u7684\u8fdb\u7a0b\u6570\u91cf\u9664\u4ee5 cpu \u3002 \u5c0f\u4e8e cpu \u4e2a\u6570\u90fd\u7b97\u6ca1\u6709\u8d85\u8d1f\u8f7d\u3002 \u7b2c\u4e8c\u884c: \u8fdb\u7a0b\u603b\u6570 \u6b63\u5728\u8fd0\u884c\u8fdb\u7a0b\u6570 \u7761\u7720\u8fdb\u7a0b\u6570 \u505c\u6b62\u8fdb\u7a0b\u6570 \u50f5\u5c38\u8fdb\u7a0b\u6570 Tasks: 179 total, \u00a0 1 running, 178 sleeping, \u00a0 0 stopped, \u00a0 0 zombie \u7b2c\u4e09\u884c: cpu\u4fe1\u606f\uff0c\u63091\u663e\u793a\u6bcf\u4e2acpu\u7684\u60c5\u51b5\uff0cus\u8868\u793a\u8fdb\u7a0b\u5904\u7406\u6240\u5360\u7684\u767e\u5206\u6bd4\uff0cni\u8868\u793a\u88abnice\u6539\u53d8\u4f18\u5148\u7ea7\u7684\u547d\u4ee4\u5360\u7684\u767e\u5206\u6bd4\uff0cid\u8868\u793aidle\u7a7a\u95f2\uff0c hi \u4ee3\u8868 hardware interrupts\uff0csi \u4ee3\u8868 software [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-3422","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/3422","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3422"}],"version-history":[{"count":26,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/3422\/revisions"}],"predecessor-version":[{"id":8322,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/3422\/revisions\/8322"}],"wp:attachment":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3422"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3422"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3422"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}