{"id":194,"date":"2024-02-11T12:51:21","date_gmt":"2024-02-11T04:51:21","guid":{"rendered":"https:\/\/www.xxiaoteng.cn\/?p=194"},"modified":"2026-05-11T21:15:46","modified_gmt":"2026-05-11T13:15:46","slug":"linux%e8%bf%90%e7%bb%b4%e6%97%a5%e5%b8%b8%e5%b7%a1%e6%a3%80","status":"publish","type":"post","link":"https:\/\/www.xxiaoteng.cn\/?p=194","title":{"rendered":"Linux\u8fd0\u7ef4\u65e5\u5e38\u5de1\u68c0"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" id=\"toc-0\">1\u3001\u4efb\u52a1\u573a\u666f<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u968f\u7740\u4f01\u4e1a\u4fe1\u606f\u5316\u548c\u4e91\u8ba1\u7b97\u6280\u672f\u7684\u5feb\u901f\u53d1\u5c55\uff0cLinux \u7cfb\u7edf\u5df2\u6210\u4e3a\u6838\u5fc3\u670d\u52a1\u5668\u5e73\u53f0\u3002\u7279\u522b\u662f <strong>CentOS Stream 9<\/strong>\uff0c\u4f5c\u4e3a\u4e00\u4e2a\u793e\u533a\u9a71\u52a8\u7684\u4f01\u4e1a\u7ea7\u64cd\u4f5c\u7cfb\u7edf\uff0c\u5176\u7a33\u5b9a\u6027\u548c\u5b89\u5168\u6027\u8981\u6c42\u8f83\u9ad8\u3002\u7cfb\u7edf\u5de1\u68c0\u548c\u5065\u5eb7\u68c0\u67e5\u5df2\u7ecf\u6210\u4e3a\u7cfb\u7edf\u7ba1\u7406\u7684\u91cd\u8981\u7ec4\u6210\u90e8\u5206\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u65e5\u5e38\u8fd0\u7ef4\u4e2d\uff0c\u7ba1\u7406\u5458\u5f80\u5f80\u9700\u8981\u5b9a\u671f\u6267\u884c\u4e00\u7cfb\u5217\u68c0\u67e5\u64cd\u4f5c\uff0c\u4f8b\u5982\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u68c0\u67e5 CPU\u3001\u5185\u5b58\u3001\u78c1\u76d8\u7684\u4f7f\u7528\u60c5\u51b5\u3002<\/li>\n\n\n\n<li>\u68c0\u67e5\u7cfb\u7edf\u8d1f\u8f7d\u3001\u6d3b\u52a8\u8fdb\u7a0b\u548c\u65e5\u5fd7\u4fe1\u606f\u3002<\/li>\n\n\n\n<li>\u786e\u4fdd\u9632\u706b\u5899\u3001SELinux \u7b49\u5b89\u5168\u8bbe\u7f6e\u7684\u6709\u6548\u6027\u3002<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u76ee\u524d\uff0c\u624b\u52a8\u6267\u884c\u8fd9\u4e9b\u68c0\u67e5\u4efb\u52a1\u8017\u65f6\u4e14\u5bb9\u6613\u51fa\u9519\uff0c\u56e0\u6b64\u9700\u8981\u4e00\u4e2a\u81ea\u52a8\u5316\u811a\u672c\u6765\u5b9a\u671f\u6267\u884c\u8fd9\u4e9b\u4efb\u52a1\uff0c\u5e76\u5c06\u68c0\u67e5\u7ed3\u679c\u4fdd\u5b58\u4e3a\u65e5\u5fd7\uff0c\u4ee5\u4f9b\u8fd0\u7ef4\u4eba\u5458\u67e5\u770b\u548c\u5206\u6790\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u95ee\u9898\u6709\u4e24\u4e2a\u65b9\u9762\uff1a\u2460 \u6bd4\u8f83\u957f\uff08\u62b5\u89e6\uff09\u2461 \u5927\u5bb6\u5bf9\u57fa\u7840\u547d\u4ee4\u4e0d\u591f\u719f\u6089<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc-1\">2\u3001\u4efb\u52a1\u62c6\u89e3<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">2.1 \u65e5\u5fd7\u6587\u4ef6\u8def\u5f84\u5b9a\u4e49 =&gt; LOGFILE=\/var\/log\/centos_stream_9_health_check.log<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2.2 \u5f00\u59cb\u68c0\u67e5\u5199\u5165\u65e5\u5fd7 =&gt; echo \"\u68c0\u67e5\u7ed3\u679c\" &gt;&gt; $LOGFILE<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2.3 \u7cfb\u7edf\u8d1f\u8f7d\u68c0\u67e5 =&gt; uptime<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2.4 CPU \u4f7f\u7528\u60c5\u51b5\u68c0\u67e5 =&gt; top(\u9700\u8981\u81ea\u5df1\u5904\u7406\uff0c\u83b7\u53d6cpu\u4f7f\u7528\u7387)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2.5 \u5185\u5b58\u4f7f\u7528\u60c5\u51b5\u68c0\u67e5 =&gt; free -h<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2.6 \u78c1\u76d8\u4f7f\u7528\u60c5\u51b5\u68c0\u67e5 =&gt; df -h<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2.7 \u6d3b\u52a8\u8fdb\u7a0b\u68c0\u67e5 =&gt; ps aux<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2.8 \u6700\u8fd1\u7684\u7cfb\u7edf\u65e5\u5fd7\u68c0\u67e5 =&gt; journalctl -n 10<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2.9 \u7cfb\u7edf\u66f4\u65b0\u68c0\u67e5 =&gt; dnf check-update<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2.10 SELinux \u72b6\u6001\u68c0\u67e5 =&gt; sestatus<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2.11 \u9632\u706b\u5899\u72b6\u6001\u68c0\u67e5 =&gt; firewall-cmd --state<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2.12 \u5f53\u524d\u6302\u8f7d\u7684\u78c1\u76d8\u68c0\u67e5 =&gt; lsblk<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2.13 Cron \u4efb\u52a1\u5217\u8868\u68c0\u67e5 =&gt; crontab -l<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2.14 \u7cfb\u7edf\u57fa\u672c\u4fe1\u606f\u68c0\u67e5 =&gt; hostname &amp;&amp; uname -r<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc-2\">3\u3001\u4efb\u52a1\u5b9e\u65bd<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"prettyprint\" >#!\/bin\/bash\n\n# \u5b9a\u4e49\u65e5\u5fd7\u6587\u4ef6\u8def\u5f84\nLOG_FILE=&quot;\/var\/log\/centos_stream_9_health_check.log&quot;\ncurrent_time=$(date +&quot;%Y-%m-%d %H:%M:%S&quot;)\n\n# \u5199\u5165\u65e5\u5fd7\u51fd\u6570\necho &quot;$current_time - Starting daily health check...&quot; &gt;&gt; $LOG_FILE\n\n# \u7cfb\u7edf\u8d1f\u8f7d\u68c0\u67e5\necho &quot;$current_time - System Load: $(uptime)&quot; &gt;&gt; $LOG_FILE\n\n# CPU \u4f7f\u7528\u60c5\u51b5\u68c0\u67e5\necho &quot;$current_time - CPU Usage: $(top -bn1 | grep &#039;Cpu(s)&#039; | cut -d&#039;,&#039; -f4 | cut -d&#039; &#039; -f2 | awk &#039;{print 100 - $1}&#039;)&quot; &gt;&gt; $LOG_FILE\n\n# \u5185\u5b58\u4f7f\u7528\u60c5\u51b5\u68c0\u67e5\necho &quot;$current_time - Memory Usage: $(free -h)&quot; &gt;&gt; $LOG_FILE\n\n# \u78c1\u76d8\u4f7f\u7528\u60c5\u51b5\u68c0\u67e5\necho &quot;$current_time - Disk Usage: $(df -h)&quot; &gt;&gt; $LOG_FILE\n\n# \u6d3b\u52a8\u8fdb\u7a0b\u68c0\u67e5\necho &quot;$current_time - Top 10 CPU consuming processes: $(ps aux --sort=-%cpu | head -n 10)&quot; &gt;&gt; $LOG_FILE\n\n# \u7f51\u7edc\u8fde\u63a5\u72b6\u6001\u68c0\u67e5\necho &quot;$current_time - Network Connections: $(ss -tunlp)&quot; &gt;&gt; $LOG_FILE\n\n# \u6700\u8fd1\u7684\u7cfb\u7edf\u65e5\u5fd7\u68c0\u67e5\necho &quot;$current_time - Recent System Logs: $(journalctl -n 10)&quot; &gt;&gt; $LOG_FILE\n\n# \u7cfb\u7edf\u66f4\u65b0\u68c0\u67e5\necho &quot;$current_time - System Updates: $(dnf check-update)&quot; &gt;&gt; $LOG_FILE\n\n# SELinux \u72b6\u6001\u68c0\u67e5\necho &quot;$current_time - SELinux Status: $(sestatus)&quot; &gt;&gt; $LOG_FILE\n\n# \u9632\u706b\u5899\u72b6\u6001\u68c0\u67e5\necho &quot;$current_time - Firewall Status: $(firewall-cmd --state)&quot; &gt;&gt; $LOG_FILE\n\n# \u5f53\u524d\u6302\u8f7d\u7684\u78c1\u76d8\u68c0\u67e5\necho &quot;$current_time - Mounted Disks: $(lsblk)&quot; &gt;&gt; $LOG_FILE\n\n# Cron \u4efb\u52a1\u5217\u8868\u68c0\u67e5\necho &quot;$current_time - Cron Jobs: $(crontab -l)&quot; &gt;&gt; $LOG_FILE\n\n# \u7cfb\u7edf\u57fa\u672c\u4fe1\u606f\u68c0\u67e5\necho &quot;$current_time - System Info: $(hostname &amp;&amp; uname -a)&quot; &gt;&gt; $LOG_FILE\n\n# \u5199\u5165\u65e5\u5fd7\u7ed3\u675f\necho &quot;$current_time - Health check completed.&quot; &gt;&gt; $LOG_FILE\n\nexit 0\n\n\n\u5907\u6ce8\uff1aps aux --sort=-%cpu\uff0c-%cpu\uff0c\u4ee3\u8868\u6309\u7167%cpu\u8fd9\u5217\u964d\u5e8f\u6392\u5217\uff0c-\u4ee3\u8868\u964d\u5e8f\u7684\u610f\u601d<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001\u4efb\u52a1\u573a\u666f \u968f\u7740\u4f01\u4e1a\u4fe1\u606f\u5316\u548c\u4e91\u8ba1\u7b97\u6280\u672f\u7684\u5feb\u901f\u53d1\u5c55\uff0cLinux \u7cfb\u7edf\u5df2\u6210\u4e3a\u6838\u5fc3\u670d\u52a1\u5668\u5e73\u53f0\u3002\u7279\u522b\u662f CentOS [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26,7,29],"tags":[],"class_list":["post-194","post","type-post","status-publish","format-standard","hentry","category-devops","category-linux","category-shell"],"_links":{"self":[{"href":"https:\/\/www.xxiaoteng.cn\/index.php?rest_route=\/wp\/v2\/posts\/194","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xxiaoteng.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xxiaoteng.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xxiaoteng.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xxiaoteng.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=194"}],"version-history":[{"count":1,"href":"https:\/\/www.xxiaoteng.cn\/index.php?rest_route=\/wp\/v2\/posts\/194\/revisions"}],"predecessor-version":[{"id":195,"href":"https:\/\/www.xxiaoteng.cn\/index.php?rest_route=\/wp\/v2\/posts\/194\/revisions\/195"}],"wp:attachment":[{"href":"https:\/\/www.xxiaoteng.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=194"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xxiaoteng.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=194"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xxiaoteng.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=194"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}