<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></title> 
<link>http://www.jackxiang.com/index.php</link> 
<description><![CDATA[赢在IT，Playin' with IT,Focus on Killer Application,Marketing Meets Technology.]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></copyright>
<item>
<link>http://www.jackxiang.com/post//</link>
<title><![CDATA[CentOS sensors软件监控主板CPU数据]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[WEB2.0]]></category>
<pubDate>Sun, 25 Jul 2010 08:33:53 +0000</pubDate> 
<guid>http://www.jackxiang.com/post//</guid> 
<description>
<![CDATA[ 
	xx对于电脑使用的玩家的常用软件，然后我就学习及深入的研究xx，在这里和大家一起探讨xx的使用方法，希望对大家有用。用MRTG监测Linux系统CPU温度<br/><br/>在Linux下有个叫CentOS sensors的软件可以帮助我们来监控主板，CPU的工作电压，风扇转速、温度等数据。这些数据我们通常在主板的 BIOS也可以看到。当我们可以在机器运行的时候通过CentOS sensors随时来监测着CPU的温度变化，可以预防呵保护因为CPU过热而会烧掉。<br/><br/>1. 安装CentOS sensors现在基本上每个Linux都已经有CentOS sensors包了，我们主要安装了就可以了。或者我们也可以通过源文件来自己编译。1)在FC，RH， CENTOS下，用rpm：[root@securitycn ~]# rpm -ivh lm_sensors-2.10.0-3.1.i386.rpm3)编译源文件安装我们可以通过:这里下载源文件这里我们要注意的问题是要先安装libsysfs库，是Sysfsutils，Sysfsutils－devel软件<br/><br/>tar xzvf lm-sensors-xxx.tar.gz&nbsp;&nbsp;make user&nbsp;&nbsp;make user_install testing 下面我们就用一些简单的命令来利用CentOS sensors来得到CPU的数据。我们要用root的身份来：sensors-detect，然后它会自动搜索主板上的chipset和相应的driver,我们全部答YES就可以了[root@securitycn ~]# sensors-detect<br/><br/># sensors-detect revision 1.413 (2006/01/19 20:28:00)&nbsp;&nbsp;This program will help you determine which I2C/SMBus modules you need to&nbsp;&nbsp;load to use lm_sensors most effectively. You need to have i2c and&nbsp;&nbsp;lm_sensors installed before running this program.&nbsp;&nbsp;Also, you need to be `root&#039;, or at least have access to the /dev/i2c-*&nbsp;&nbsp;files, for most things.&nbsp;&nbsp;If you have patched your kernel and have some drivers built in, you can&nbsp;&nbsp;safely answer NO if asked to load some modules. In this case, things may&nbsp;&nbsp;seem a bit confusing, but they will still work.&nbsp;&nbsp; It is generally safe and recommended to accept the default answers to all&nbsp;&nbsp;questions, unless you know what you&#039;re doing.&nbsp;&nbsp; We can start with probing for (PCI) I2C or SMBus adapters.&nbsp;&nbsp;You do not need any special privileges for this.&nbsp;&nbsp;Do you want to probe now? (YES/no):&nbsp;&nbsp; 全部默认YES即可。然后我们启动CentOS sensors：<br/><br/>/etc/init.d/lm_sensors start&nbsp;&nbsp;Starting lm_sensors: [ OK ] 我们可以通过lsmod来确定我们需要的driver已经加载了没有<br/><br/>lsmod &#124; grep i2c&nbsp;&nbsp;i2c_isa 9153 2 w83627hf,w83781d&nbsp;&nbsp;i2c_i801 11341 0&nbsp;&nbsp; i2c_dev 12613 0&nbsp;&nbsp; i2c_ec 9025 1 sbs&nbsp;&nbsp;i2c_core 23745 6 w83627hf,w83781d,i2c_isa,i2c_i801,i2c_dev,i2c_ec 然后我们用CentOS sensors的命令就可以了：<br/><br/>[root@securitycn ~]# sensors&nbsp;&nbsp;w83627hf-isa-0290&nbsp;&nbsp;Adapter: ISA adapter&nbsp;&nbsp;VCore 1: +3.33 V (min = +0.00 V, max = +0.00 V) ALARM&nbsp;&nbsp; VCore 2: +3.36 V (min = +0.00 V, max = +0.00 V) ALARM&nbsp;&nbsp; +3.3V: +0.93 V (min = +3.14 V, max = +3.46 V) ALARM&nbsp;&nbsp; +5V: +5.11 V (min = +4.73 V, max = +5.24 V)&nbsp;&nbsp; +12V: +4.56 V (min = +10.82 V, max = +13.19 V) ALARM&nbsp;&nbsp; -12V: -7.10 V (min = -13.18 V, max = -10.88 V) ALARM&nbsp;&nbsp; -5V: -1.93 V (min = -5.25 V, max = -4.75 V) ALARM&nbsp;&nbsp; V5SB: +5.51 V (min = +4.73 V, max = +5.24 V) ALARM&nbsp;&nbsp; VBat: +0.02 V (min = +2.40 V, max = +3.60 V) ALARM&nbsp;&nbsp; fan1: 0 RPM (min = 2732 RPM, div = 2) ALARM&nbsp;&nbsp; fan2: 0 RPM (min = 0 RPM, div = 2)&nbsp;&nbsp; fan3: 0 RPM (min = 0 RPM, div = 2)&nbsp;&nbsp; temp1: +38癈 (high = +50癈, hyst = +45癈) sensor = thermistor&nbsp;&nbsp; temp2: +33.5癈 (high = +80癈, hyst = +75癈) sensor = thermistor&nbsp;&nbsp; temp3: +33.5癈 (high = +80癈, hyst = +75癈) sensor = thermistor&nbsp;&nbsp; vid: +0.000 V (VRM Version 10.0)&nbsp;&nbsp;alarms:&nbsp;&nbsp; beep_enable:&nbsp;&nbsp;Sound alarm enabled 这里我们可以看到温度还没有相对应CPU，我们主要稍微修改一下/etc/sensors.conf就可以了，不过其实都不用我们自己去动手，一般我们都可以从主板生产商那里下载到配置文件。通过CentOS sensors我们就可以得到主板温度，CPU电压，风扇转速这些信息。我们可以根据这些数据来监察系统的运行情况来预防系统的问题。 <br/><br/>接下来让它和MRTG整合在一起吧<br/><br/>[root@securitycn ~]# cd /usr/local/mrtg/bin&nbsp;&nbsp;[root@securitycn ~]# vi temp.sh&nbsp;&nbsp;#内容如下&nbsp;&nbsp;#!/bin/bash&nbsp;&nbsp;cputemp=`/usr/bin/sensors &#124; grep temp1 &#124;awk &#039;&#123;print $2&#125;&#039;&#124;cut -c 2-4` #这句是说找出有temp1那一行,印出第二个列的2-4个字&nbsp;&nbsp;systemp =`/usr/bin/sensors &#124; grep temp2 &#124;awk &#039;&#123;print $2&#125;&#039;&#124;cut -c 2-5` 不用解释了吧&nbsp;&nbsp;echo $cputemp&nbsp;&nbsp;echo $systemp&nbsp;&nbsp;# the uptime&nbsp;&nbsp;uptime &#124; sed &#039;s:^.* up &#92;(.*&#92;), [0-9][0-9]* users.*$:&#92;1:&#039;&nbsp;&nbsp;# my name&nbsp;&nbsp;uname -n [root@securitycn ~]# chmod +x temp.sh 改成可执行&nbsp;&nbsp;[root@securitycn ~]# ./temp.sh 试试看有没有问题&nbsp;&nbsp;39&nbsp;&nbsp;33.5&nbsp;&nbsp;15:36:19 up 22:28, 1 user, load average: 0.04, 0.09, 0.04&nbsp;&nbsp;securitycn CentOS sensors再来写下面的文件<br/><br/>[root@securitycn ~]# cd ../etc/&nbsp;&nbsp;[root@securitycn ~]# vi temp.cfg&nbsp;&nbsp;WorkDir: /data1/usr/apache/htdocs/mrtg/temp/&nbsp;&nbsp;Target[index]: `/usr/local/mrtg/bin/temp.sh`&nbsp;&nbsp;MaxBytes[index]:80&nbsp;&nbsp;Options[index]: gauge, nopercent, growright&nbsp;&nbsp;YLegend[index]: Temp (度)&nbsp;&nbsp;ShortLegend[index]: 度&nbsp;&nbsp;LegendO[index]: 系统温度;&nbsp;&nbsp;LegendI[index]: CPU温度;&nbsp;&nbsp;Title[index]: 系统温度表&nbsp;&nbsp;PageTop[index]: &lt;H1&gt;主机温度表&lt;/H1&gt; [root@securitycn ~]# /usr/local/mrtg/bin/mrtg /usr/local/mrtg/etc/temp.cfg执行3次就不报错了然后加入到crontab里面*/5 * * * * /usr/local/mrtg/bin/mrtg /usr/local/mrtg/etc/temp.cfgPageTop[index]: &lt;H1&gt;主机温度表<br/><br/>来源：http://os.51cto.com/art/201002/184810.htm<br/>
]]>
</description>
</item><item>
<link>http://www.jackxiang.com/post//#blogcomment</link>
<title><![CDATA[[评论] CentOS sensors软件监控主板CPU数据]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://www.jackxiang.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>