lm-sensors

更新日2012-08-21 (火) 14:11:17

lm-sensorsはPCのハードウェア状況を表示するプログラムである。CPU温度、M/Bの温度 CPUFANの回転数や各電源の電圧等が表示できる。

事前準備[Vin4.0 kernel2.6.16]

Vine4.0ではi2cは不要だが、sysfsutilsが必要なのでここhttp://sourceforge.net/project/showfiles.php?group_id=44427からDownlaodしてインストールしておく

$ tar xvfz sysfsutils-2.1.0.tar.gz
$ cd sysfsutils-2.1.0
$ ./configure
$ make
$ su
# make install

/usr/local/lib,/usr/local/bin,/usr/local/include/sysfsにインストールされる

事前準備

flex&bisonを入れる必要があるのでrpm等でインストールしておく。 また、Kernelソースも必要なのでインストールしておき、コンパイル環境を利用できる 環境に以下のようにしておく。Vine3.2ではKernelの再構築の必要はない。

# cd /usr/linux/src

# cp configs/kernel-2.4.31-i686.config .config lm-sensorsのインストール

ここからi2c-2.10.0.tar.gz(シリアル通信インターフェイスデバイス)と、lm_sensors-2.10.0.tar.gzをDownloadする。 シリアル通信インターフェイスデバイス(i2c)のインストール $ tar zxvf i2c-2.10.0.tar.gz $ cd i2c-2.10.0 $ make Makefile:191: kernel/i2c-core.d: そのようなファイルやディレクトリはありません Makefile:191: kernel/i2c-dev.d: そのようなファイルやディレクトリはありません Makefile:191: kernel/i2c-algo-bit.d: そのようなファイルやディレクトリはありませ ん Makefile:191: kernel/i2c-philips-par.d: そのようなファイルやディレクトリはありま (略)

-DEXPORT_SYMTAB -fno-strict-aliasing -c kernel/i2c-proc.c -o kernel/i2c-proc.o

gcc -I/lib/modules/2.4.31-0vl1.12/build/include -nostdinc -I /usr/lib/gcc-lib/i386-vine-linux/3.3.2/include -Wall -O2 -D__KERNEL__ -DMODULE -fomit-frame-pointer -DEXPORT_SYMTAB -fno-strict-aliasing -c kernel/i2c-pport.c -o kernel/i2c-pport.o

$ su

# make install

(略)

/sbin/depmod -a

Installation successful!

Important notes:

1* Compatibility with the Linux 2.4 kernel has been restored.

2* The i2c-elektor and i2c-pcf-epp modules were not built. If you

need them, you have to use compilation option 3 as described in

the INSTALL file.

# exit

lm_sensorsのインストール

$ cd ..
$ tar zxvf lm_sensors-2.10.0.tar.gz
$ cd lm_sensors-2.10.0
$ make

(略)

gcc -DETCDIR="\"/etc\"" -I. -Ikernel/include -I/usr/local/include  -Wundef - Wall -O2  -c prog/sensors/main.c -o prog/sensors/main.ro
gcc -DETCDIR="\"/etc\"" -I. -Ikernel/include -I/usr/local/include  -Wundef - Wall -O2  -c prog/sensors/chips.c -o prog/sensors/chips.ro
gcc -Wl,-rpath,/usr/local/lib -o prog/sensors/sensors prog/sensors/main.ro prog/sensors/chips.ro  -Llib -lsensors

$ su
# make install

(略)

if [ ! -e /etc/sensors.conf ] ; then \
  install -m 644 etc/sensors.conf.eg /etc/sensors.conf; \
fi
*** Important note:
***  * The libsensors configuration file (/etc/sensors.conf) is never
***    overwritten by our installation process, so that you won't lose
***    your personal settings in that file. You still can get our latest
***    default config file in etc/sensors.conf.eg and manually copy it to
***    /etc/sensors.conf if you want. You will then want to edit it
***    to fit your needs again.
/sbin/depmod -a

lm_sensorsの設定

センサーの検出等の設定を以下のようにする(インストール後一度実行する必要あり) /etc/sysconfig/lm_sensorsに検出結果が格納される

# cd lm_sensors-2.10.0/prog/detect 
# ./sensors-detect 

# sensors-detect revision 1.413 (2006/01/19 20:28:00)

This program will help you determine which I2C/SMBus modules you need to
load to use lm_sensors most effectively. You need to have i2c and
lm_sensors installed before running this program.
Also, you need to be `root', or at least have access to the /dev/i2c-*
files, for most things.

(略)

 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):  <---(Enter)

Probing for PCI bus adapters...
Use driver `i2c-i801' for device 00:1f.3: Intel 82801FB ICH6
Probe succesfully concluded. 

