{"id":204803,"date":"2020-11-18T08:17:56","date_gmt":"2020-11-18T00:17:56","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=204803"},"modified":"2020-11-05T16:18:40","modified_gmt":"2020-11-05T08:18:40","slug":"linux-average-load","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/linux-average-load.html","title":{"rendered":"Linux\u5e73\u5747\u8d1f\u8f7d\u641e\u901a\u900f\uff01"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u5e73\u5747\u8d1f\u8f7d\u53ef\u4ee5\u5bf9\u4e8e\u6211\u4eec\u6765\u8bf4\u53ca\u719f\u6089\u53c8\u964c\u751f\uff0c\u4f46\u6211\u4eec\u95ee\u5e73\u5747\u8d1f\u8f7d\u662f\u4ec0\u4e48\uff0c\u4f46\u5927\u90e8\u5206\u4eba\u90fd\u56de\u7b54\u8bf4\u5e73\u5747\u8d1f\u8f7d\u4e0d\u5c31\u662f\u5355\u4f4d\u65f6\u95f4\u5185CPU\u4f7f\u7528\u7387\u5417\uff1f\u5176\u5b9e\u5e76\u4e0d\u662f\u8fd9\u6837\u7684\uff0c\u5982\u679c\u53ef\u4ee5\u7684\u8bdd\uff0c\u53ef\u4ee5 man uptime \u6765\u4e86\u89e3\u4e00\u4e0b\u5e73\u5747\u8d1f\u8f7d\u7684\u8be6\u7ec6\u4fe1\u606f\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\u4ec0\u4e48\u662f\u5e73\u5747\u8d1f\u8f7d<\/strong><\/div>\n

\u5e73\u5747\u8d1f\u8f7d\u53ef\u4ee5\u5bf9\u4e8e\u6211\u4eec\u6765\u8bf4\u53ca\u719f\u6089\u53c8\u964c\u751f\uff0c\u4f46\u6211\u4eec\u95ee\u5e73\u5747\u8d1f\u8f7d\u662f\u4ec0\u4e48\uff0c\u4f46\u5927\u90e8\u5206\u4eba\u90fd\u56de\u7b54\u8bf4\u5e73\u5747\u8d1f\u8f7d\u4e0d\u5c31\u662f\u5355\u4f4d\u65f6\u95f4\u5185CPU\u4f7f\u7528\u7387\u5417\uff1f\u5176\u5b9e\u5e76\u4e0d\u662f\u8fd9\u6837\u7684\uff0c\u5982\u679c\u53ef\u4ee5\u7684\u8bdd\uff0c\u53ef\u4ee5 man uptime \u6765\u4e86\u89e3\u4e00\u4e0b\u5e73\u5747\u8d1f\u8f7d\u7684\u8be6\u7ec6\u4fe1\u606f\u3002<\/p>\n

\u7b80\u5355\u7684\u8bf4\u5e73\u5747\u8d1f\u8f7d\u662f\u6307\u5355\u4f4d\u65f6\u95f4\u5185\uff0c\u7cfb\u7edf\u5904\u4e8e\u53ef\u8fd0\u884c\u72b6\u6001\u548c\u4e0d\u53ef\u4e2d\u65ad\u72b6\u6001\u7684\u5e73\u5747\u8fdb\u7a0b\u6570\uff0c\u4e5f\u5c31\u662f\u8bf4\u5e73\u5747\u6d3b\u8dc3\u8fdb\u7a0b\u6570\uff0c\u5b83\u548cCPU\u4f7f\u7528\u7387\u5e76\u6ca1\u6709\u76f4\u63a5\u5173\u7cfb\u3002\u8fd9\u91cc\u89e3\u91ca\u4e00\u4e0b\u53ef\u8fd0\u884c\u72b6\u6001\u548c\u4e0d\u53ef\u4e2d\u65ad\u8fd9\u4e24\u4e2a\u8bcd\u3002<\/p>\n

\"\"<\/p>\n

\u53ef\u8fd0\u884c\u72b6\u6001\uff1a<\/strong><\/span><\/div>\n

\u6307\u6b63\u5728\u4f7f\u7528CPU\u6216\u8005\u6b63\u5728\u7b49\u5f85CPU\u7684\u8fdb\u7a0b\uff0c\u6211\u4eec\u4f7f\u7528ps\u547d\u4ee4\u67e5\u770b\u5904\u4e8eR\u72b6\u6001\u7684\u8fdb\u7a0b<\/p>\n

\u4e0d\u53ef\u4e2d\u65ad\u72b6\u6001\uff1a<\/strong><\/span><\/div>\n

\u8fdb\u7a0b\u5219\u662f\u6b63\u5904\u4e8e\u5185\u6838\u6001\u5173\u952e\u6d41\u7a0b\u4e2d\u7684\u8fdb\u7a0b\uff0c\u5e76\u4e14\u8fd9\u4e9b\u6d41\u7a0b\u662f\u4e0d\u53ef\u4e2d\u65ad\u7684\u3002\u4f8b\u5982\uff1a\u5e38\u89c1\u7684\u7b49\u5f85\u786c\u4ef6\u8bbe\u5907I\/O\u7684\u54cd\u5e94\uff0c\u4e5f\u5c31\u662f\u6211\u4eec\u5728ps\u547d\u4ee4\u67e5\u770b\u5904\u4e8eD\u72b6\u6001\u7684\u8fdb\u7a0b<\/p>\n

\u6bd4\u5982\uff0c\u5f53\u4e00\u4e2a\u8fdb\u7a0b\u5411\u78c1\u76d8\u8bfb\u5199\u6570\u636e\u65f6\uff0c\u4e3a\u4e86\u4fdd\u8bc1\u6570\u636e\u7684\u4e00\u81f4\u6027\uff0c\u5728\u5f97\u5230\u78c1\u76d8\u56de\u590d\u524d\uff0c\u5b83\u662f\u4e0d\u80fd\u88ab\u5176\u4ed6\u8fdb\u7a0b\u4e2d\u65ad\u6216\u8005\u6253\u65ad\u7684\uff0c\u8fd9\u4e2a\u65f6\u5019\u7684\u8fdb\u7a0b\u5904\u4e8e\u4e0d\u53ef\u4e2d\u65ad\u72b6\u6001\uff0c\u5982\u679c\u6b64\u65f6\u7684\u8fdb\u7a0b\u88ab\u6253\u65ad\u4e86\uff0c\u5c31\u5bb9\u6613\u51fa\u73b0\u78c1\u76d8\u6570\u636e\u548c\u8fdb\u7a0b\u6570\u636e\u4e0d\u4e00\u81f4\u7684\u95ee\u9898\u3002<\/p>\n

\u6240\u4ee5\uff0c\u4e0d\u53ef\u4e2d\u65ad\u72b6\u6001\u5b9e\u9645\u4e0a\u662f\u7cfb\u7edf\u8fdb\u7a0b\u548c\u786c\u4ef6\u8bbe\u5907\u7684\u4e00\u79cd\u4fdd\u62a4\u673a\u5236\u3002<\/p>\n

\u56e0\u6b64\uff0c\u4f60\u53ef\u4ee5\u7b80\u5355\u7406\u89e3\u4e3a\uff0c\u5e73\u5747\u8d1f\u8f7d\u5c31\u662f\u5e73\u5747\u6d3b\u8dc3\u8fdb\u7a0b\u6570\u3002\u5e73\u5747\u6d3b\u8dc3\u8fdb\u7a0b\u6570\uff0c\u76f4\u89c2\u4e0a\u7684\u7406\u89e3\u5c31\u662f\u5355\u4f4d\u65f6\u95f4\u5185\u7684\u6d3b\u8dc3\u8fdb\u7a0b\u6570\uff0c\u4f46\u5b83\u5b9e\u9645\u4e0a\u662f\u6d3b\u8dc3\u8fdb\u7a0b\u6570\u7684\u6307\u6570\u8870\u51cf\u5e73\u5747\u503c\u3002\u65e2\u7136\u662f\u5e73\u5747\u6d3b\u8dc3\u8fdb\u7a0b\u6570\uff0c\u90a3\u4e48\u7406\u60f3\u72b6\u6001\uff0c\u5c31\u662f\u6bcf\u4e2aCPU\u4e0a\u90fd\u521a\u597d\u8fd0\u884c\u7740\u4e00\u4e2a\u8fdb\u7a0b\uff0c\u8fd9\u6837\u6bcf\u4e2aCPU\u90fd\u4f1a\u5f97\u5230\u5145\u5206\u7684\u5229\u7528\u3002\u4f8b\u5982\u5e73\u5747\u8d1f\u8f7d\u4e3a2\u65f6\uff0c\u610f\u5473\u7740\u4ec0\u4e48\u5462\uff1f<\/p>\n

\u5728\u53ea\u67092\u4e2aCPU\u7684\u7cfb\u7edf\u4e0a\uff0c\u610f\u5473\u7740\u6240\u6709\u7684CPU\u521a\u597d\u88ab\u5b8c\u5168\u5360\u7528<\/p>\n

\u57284\u4e2aCPU\u7684\u7cfb\u7edf\u4e0a\uff0c\u610f\u5473\u7740CPU\u670950%\u7684\u7a7a\u95f2<\/p>\n

\u800c\u5728\u53ea\u67091\u4e2aCPU\u7684\u7cfb\u7edf\u4e0a\uff0c\u5219\u610f\u5473\u7740\u6709\u4e00\u534a\u7684\u8fdb\u7a0b\u7ade\u4e89\u4e0d\u5230CPU<\/p>\n

\u5e73\u5747\u8d1f\u8f7d\u548cCPU\u4f7f\u7528\u7387<\/strong><\/div>\n

\u73b0\u5b9e\u5de5\u4f5c\u4e2d\uff0c\u6211\u4eec\u7ecf\u5e38\u5bb9\u6613\u628a\u5e73\u5747\u8d1f\u8f7d\u548cCPU\u4f7f\u7528\u7387\u6df7\u6dc6\uff0c\u6240\u4ee5\u5728\u8fd9\u91cc\uff0c\u6211\u4e5f\u505a\u4e00\u4e2a\u5206\u533a\u3002<\/p>\n

\u53ef\u80fd\u4f60\u4f1a\u7591\u60d1\uff0c\u65e2\u7136\u5e73\u5747\u8d1f\u8f7d\u4ee3\u8868\u7684\u662f\u6d3b\u8dc3\u8fdb\u7a0b\u6570\uff0c\u90a3\u5e73\u5747\u8d1f\u8f7d\u9ad8\u4e86\uff0c\u4e0d\u5c31\u610f\u5473\u7740CPU\u4f7f\u7528\u7387\u9ad8\u5417\uff1f<\/p>\n

\u6211\u4eec\u8fd8\u662f\u8981\u56de\u5230\u5e73\u5747\u8d1f\u8f7d\u7684\u542b\u4e49\u4e0a\u6765\uff0c\u5e73\u5747\u8d1f\u8f7d\u662f\u6307\u5355\u4f4d\u65f6\u95f4\u5185\uff0c\u5904\u4e8e\u53ef\u8fd0\u884c\u72b6\u6001\u548c\u4e0d\u53ef\u4e2d\u65ad\u72b6\u6001\u7684\u8fdb\u7a0b\u6570\uff0c\u6240\u4ee5\uff0c\u5b83\u4e0d\u4ec5\u5305\u62ec\u4e86\u6b63\u5e38\u4f7f\u7528CPU\u7684\u8fdb\u7a0b\uff0c\u8fd8\u5305\u62ec\u4e86\u7b49\u5f85CPU\u548c\u7b49\u5f85I\/O\u7684\u8fdb\u7a0b\u3002<\/p>\n

\u800cCPU\u4f7f\u7528\u7387\uff0c\u662f\u5355\u4f4d\u65f6\u95f4\u5185CPU\u7684\u7e41\u5fd9\u60c5\u51b5\u7684\u7edf\u8ba1\uff0c\u8ddf\u5e73\u5747\u8d1f\u8f7d\u5e76\u4e0d\u4e00\u5b9a\u5b8c\u5168\u5bf9\u5e94\uff0c\u4f8b\u5982\uff1a<\/p>\n

CPU\u5bc6\u96c6\u578b\u8fdb\u7a0b\uff0c\u4f7f\u7528\u5927\u91cfCPU\u4f1a\u5bfc\u81f4\u5e73\u5747\u8d1f\u8f7d\u5347\u9ad8\uff0c\u6b64\u65f6\u8fd9\u4e24\u8005\u662f\u4e00\u81f4\u7684<\/p>\n

I\/O\u5bc6\u96c6\u578b\u8fdb\u7a0b\uff0c\u7b49\u5f85I\/O\u4e5f\u4f1a\u5bfc\u81f4\u5e73\u5747\u8d1f\u8f7d\u5347\u9ad8\uff0c\u4f46CPU\u4f7f\u7528\u7387\u4e0d\u4e00\u5b9a\u5f88\u9ad8<\/p>\n

\u5927\u91cf\u7b49\u5f85CPU\u7684\u8fdb\u7a0b\u8c03\u5ea6\u4e5f\u4f1a\u5bfc\u81f4\u5e73\u5747\u8d1f\u8f7d\u5347\u9ad8\uff0c\u6b64\u65f6\u7684CPU\u4f7f\u7528\u7387\u4f1a\u5f88\u9ad8<\/p>\n

\u5e73\u5747\u8d1f\u8f7d\u6848\u4f8b<\/strong><\/div>\n

\u8fd9\u91cc\u6211\u4eec\u9700\u8981\u5b89\u88c5\u51e0\u4e2a\u5de5\u5177sysstat\u3001stress\u3001stress-ng<\/p>\n

\u8fd9\u91ccCentos\u7684sysstat\u7248\u672c\u4f1a\u8001\u4e00\u70b9\uff0c\u6700\u597d\u5347\u7ea7\u5230\u6700\u65b0\u7248\u672c\u3002\u624b\u52a8rpm\u5b89\u88c5\u6216\u8005\u6e90\u7801\u5b89\u88c5<\/p>\n

\u573a\u666f\u4e00\u3001CPU\u5bc6\u96c6\u578b<\/strong><\/span><\/div>\n

1\u3001\u8fd0\u884c\u4e00\u4e2astress\u547d\u4ee4\uff0c\u6a21\u62df\u4e00\u4e2aCPU\u4f7f\u7528\u7387100%\u573a\u666f<\/p>\n

$ stress --cpu 1 --timeout 600 <\/pre>\n

2\u3001\u5f00\u542f\u7b2c\u4e8c\u4e2a\u7ec8\u7aef\uff0cuptime\u67e5\u770b\u5e73\u5747\u8d1f\u8f7d\u7684\u53d8\u5316\u60c5\u51b5<\/p>\n

$ watch -d uptime <\/pre>\n

09:40:35 up 80 days, 18:41, 2 users, load average: 1.62, 1.10, 0.87
\n3\u3001\u5f00\u542f\u7b2c\u4e09\u4e2a\u7ec8\u7aef\uff0cmpstat \u67e5\u770bCPU\u4f7f\u7528\u7387\u7684\u53d8\u5316\u60c5\u51b5<\/p>\n

\r\n$ mpstat -P ALL 5 20 \r\n \r\n10:06:37 AM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle \r\n \r\n10:06:42 AM all 31.50 0.00 0.35 0.00 0.00 0.00 0.00 0.00 0.00 68.15 \r\n \r\n10:06:42 AM 0 1.20 0.00 0.80 0.00 0.00 0.00 0.00 0.00 0.00 98.00 \r\n \r\n10:06:42 AM 1 7.21 0.00 0.40 0.00 0.00 0.00 0.00 0.00 0.00 92.38 \r\n \r\n10:06:42 AM 2 100.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 \r\n \r\n10:06:42 AM 3 17.43 0.00 0.20 0.00 0.00 0.00 0.00 0.00 0.00 82.36 \r\n# -P ALL \u8868\u793a\u76d1\u63a7\u6240\u6709CPU\uff0c\u540e\u9762\u6570\u5b575 \u8868\u793a\u95f4\u96945\u79d2\u8f93\u51fa\u4e00\u6b21\u6570\u636e<\/pre>\n

\u4ece\u7b2c\u4e8c\u4e2a\u7ec8\u7aef\u53ef\u4ee5\u770b\u5230\uff0c1\u5206\u949f\u5e73\u5747\u8d1f\u8f7d\u589e\u52a0\u52301.62\uff0c\u4ece\u7b2c\u4e09\u4e2a\u7ec8\u7aef\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u6709\u4e00\u4e2aCPU\u4f7f\u7528\u7387100%\uff0c\u4f46iowait\u4e3a0\uff0c\u8fd9\u8bf4\u660e\u5e73\u5747\u8d1f\u8f7d\u7684\u5347\u9ad8\u6b63\u5f0f\u7531CPU\u4f7f\u7528\u7387\u4e3a100%<\/p>\n

\u90a3\u6211\u4eec\u67e5\u770b\u662f\u90a3\u4e2a\u8fdb\u7a0b\u5bfc\u81f4\u4e86CPU\u4f7f\u7528\u7387\u4e3a100%\u5462\uff1f\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528pidstat\u6765\u67e5\u770b\uff1a<\/p>\n

#\u6bcf5\u79d2\u8f93\u51fa\u4e00\u6b21\u6570\u636e <\/p>\n

\r\n$ pidstat -u 5 1 \r\n \r\n10:08:41 AM UID PID %usr %system %guest %wait %CPU CPU Command \r\n \r\n10:08:46 AM 0 1 0.20 0.00 0.00 0.00 0.20 0 systemd \r\n \r\n10:08:46 AM 0 599 0.00 1.00 0.00 0.20 1.00 0 systemd-journal \r\n \r\n10:08:46 AM 0 1043 0.60 0.00 0.00 0.00 0.60 0 rsyslogd \r\n \r\n10:08:46 AM 0 6863 100.00 0.00 0.00 0.00 100.00 3 stress \r\n \r\n10:08:46 AM 0 7303 0.20 0.20 0.00 0.00 0.40 2 pidstat <\/pre>\n

\u4ece\u8fd9\u91cc\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u662fstress\u8fd9\u4e2a\u8fdb\u7a0b\u5bfc\u81f4\u7684\u3002<\/p>\n

\u573a\u666f\u4e8c\u3001I\/O\u5bc6\u96c6\u578b\u8fdb\u7a0b<\/strong><\/span><\/div>\n

1\u3001\u6211\u4eec\u4f7f\u7528stress-ng\u547d\u4ee4\uff0c\u4f46\u8fd9\u6b21\u6a21\u62dfI\/O\u538b\u529b\uff0c\u65e2\u4e0d\u505c\u6267\u884csync:<\/p>\n

\r\n#--hdd\u8868\u793a\u8bfb\u5199\u4e34\u65f6\u6587\u4ef6 \r\n \r\n#-i \u751f\u6210\u51e0\u4e2aworker\u5faa\u73af\u8c03\u7528sync()\u4ea7\u751fio\u538b\u529b \r\n \r\n$ stress-ng -i 4 --hdd 1 --timeout 600 <\/pre>\n

2\u3001\u5f00\u542f\u7b2c\u4e8c\u4e2a\u7ec8\u7aef\u8fd0\u884cuptime\u67e5\u770b\u5e73\u5747\u8d1f\u8f7d\u60c5\u51b5<\/p>\n

\r\n$ watch -d uptime \r\n \r\n10:30:57 up 98 days, 19:39, 3 users, load average: 1.71, 0.75, 0.69 <\/pre>\n

3\u3001\u5f00\u542f\u7b2c\u4e09\u4e2a\u7ec8\u7aef\u8fd0\u884cmpstat\u67e5\u770bCPU\u4f7f\u7528\u7387<\/p>\n

\r\n$ mpstat -P ALL 5 20 \r\n \r\n10:32:09 AM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle \r\n \r\n10:32:14 AM all 6.80 0.00 33.75 26.16 0.00 0.39 0.00 0.00 0.00 32.90 \r\n \r\n10:32:14 AM 0 4.03 0.00 69.57 19.91 0.00 0.00 0.00 0.00 0.00 6.49 \r\n \r\n10:32:14 AM 1 25.32 0.00 9.49 0.00 0.00 0.95 0.00 0.00 0.00 64.24 \r\n \r\n10:32:14 AM 2 0.24 0.00 10.87 63.04 0.00 0.48 0.00 0.00 0.00 25.36 \r\n \r\n10:32:14 AM 3 1.42 0.00 36.93 14.20 0.00 0.28 0.00 0.00 0.00 47.16 <\/pre>\n

\u4ece\u8fd9\u91cc\u53ef\u4ee5\u770b\u5230\uff0c1\u5206\u949f\u5e73\u5747\u8d1f\u8f7d\u4f1a\u6162\u6162\u589e\u52a0\u52301.71\uff0c\u5176\u4e2d\u4e00\u4e2aCPU\u7684\u7cfb\u7edfCPU\u4f7f\u7528\u7387\u5347\u523063.04\u3002\u8fd9\u8bf4\u660e\uff0c\u5e73\u5747\u8d1f\u8f7d\u7684\u5347\u9ad8\u662f\u7531\u4e8eiowait\u5347\u9ad8\u3002<\/p>\n

\u90a3\u4e48\u6211\u4eec\u5230\u5e95\u662f\u54ea\u4e2a\u8fdb\u7a0b\u5bfc\u81f4\u7684\u5462\uff1f\u6211\u4eec\u4f7f\u7528pidstat\u6765\u67e5\u770b\uff1a<\/p>\n

\r\n$ pidstat -u 5 1 \r\n \r\nAverage: UID PID %usr %system %guest %wait %CPU CPU Command \r\n \r\nAverage: 0 1 0.00 0.19 0.00 0.00 0.19 - systemd \r\n \r\nAverage: 0 10 0.00 0.19 0.00 1.56 0.19 - rcu_sched \r\n \r\nAverage: 0 599 0.58 1.75 0.00 0.39 2.33 - systemd-journal \r\n \r\nAverage: 0 1043 0.19 0.19 0.00 0.00 0.39 - rsyslogd \r\n \r\nAverage: 0 6934 0.00 1.56 0.00 1.17 1.56 - kworker\/2:0-events_power_efficient \r\n \r\nAverage: 0 7383 0.00 0.39 0.00 0.78 0.39 - kworker\/1:0-events_power_efficient \r\n \r\nAverage: 0 9411 0.00 0.19 0.00 0.58 0.19 - kworker\/0:0-events \r\n \r\nAverage: 0 9662 0.00 97.67 0.00 0.19 97.67 - kworker\/u8:0+flush-253:0 \r\n \r\nAverage: 0 10793 0.00 0.97 0.00 1.56 0.97 - kworker\/3:2-mm_percpu_wq \r\n \r\nAverage: 0 11062 0.00 21.79 0.00 0.19 21.79 - stress-ng-hdd \r\n \r\nAverage: 0 11063 0.00 1.95 0.00 1.36 1.95 - stress-ng-io \r\n \r\nAverage: 0 11064 0.00 2.72 0.00 0.39 2.72 - stress-ng-io \r\n \r\nAverage: 0 11065 0.00 1.36 0.00 1.75 1.36 - stress-ng-io \r\n \r\nAverage: 0 11066 0.00 2.72 0.00 0.58 2.72 - stress-ng-io \r\n<\/pre>\n

\u53ef\u4ee5\u53d1\u73b0\u662fstress-ng\u5bfc\u81f4\u7684<\/p>\n

\u573a\u666f\u4e09\u3001\u5927\u91cf\u8fdb\u7a0b\u7684\u573a\u666f<\/strong><\/span><\/div>\n

\u5f53\u7cfb\u7edf\u4e2d\u8fd0\u884c\u8fdb\u7a0b\u8d85\u51faCPU\u8fd0\u884c\u80fd\u529b\u65f6\uff0c\u5c31\u4f1a\u51fa\u73b0\u7b49\u5f85CPU\u7684\u8fdb\u7a0b\u3002<\/p>\n

\u6bd4\u5982\uff1a\u6211\u4eec\u4f7f\u7528stress,\u4f46\u8fd9\u6b21\u6a21\u62df8\u4e2a\u8fdb\u7a0b\uff1a<\/p>\n

\r\n$ stress -c 8 --timeout 600 <\/pre>\n

\u6211\u4eec\u7684\u7cfb\u7edf\u53ea\u67094\u9897CPU\uff0c\u8fd9\u65f6\u5019\u8981\u8fd0\u884c8\u4e2a\u8fdb\u7a0b\uff0c\u662f\u660e\u663e\u4e0d\u591f\u7684\uff0c\u7cfb\u7edf\u7684CPU\u540e\u4e25\u91cd\u8fc7\u8f7d,\u8fd9\u65f6\u5019\u8d1f\u8f7d\u503c\u8fbe\u5230\u4e864\u70b9\u591a\uff1a<\/p>\n

\r\n$ uptime \r\n \r\n10:56:22 up 98 days, 20:05, 3 users, load average: 4.52, 2.82, 2.67 <\/pre>\n

\u63a5\u7740\u6211\u4eec\u8fd0\u884cpidstat\u6765\u67e5\u770b\u4e00\u4e0b\u8fdb\u7a0b\u7684\u60c5\u51b5\uff1a<\/p>\n

\r\n$ pidstat -u 5 1 \r\n \r\nLinux 5.0.5-1.el7.elrepo.x86_64 (k8s-m1) 07\/11\/2019 _x86_64_ (4 CPU) \r\n \r\n10:57:33 AM UID PID %usr %system %guest %wait %CPU CPU Command \r\n \r\n10:57:38 AM 0 1 0.20 0.00 0.00 0.00 0.20 1 systemd \r\n \r\n10:57:38 AM 0 599 0.00 0.99 0.00 0.20 0.99 2 systemd-journal \r\n \r\n10:57:38 AM 0 1043 0.60 0.20 0.00 0.00 0.79 1 rsyslogd \r\n \r\n10:57:38 AM 0 12927 51.59 0.00 0.00 48.21 51.59 0 stress \r\n \r\n10:57:38 AM 0 12928 44.64 0.00 0.00 54.96 44.64 0 stress \r\n \r\n10:57:38 AM 0 12929 45.44 0.00 0.00 54.56 45.44 2 stress \r\n \r\n10:57:38 AM 0 12930 45.44 0.00 0.00 54.37 45.44 2 stress \r\n \r\n10:57:38 AM 0 12931 51.59 0.00 0.00 48.21 51.59 3 stress \r\n \r\n10:57:38 AM 0 12932 48.41 0.00 0.00 51.19 48.41 1 stress \r\n \r\n10:57:38 AM 0 12933 45.24 0.00 0.00 54.37 45.24 3 stress \r\n \r\n10:57:38 AM 0 12934 48.81 0.00 0.00 50.99 48.81 1 stress \r\n \r\n10:57:38 AM 0 13083 0.00 0.40 0.00 0.20 0.40 0 pidstat <\/pre>\n

\u53ef\u4ee5\u770b\u51fa\uff0c8\u4e2a\u8fdb\u7a0b\u62a2\u53604\u9897CPU\uff0c\u6bcf\u4e2a\u8fdb\u7a0b\u7b49\u5230CPU\u65f6\u95f4(%wait)\u9ad8\u8fbe50%\uff0c\u8fd9\u4e9b\u90fd\u8d85\u51faCPU\u8ba1\u7b97\u80fd\u529b\u7684\u8fdb\u7a0b\uff0c\u6700\u7ec8\u5bfc\u81f4CPU\u8fc7\u8f7d\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u5e73\u5747\u8d1f\u8f7d\u53ef\u4ee5\u5bf9\u4e8e\u6211\u4eec\u6765\u8bf4\u53ca\u719f\u6089\u53c8\u964c\u751f\uff0c\u4f46\u6211\u4eec\u95ee\u5e73\u5747\u8d1f\u8f7d\u662f\u4ec0\u4e48\uff0c\u4f46\u5927\u90e8\u5206\u4eba\u90fd\u56de\u7b54\u8bf4\u5e73\u5747\u8d1f\u8f7d\u4e0d\u5c31\u662f\u5355\u4f4d\u65f6\u95f4\u5185CPU […]<\/p>\n","protected":false},"author":317,"featured_media":202541,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-204803","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/204803","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/317"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=204803"}],"version-history":[{"count":1,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/204803\/revisions"}],"predecessor-version":[{"id":204805,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/204803\/revisions\/204805"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/202541"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=204803"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=204803"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=204803"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}