{"id":172,"date":"2008-03-13T16:59:30","date_gmt":"2008-03-13T00:59:30","guid":{"rendered":"http:\/\/blog.longwin.com.tw\/?p=172"},"modified":"2008-03-13T16:59:30","modified_gmt":"2008-03-13T00:59:30","slug":"linux-cpu","status":"publish","type":"post","link":"https:\/\/blog.fhl.net\/?p=172","title":{"rendered":"Linux cpu\u6eab\u5ea6\u8b66\u544a"},"content":{"rendered":"<p>\n\u6211\u5011\u5229\u7528lm_sensors\u4f86\u5075\u6e2cCPU\u6eab\u5ea6\uff0c\u4f5c\u6cd5\u5927\u7565\u5982\u4e0b\uff1a\n<\/p>\n<p>\n\u5b89\u88dd lm_sensors\n<\/p>\n<p>\nyum -y install lm_sensors&nbsp;\n<\/p>\n<p>\n\u8981\u7cfb\u7d71\u81ea\u52d5\u5075\u6e2c sensors\n<\/p>\n<p>\n&nbsp;\/usr\/sbin\/sensors-detect\n<\/p>\n<p>\n\u4e00\u8def&nbsp; yes \u5230\u6700\u5f8c\n<\/p>\n<p>\n\u555f\u52d5daemon\n<\/p>\n<p>\n&nbsp;\/etc\/init.d\/lm_sensors start\n<\/p>\n<p>\n\u6253 \/usr\/bin\/sensors&nbsp; \u6e2c\u8a66\n<\/p>\n<p>\n\u5982\u679c\u51fa\u73fe\u6eab\u5ea6\uff0c\u5c31\u8868\u793a\u8a2d\u5b9a\u6b63\u78ba\uff0c\u53ef\u4ee5\u6253\u5165\u4e0b\u9762\u9019\u4e00\u884c\u8b93\n<\/p>\n<p>\nchkconfig &#8211;add&nbsp; lm_sensors\n<\/p>\n<p>\ndaemon\u958b\u6a5f\u81ea\u52d5\u555f\u52d5\n<\/p>\n<p>\n\u6700\u5f8c\u6211\u5011\u7528\u9019\u500b php script\u4f86\u5075\u6e2c\u6eab\u5ea6\u72c0\u6cc1\uff1a\n<\/p>\n<p>\n&nbsp;#!\/usr\/local\/bin\/php -q<br \/>\n&lt;?php<br \/>\n$target=array(&#8216;Core 0:&#8217;,&#8217;Core 1:&#8217;,&#8217;Core 2:&#8217;,&#8217;Core 3:&#8217;);<br \/>\n&nbsp; $alarm=65;<br \/>\n&nbsp; $inp=file(&#8216;php:\/\/stdin&#8217;);<br \/>\n&nbsp; $cnt=count($inp);<br \/>\n&nbsp; $tcnt=count($target);<br \/>\n&nbsp; for ($i=0;$i&lt;$cnt;$i=$i+1)<br \/>\n&nbsp; {<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for ($j=0;$j&lt;$tcnt;$j=$j+1)<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (strncmp($target[$j],$inp[$i],strlen($target[$j]))==0)<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {\/\/matched<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $c=(float) substr($inp[$i],strlen($target[$j]));<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \/\/echo $c.&quot;\\n&quot;;<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ($c&gt; $alarm) \/\/alarm on<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit(1);<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br \/>\n&nbsp; }<br \/>\n&nbsp; exit(0);<br \/>\n?&gt;\n<\/p>\n<p>\n\u9019\u500bscript\u6aa2\u67e5\u56db\u500b\u6838\u5fc3\u7684\u6eab\u5ea6\uff0c\u7136\u5f8c\u5982\u679c\u5927\u65bc $alarm \u8a2d\u5b9a\u7684\u6eab\u5ea6\uff0c\u5c31\u56de\u50b3 1 \u5426\u5247\u56de\u50b30\uff0c\u4f7f\u7528\u7684\u65b9\u6cd5\u662f\n<\/p>\n<p>\n&nbsp; \/usr\/bin\/sensors| \/xxxdir\/Temp.sh\n<\/p>\n<p>\n&nbsp;\u9019\u6a23\uff0c\u5c31\u53ef\u4ee5\u6b63\u78ba\u56de\u50b3CPU\u7684\u72c0\u6cc1\u4e86\u3002\n<\/p>\n<p>\n&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6211\u5011\u5229\u7528lm_sensors\u4f86\u5075\u6e2cCPU\u6eab\u5ea6\uff0c\u4f5c\u6cd5\u5927\u7565\u5982\u4e0b\uff1a \u5b89\u88dd lm_sensors yum -y ins &hellip; <a href=\"https:\/\/blog.fhl.net\/?p=172\" class=\"more-link\">\u95b1\u8b80\u5168\u6587 <span class=\"screen-reader-text\">Linux cpu\u6eab\u5ea6\u8b66\u544a<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[],"class_list":["post-172","post","type-post","status-publish","format-standard","hentry","category-e"],"_links":{"self":[{"href":"https:\/\/blog.fhl.net\/index.php?rest_route=\/wp\/v2\/posts\/172","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.fhl.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.fhl.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.fhl.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.fhl.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=172"}],"version-history":[{"count":0,"href":"https:\/\/blog.fhl.net\/index.php?rest_route=\/wp\/v2\/posts\/172\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.fhl.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=172"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.fhl.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=172"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.fhl.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=172"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}