We will now try to load each adapter module in turn.
Load `i2c-i801' (say NO if built into your kernel)? (YES/no):<---(Enter)
Module loaded succesfully.
If you have undetectable or unsupported adapters, you can have them
scanned by manually loading the modules before running this script.

To continue, we need module `i2c-dev' to be loaded.
If it is built-in into your kernel, you can safely skip this.
i2c-dev is not loaded. Do you want to load it now? (YES/no):<---(Enter)
Module loaded succesfully.

We are now going to do the adapter probings. Some adapters may hang halfway
through; we can't really help that. Also, some chips will be double detected;
we choose the one with the highest confidence value in that case.
If you found that the adapter hung after probing a certain address, you can
specify that address to remain unprobed. That often
includes address 0x69 (clock chip).

Next adapter: SMBus I801 adapter at 5000
Do you want to scan it? (YES/no/selectively):<---(Enter)
Client found at address 0x08
Client found at address 0x44
Probing for `Maxim MAX6633/MAX6634/MAX6635'... Failed!
Client found at address 0x50
Probing for `SPD EEPROM'... Success!
    (confidence 8, driver `eeprom')
Probing for `DDC monitor'... Failed!
Probing for `Maxim MAX6900'... Failed!
Client found at address 0x69

Some chips are also accessible through the ISA bus. ISA probes are
typically a bit more dangerous, as we have to write to I/O ports to do
this. This is usually safe though.

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


Some Super I/O chips may also contain sensors. Super I/O probes are
typically a bit more dangerous, as we have to write to I/O ports to do
this. This is usually safe though.

Do you want to scan for Super I/O sensors? (YES/no):<---(Enter)
Probing for `ITE 8702F Super IO Sensors'
  Failed! (skipping family)
Probing for `Nat. Semi. PC87351 Super IO Fan Sensors'
  Failed! (skipping family)
Probing for `SMSC 47B27x Super IO Fan Sensors'
  Failed! (skipping family)
Probing for `VT1211 Super IO Sensors'
  Failed! (0x82)
Probing for `Winbond W83627HF Super IO Sensors'
  Failed! (0x82)
Probing for `Winbond W83627THF Super IO Sensors'
  Success... found at address 0x0290
Probing for `Winbond W83637HF Super IO Sensors'
  Failed! (0x82)
Probing for `Winbond W83687THF Super IO Sensors'
  Failed! (0x82)
Probing for `Winbond W83697HF Super IO Sensors'
  Failed! (0x82)
Probing for `Winbond W83697SF/UF Super IO PWM'
  Failed! (0x82)
Probing for `Winbond W83L517D Super IO'
  Failed! (0x82)
Probing for `Fintek F71805F/FG Super IO Sensors'
  Failed! (0x8285)
Probing for `Winbond W83627EHF/EHG Super IO Sensors'
  Failed! (0x8285)

Do you want to scan for secondary Super I/O sensors? (YES/no):<---(Enter)
Probing for `ITE 8702F Super IO Sensors'
  Failed! (skipping family)
Probing for `Nat. Semi. PC87351 Super IO Fan Sensors'
  Failed! (skipping family)
Probing for `SMSC 47B27x Super IO Fan Sensors'
  Failed! (skipping family)
Probing for `VT1211 Super IO Sensors'
  Failed! (skipping family)
Probing for `Winbond W83627EHF/EHG Super IO Sensors'
  Failed! (skipping family)

Now follows a summary of the probes I have just done.
Just press ENTER to continue:

Driver `eeprom' (should be inserted):
  Detects correctly:
  * Bus `SMBus I801 adapter at 5000'
    Busdriver `i2c-i801', I2C address 0x50
    Chip `SPD EEPROM' (confidence: 8)

Driver `w83627hf' (should be inserted):
  Detects correctly:
  * ISA bus address 0x0290 (Busdriver `i2c-isa')
    Chip `Winbond W83627THF Super IO Sensors' (confidence: 9)


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

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   <---/etc/modules.confに追加する内容
#----cut here----

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

#----cut here----
# I2C adapter drivers
modprobe i2c-i801
modprobe i2c-isa
# I2C chip drivers
modprobe eeprom
modprobe w83627hf
# sleep 2 # optional
/usr/local/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.

Do you want to generate /etc/sysconfig/lm_sensors? (YES/no):<---(Enter)
Copy prog/init/lm_sensors.init to /etc/rc.d/init.d/lm_sensors
for initialization at boot time.

以下のファイルを修正

/etc/modules.confに

alias char-major-89 i2c-dev

を追加。

モジュールのload / プログラムの実行

以下で確認(モジュールのload / プログラムの実行)

# /sbin/modprobe i2c-i801
# /sbin/modprobe i2c-isa
# /sbin/modprobe eeprom
# /sbin/modprobe w83627hf

実行

# /usr/local/bin/sensors
eeprom-i2c-0-50
Adapter: SMBus I801 adapter at 5000
Memory type:            DDR2 SDRAM DIMM
Memory size (MB):       512

w83627thf-isa-0290
Adapter: ISA adapter
VCore:     +1.29 V  (min =  +0.70 V, max =  +0.70 V)       ALARM
+12V:     +11.93 V  (min = +10.83 V, max = +13.19 V)
+3.3V:     +3.26 V  (min =  +3.14 V, max =  +3.46 V)
+5V:       +4.98 V  (min =  +4.75 V, max =  +5.25 V)
-12V:      -5.71 V  (min = -13.16 V, max = -10.90 V)       ALARM
V5SB:      +5.02 V  (min =  +4.74 V, max =  +5.24 V)
VBat:      +3.30 V  (min =  +2.40 V, max =  +3.60 V)
fan1:        0 RPM  (min =  664 RPM, div = 8)              ALARM
CPU Fan:  4326 RPM  (min =  664 RPM, div = 8)
fan3:        0 RPM  (min =  664 RPM, div = 8)              ALARM
M/B Temp:    +62°C  (high =   +44°C, hyst =   -32°C)   sensor = thermistor     ALARM
CPU Temp:  +66.0°C  (high =   +80°C, hyst =   +75°C)   sensor = diode        
temp3:     -48.0°C  (high =   +80°C, hyst =   +75°C)   sensor = thermistor   
vid:      +0.000 V  (VRM Version 9.0)
alarms:
beep_enable:
          Sound alarm enabled

起動時起動するように設定

# cp prog/init/lm_sensors.init /etc/rc.d/init.d/lm_sensors
# /sbin/chkconfig --add lm_sensors

MRTGで結果を表示する

/usr/local/mrtg-2/lib/mrtg.cfgに以下を追加

#-----------------------------------------------------------------
# CPU/MB温度状況
#-----------------------------------------------------------------
Target[cputemp]: `/usr/local/bin/sensors | grep Temp | awk '{print $3}' | sed -e 's/+//' -e 's/[^0-9+\.].*//'`
MaxBytes[cputemp]: 100
Title[cputemp]: CPUとマザーボードの温度
PageTop[cputemp]: <h1>CPUとマザーボードの温度</h1>
Options[cputemp]: absolute,gauge,nopercent,noinfo
#WithPeak[cputemp]: ymw
unscaled[cputemp]: dwmy
YLegend[cputemp]: Temperature
ShortLegend[cputemp]: C
LegendI[cputemp]: M/B
LegendO[cputemp]: CPU
Legend1[cputemp]: M/B
Legend2[cputemp]: CPU

#-----------------------------------------------------------------
# CPU FUN 回転数
#-----------------------------------------------------------------
Target[cpufun]: `/usr/local/bin/sensors | grep 'CPU Fan:' | awk '{print $3 "\n0
}'`  <--出力結果が2行になる必要があるようなのでダミーに0を出力
MaxBytes[cpufun]: 6000
Title[cpufun]: CPU FAN 回転数
PageTop[cpufun]: <h1>CPU FAN 回転数</h1>
Options[cpufun]: gauge
#WithPeak[cpufun]: ymw
unscaled[cpufun]: dwmy
YLegend[cpufun]: RPM
ShortLegend[cpufun]: RPM
LegendI[cpufun]: CPU FUN
LegendO[cpufun]: CPU FUN

携帯でも表示

以下のようなScriptを作成しCronで実行

cputemp.shを作成
#!/bin/sh

cputemp=`/usr/local/bin/sensors | awk '{if($2 == "Temp:"){print  $1$2" "$3"<Br>"};if($2 == "Fan:"){print $1$2" "$3$4"<Br>"}}'`
date0=`/bin/date`
echo "<html>"
echo "<body>"
echo "<Center> CPU M/B Status(Mini-PC) </Center><Br>"
echo "<HR>"
echo $date0
echo "<Br>"
echo $cputemp
echo "<Br>"
echo "</body>"
echo "</html>"

crontabに以下のように記入(一般ユーザでOK)

*/10 * * * * /home/okada/script/cputemp.sh > /usr/local/apache2/htdocs/temperature/cpustatus.html

元ページ

トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS