{"id":63656,"date":"2025-04-29T14:26:28","date_gmt":"2025-04-29T06:26:28","guid":{"rendered":"https:\/\/fwq.ai\/blog\/63656\/"},"modified":"2025-04-29T14:26:28","modified_gmt":"2025-04-29T06:26:28","slug":"linux%e6%80%8e%e4%b9%88%e6%9f%a5%e7%9c%8b%e7%ba%bf%e7%a8%8b%e6%95%b0-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/63656\/","title":{"rendered":"linux\u600e\u4e48\u67e5\u770b\u7ebf\u7a0b\u6570"},"content":{"rendered":"<blockquote><p>\n  linux \u67e5\u770b\u7ebf\u7a0b\u6570\u7684\u65b9\u6cd5\uff1a\u67e5\u770b\u7279\u5b9a\u8fdb\u7a0b\u7ebf\u7a0b\u6570\uff1aps -elf | grep pid\uff1a\u663e\u793a\u8fdb\u7a0b pid \u7684\u7ebf\u7a0b\u6570top -h -p pid\uff1a\u4ea4\u4e92\u5f0f\u663e\u793a\u8fdb\u7a0b pid \u7684\u7ebf\u7a0b\u6570\u67e5\u770b\u7cfb\u7edf\u6240\u6709\u7ebf\u7a0b\u6570\uff1agrep ^threads \/proc\/stat\uff1a\u68c0\u7d22\u7cfb\u7edf\u6240\u6709\u7ebf\u7a0b\u6570cat \/proc\/cpuinfo | grep &#8220;processor&#8221; | wc -l\uff1a\u8ba1\u6570\u5904\u7406\u5668\u6570\u91cf\uff0c\u6bcf\u4e2a\u5904\u7406\u5668\u901a\u5e38\u6709\u4e00\u4e2a\u7ebf\u7a0b\u4f7f\u7528\u7b2c\u4e09\u65b9\u5de5\u5177\uff1ahtop\uff1a\u4ea4\u4e92\u5f0f\u663e\u793a\u7cfb\u7edf\u6240\u6709\u8fdb\u7a0b\u548c\u7ebf\u7a0b\u4fe1\u606f\uff0c\u5305\u62ec\u7ebf\u7a0b\u6570atop\uff1a\u7cfb\u7edf\u6027\u80fd\u76d1\u63a7\u5de5\u5177\uff0c\u663e\u793a\u7cfb\u7edf\u6240\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202406\/04\/2024060409241891787.jpg\" class=\"aligncenter\" title=\"linux\u600e\u4e48\u67e5\u770b\u7ebf\u7a0b\u6570\u63d2\u56fe\" alt=\"linux\u600e\u4e48\u67e5\u770b\u7ebf\u7a0b\u6570\u63d2\u56fe\" \/><\/p>\n<p><strong>Linux \u4e2d\u67e5\u770b\u7ebf\u7a0b\u6570\u7684\u65b9\u6cd5<\/strong><\/p>\n<p><strong>1. \u67e5\u770b\u7279\u5b9a\u8fdb\u7a0b\u7684\u7ebf\u7a0b\u6570<\/strong><\/p>\n<ul>\n<li><strong>ps -eLf | grep PID<\/strong><\/li>\n<\/ul>\n<p>\u6b64\u547d\u4ee4\u5c06\u663e\u793a\u8fdb\u7a0b PID \u7684\u7ebf\u7a0b\u6570\uff0c\u5176\u4e2d\uff1a<\/p>\n<ul>\n<li>-e\uff1a\u663e\u793a\u6240\u6709\u8fdb\u7a0b<\/li>\n<li>-Lf\uff1a\u663e\u793a\u8be6\u7ec6\u4fe1\u606f\uff0c\u5305\u62ec\u7ebf\u7a0b\u4fe1\u606f<\/li>\n<li>PID\uff1a\u8981\u68c0\u67e5\u7684\u8fdb\u7a0b ID<\/li>\n<li><strong>top -H -p PID<\/strong><\/li>\n<\/ul>\n<p>\u6b64\u547d\u4ee4\u542f\u52a8\u4ea4\u4e92\u5f0f top \u5b9e\u7528\u7a0b\u5e8f\uff0c\u5e76\u663e\u793a\u6307\u5b9a\u8fdb\u7a0b PID \u7684\u7ebf\u7a0b\u6570\u3002<\/p>\n<p><strong>2. \u67e5\u770b\u7cfb\u7edf\u4e2d\u7684\u6240\u6709\u7ebf\u7a0b\u6570<\/strong><\/p>\n<ul>\n<li><strong>grep ^Threads \/proc\/stat<\/strong><\/li>\n<\/ul>\n<p>\u6b64\u547d\u4ee4\u4ece \/proc\/stat \u6587\u4ef6\u4e2d\u68c0\u7d22\u7cfb\u7edf\u4e2d\u6240\u6709\u7ebf\u7a0b\u6570\u7684\u4fe1\u606f\u3002<\/p>\n<ul>\n<li><strong>cat \/proc\/cpuinfo | grep &#8220;processor&#8221; | wc -l<\/strong><\/li>\n<\/ul>\n<p>\u6b64\u547d\u4ee4\u8ba1\u6570 \/proc\/cpuinfo \u6587\u4ef6\u4e2d\u5904\u7406\u5668\u7684\u6570\u91cf\uff0c\u56e0\u4e3a\u6bcf\u4e2a\u5904\u7406\u5668\u901a\u5e38\u6709\u4e00\u4e2a\u7ebf\u7a0b\u3002<\/p>\n<p><strong>3. \u4f7f\u7528\u7b2c\u4e09\u65b9\u5de5\u5177<\/strong><\/p>\n<ul>\n<li><strong>htop<\/strong><\/li>\n<\/ul>\n<p>htop \u662f\u4e00\u4e2a\u4ea4\u4e92\u5f0f\u8fdb\u7a0b\u67e5\u770b\u5668\uff0c\u53ef\u663e\u793a\u7cfb\u7edf\u4e2d\u6240\u6709\u8fdb\u7a0b\u548c\u7ebf\u7a0b\u7684\u4fe1\u606f\uff0c\u5305\u62ec\u7ebf\u7a0b\u6570\u3002<\/p>\n<ul>\n<li><strong>atop<\/strong><\/li>\n<\/ul>\n<p>atop \u662f\u4e00\u4e2a\u7cfb\u7edf\u6027\u80fd\u76d1\u63a7\u5de5\u5177\uff0c\u53ef\u663e\u793a\u7cfb\u7edf\u4e2d\u6240\u6709\u8fdb\u7a0b\u548c\u7ebf\u7a0b\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u5305\u62ec\u7ebf\u7a0b\u6570\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u67e5\u770b\u7ebf\u7a0b\u6570\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8FDCServers\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>linux \u67e5\u770b\u7ebf\u7a0b\u6570\u7684\u65b9\u6cd5\uff1a\u67e5\u770b\u7279\u5b9a\u8fdb\u7a0b\u7ebf\u7a0b\u6570\uff1aps -elf | grep pid\uff1a\u663e\u793a\u8fdb\u7a0b pid \u7684\u7ebf\u7a0b\u6570top -h -p pid\uff1a\u4ea4\u4e92\u5f0f\u663e\u793a\u8fdb\u7a0b pid \u7684\u7ebf\u7a0b\u6570\u67e5\u770b\u7cfb\u7edf\u6240\u6709\u7ebf\u7a0b\u6570\uff1agrep ^threads \/proc\/stat\uff1a\u68c0\u7d22\u7cfb\u7edf\u6240\u6709\u7ebf\u7a0b\u6570cat \/proc\/cpuinfo | grep &#8220;processor&#8221; | wc -l\uff1a\u8ba1\u6570\u5904\u7406\u5668\u6570\u91cf\uff0c\u6bcf\u4e2a\u5904\u7406\u5668\u901a\u5e38\u6709\u4e00\u4e2a\u7ebf\u7a0b\u4f7f\u7528\u7b2c\u4e09\u65b9\u5de5\u5177\uff1ahtop\uff1a\u4ea4\u4e92\u5f0f\u663e\u793a\u7cfb\u7edf\u6240\u6709\u8fdb\u7a0b\u548c\u7ebf\u7a0b\u4fe1\u606f\uff0c\u5305\u62ec\u7ebf\u7a0b\u6570atop\uff1a\u7cfb\u7edf\u6027\u80fd\u76d1\u63a7\u5de5\u5177\uff0c\u663e\u793a\u7cfb\u7edf\u6240 Linux \u4e2d\u67e5\u770b\u7ebf\u7a0b\u6570\u7684\u65b9\u6cd5 1. \u67e5\u770b\u7279\u5b9a\u8fdb\u7a0b\u7684\u7ebf\u7a0b\u6570 ps -eLf | grep PID \u6b64\u547d\u4ee4\u5c06\u663e\u793a\u8fdb\u7a0b PID \u7684\u7ebf\u7a0b\u6570\uff0c\u5176\u4e2d\uff1a -e\uff1a\u663e\u793a\u6240\u6709\u8fdb\u7a0b -Lf\uff1a\u663e\u793a\u8be6\u7ec6\u4fe1\u606f\uff0c\u5305\u62ec\u7ebf\u7a0b\u4fe1\u606f PID\uff1a\u8981\u68c0\u67e5\u7684\u8fdb\u7a0b ID top -H -p PID \u6b64\u547d\u4ee4\u542f\u52a8\u4ea4\u4e92\u5f0f top \u5b9e\u7528\u7a0b\u5e8f\uff0c\u5e76\u663e\u793a\u6307\u5b9a\u8fdb\u7a0b PID \u7684\u7ebf\u7a0b\u6570\u3002 2. \u67e5\u770b\u7cfb\u7edf\u4e2d\u7684\u6240\u6709\u7ebf\u7a0b\u6570 grep ^Threads \/proc\/stat \u6b64\u547d\u4ee4\u4ece \/proc\/stat \u6587\u4ef6\u4e2d\u68c0\u7d22\u7cfb\u7edf\u4e2d\u6240\u6709\u7ebf\u7a0b\u6570\u7684\u4fe1\u606f\u3002 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-63656","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/63656","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=63656"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/63656\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=63656"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=63656"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=63656"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}