安装测试系统:

硬件:普通PC机,

软件:redhat linux as 4  2.6 .9 , 安装系统自带的lm_sensors-2.8.7-2.i386

你也可以从[url]http://www.edgedesign.us/about/lm_sensors[/url]下载

这个软件可以在linux下收集到系统温度。然后我用cacti显示。

由于是系统自带的。所以我在安装系统的时候就已经安装好的。所以如果你找不到的话。可以在系统盘上找,然后rpm安装。这个我就不说了。

下来看配置:

运行:  /sbin/depmod –a

vi /etc/ld.so.conf

加入这一行: /usr/local/lib

运行: ldconfig

运行:sensors-detect 扫瞄你的主机使用那些芯片组

1: We can start with probing for (PCI) I2C or SMBus adapters.

You do not need any special privileges for this.

Do you want to probe now? (YES/no): YES

2:Next adapter: SMBus I801 adapter at 0500 (Algorithm unavailable)

Do you want to scan it? (YES/no/selectively): YES

3:Do you want to scan the ISA bus? (YES/no): YES

4:Do you want to scan for Super I/O sensors? (YES/no): YES

5:Do you want to scan for secondary Super I/O sensors? (YES/no): YES

6:Now follows a summary of the probes I have just done.

Just press ENTER to continue: 回车

7:I will now generate the commands needed to load the I2C modules.

Sometimes, a chip is available both through the ISA bus and an I2C bus.

ISA bus access is faster, but you need to load an additional driver module

for it. If you have the choice, do you want to use the ISA bus or the

I2C/SMBus (ISA/smbus)? ISA

显示:

To make the sensors modules behave correctly, add these lines to

/etc/modules.conf:


#----cut here----

# I2C module options

alias char-major-89 i2c-dev

#----cut here----


To load everything that is needed, add this to some /etc/rc* file:


#----cut here----

# I2C adapter drivers

modprobe i2c-isa

# I2C chip drivers

modprobe w83627hf

# sleep 2 # optional

/usr/bin/sensors -s # recommended

#----cut here----


WARNING! If you have some things built into your kernel, the list above

will contain too many modules. Skip the appropriate ones! You really should

try these commands right now to make sure everything is working properly.

Monitoring programs won't work until it's done.

8:Do you want to generate /etc/sysconfig/lm_sensors? (YES/no): YES

Copy prog/init/lm_sensors.init to /etc/rc.d/init.d/lm_sensors

for initialization at boot time.

完成。

cat /etc/sysconfig/lm_sensors

显示:

MODULE_0=i2c-isa

MODULE_1=w83627hf

启动

[root@linux etc]# /etc/rc.d/init.d/lm_sensors start

Starting lm_sensors:                                       [  OK  ]

sudo sh -c "yes|sensors-detect"   如果没问题就可以检测了

测试:运行 sensors

显示:

w83627thf-isa-0290

Adapter: ISA adapter

VCore:     +1.53 V  (min =  +1.93 V, max =  +1.93 V)            

+12V:      +5.59 V  (min = +10.82 V, max = +13.19 V)            

+3.3V:     +3.26 V  (min =  +3.14 V, max =  +3.47 V)              

+5V:       +5.01 V  (min =  +4.75 V, max =  +5.25 V)            

-12V:     -14.91 V  (min = -10.80 V, max = -13.18 V)            

V5SB:      +4.44 V  (min =  +4.76 V, max =  +5.24 V)            

VBat:      +3.23 V  (min =  +2.40 V, max =  +3.60 V)            

fan1:        0 RPM  (min = 225000 RPM, div = 2)                    

CPU Fan:  3668 RPM  (min =   -1 RPM, div = 2)                    

fan3:        0 RPM  (min = 14062 RPM, div = 8)                    

M/B Temp:    +35°C  (high =    +5°C, hyst =    +0°C)   sensor = thermistor          

CPU Temp:  +42.0°C  (high =  +100°C, hyst =   +95°C)   sensor = PII/Celeron diode          

