用 lm_sensors套件取得 cpu溫度

[1] apt-get install lm_sensors

[2] 執行 sensors-detect指令
     此用來偵測設定值,全Enter即可,
     之後它自已會將該要的module放於/etc/sysconfig/lm_sensors裡

[3] 載入/etc/sysconfig/lm_sensors裡的模組
      指令如下
         modprobe module1
         modprobe module2

     如果是 RPM安裝
        service lm_sensors start

     執行 sensors指令可看到溫度資訊

it87-isa-0290
Adapter: ISA adapter
VCore 1:   +1.33 V  (min =  +1.42 V, max =  +1.57 V)   ALARM
VCore 2:   +2.72 V  (min =  +2.40 V, max =  +2.61 V)   ALARM
+3.3V:     +6.62 V  (min =  +3.14 V, max =  +3.46 V)   ALARM
+5V:       +3.44 V  (min =  +4.76 V, max =  +5.24 V)   ALARM
+12V:     +11.71 V  (min = +11.39 V, max = +12.61 V)
-12V:      -2.20 V  (min = -12.63 V, max = -11.41 V)   ALARM
-5V:       -6.50 V  (min =  -5.26 V, max =  -4.77 V)   ALARM
Stdby:     +4.89 V  (min =  +4.76 V, max =  +5.24 V)
VBat:      +3.25 V
fan1:     1739 RPM  (min =    0 RPM, div = 8)
fan2:     1687 RPM  (min = 3013 RPM, div = 8)          ALARM
fan3:        0 RPM  (min = 3013 RPM, div = 8)
M/B Temp:    +25°C  (low  =   +15°C, high =   +40°C)   sensor = thermistor
CPU Temp:    +42°C  (low  =   +15°C, high =   +45°C)   sensor = diode
Temp3:       +33°C  (low  =   +15°C, high =   +45°C)   sensor = thermistor

[4] 寫 script
      vi temp_sensors.sh

#!/bin/bash
MB_TEMP=`sensors | grep "SYS Temp" | awk '{print $3}' | sed -e 's/^+//' -e 's/^-//' -e 's/°C//'`
CPU_TEMP=`sensors | grep "CPU Temp" | awk '{print $3}' | sed -e 's/^+//' -e 's/^-//' -e 's/°C//'`
echo $MB_TEMP
echo $MB_TEMP

# 當有使用 snmp時,可忽略底下設定
#echo `uptime | awk '{print $3 " " $4}' | cut -d, -f1`
#echo `hostname`

[5] vi mrtg.cfg-temp

WorkDir: /var/www/mrtg/temp
#Language: big5
Target[temperature]: `sh /etc/mrtg/temp_sensor.sh`
RouterUptime[temperature]: cross@10.1.1.254
MaxBytes[temperature]: 100
Options[temperature]: growright, nopercent, gauge
#Unscaled[temperature]: dwmy
YLegend[temperature]: Temperature
ShortLegend[temperature]: °C
Legend1[temperature]: Mainboard(L1)
Legend2[temperature]: CPU(L2)
Legend3[temperature]:
Legend4[temperature]:
LegendI[temperature]:   Mainboard(LI):
LegendO[temperature]:   CPU(LO):
Title[temperature]: Temperature(Title)
PageTop[temperature]: <H1>Temperature(PageTop)</H1>
最後修改日期: 2006 年 12 月 30 日

作者

留言

撰寫回覆或留言

發佈留言必須填寫的電子郵件地址不會公開。