temp3:     +25.5°C  (high =  +100°C, hyst =   +95°C)   sensor = thermistor          

ERROR: Can't get VID data!

alarms:   Chassis intrusion detection                      ALARM

beep_enable:

         Sound alarm disabled


eeprom-i2c-0-50

Adapter: SMBus I801 adapter at 0500

Memory type:            DDR SDRAM DIMM

Memory size (MB):       512

运行: ntsysv

设置lm_sensors 开机运行。

接下来 设置与 cacti整合:

编辑数据采集脚本

Vi mrtg.sh

#!/bin/sh

cputemp=`sensors | grep "CPU Temp" | awk '{print $3}' | cut -c 2-3`

systemp=`sensors | grep temp3 | awk '{print $2}' | cut -c 2-3`

uptime=`uptime | awk '{print $3 " " $4 " " $5}'`

echo $cputemp

echo $systemp

echo $uptime

echo linux226

添加权限:chmod +x mrtg.sh

采集结果如下:

42

26

4:50, 2 users,

linux226

接下来改写档案

WorkDir: /var/www/html/mrtg/temp/


  Language: big5


  Target[index]: `/var/www/html/mrtg/temp/mrtg.temp`


  MaxBytes[index]:60


  Options[index]: gauge, nopercent, growright


  YLegend[index]: Temp (度)


  ShortLegend[index]: 度


  LegendO[index]: 系统温度;


  LegendI[index]: CPU温度;


  Title[index]: Blue-Moon City 系统温度表


  PageTop[index]: <H1>Blue-Moon City 主机温度表</H1>


  <TABLE>


  <TR><TD>系统:</TD> <TD>RedHat 9.0+Apache 2.0.40 </TD></TR>


  </TABLE>

Mrtg添加:root#/usr/bin/mrtg /var/www/html/mrtg/temp/mrtg.cfg.temp

然后将上面这条命令加入crontab 里定时运行。

我在pc机测试没有问题。。IBM服务器测试没有成功,总是 sensors-detect 时候出错。

经查询:IBM服务器不建议用lm_sensors 软件。

转载:[url]http://zh.gentoo-wiki.com/HARDWARE_Sensors[/url]

参考:[url]http://doc.linuxpk.com/5330.html[/url]


昨天一台 Linux Xen 服务器莫名其妙就不能访问了,开始以为又碰到 server kernel: ip_conntrack: table full, dropping packet. 问题,没仔细看。后来过了2个小时又不能访问了,看了一下日志是服务器自己 shutdown 了,不是网络的问题。再看日志发现错误信息:


Nov 24 05:32:22 ivps kernel: ACPI: Critical trip point

Nov 24 05:32:22 ivps kernel: Critical temperature reached (76 C), shutting down.

原因是 CPU 温度过高超过了警戒温度,查一下系统默认的警戒温度是75度,所以到了76度系统就自动 shutdown 了:


# cat /proc/acpi/thermal_zone/THRM/trip_points

critical (S5):           75 C

服务器温度有这么高吗?查看一下当前温度吓一跳,刚启动的系统又到了74度,系统马上又要 shutdown 了:


# cat /proc/acpi/thermal_zone/THRM/temperature

temperature:             74 C

紧急做法是暂时修改默认报警温度到85度:


# echo 85:0:80:60:0 > /proc/acpi/thermal_zone/THRM/trip_points


# cat /proc/acpi/thermal_zone/THRM/trip_points

critical (S5):           85 C

一般来说 CPU 温度超过70度都是很高的温度了,如果不是系统和程序的原因要赶紧检查服务器周围的环境,检查机房和机柜温度情况、服务器风扇、内部积灰等,让 CPU 和主板长时间工作在高温下可不是好事情。当然不同 CPU 所能耐的住的温度也不同,VPSee 推荐 Intel Core 2 Quad CPU 保持在70度以下,Intel Core i7 CPU 保持在80度以下,这样 CPU 和系统能全速工作发挥最大效率而温度又不至于损坏 CPU.