lm-sensors

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

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

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

Vine4.0ではi2cは不要だが、sysfsutilsが必要なのでここから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/src/linux-2.6.xx
# 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! [#q3e04c67]
*** Important notes: [#f740ae0c]
*** 1* Compatibility with the Linux 2.4 kernel has been restored. [#kd0377fc]
*** 2* The i2c-elektor and i2c-pcf-epp modules were not built. If you  [#t753763d]
***    need them, you have to use compilation option 3 as described in  [#fd095f85]
***    the INSTALL file. [#z4e9fc58]

# exit

lm_sensorsのインストール[Vine4.0 kernel2.6.16]

$ tar zxvf lm_sensors-2.10.1.tar.gz
$ cd lm_sensors-2.10.1
$ make user
(略)
 -O2  -c prog/dump/isaset.c -o prog/dump/isaset.ro
gcc -Wl,-rpath,/usr/local/lib -o prog/dump/isaset prog/dump/isaset.ro
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 user_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.

注)sysfsutilsインストールを忘れて以下のようなエラーが出たら

$ make user

make: *** `lib/sysfs.ad' に必要なターゲット `sysfs/libsysfs.h' を make するルールがありません。中止。

sysfsutilsインストールして

$ make clean

をしてからmake userを行う

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

を追加。

Vine4.0では/etc/modprobe.confに

# I2C module options
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

Vine5.x + lm_sensors-3.x

Atomマシン(G945チップセット)にインストール

基本はVine4.xと同じ

$ tar zxvf lm_sensors-3.1.1.tar.bz2
$ cd lm_sensors-3.1.1
$ su
# make user
(略)
a - lib/data.ao
a - lib/general.ao
a - lib/error.ao
a - lib/access.ao
a - lib/init.ao
a - lib/sysfs.ao
a - lib/conf-parse.ao
a - lib/conf-lex.ao
gcc -DETCDIR="\"/etc\"" -I.  -Wall -O2 -Wstrict-prototypes -Wshadow -Wpointer- 
arith -Wcast-qual -Wcast-align -Wwrite-strings -Wnested-externs -Winline -W -
Wmissing-prototypes -Wundef  -c prog/sensors/main.c -o prog/sensors/main.ro
prog/sensors/main.c: In function ‘set_degstr’:
prog/sensors/main.c:128: 警告: initialization discards qualifiers from pointer target type
(略)
gcc -DETCDIR="\"/etc\"" -I.  -Wall -O2 -Wstrict-prototypes -Wshadow -Wpointer-
arith -Wcast-qual -Wcast-align -Wwrite-strings -Wnested-externs -Winline -W -
Wmissing-prototypes -Wundef  -c lib/test/test-scanner.c -o lib/test/test-
scanner.ro
gcc -Wl,-rpath,/usr/local/lib -o lib/test/test-scanner lib/test/test-
scanner.ro lib/conf-lex.ao lib/error.ao lib/general.ao -Llib

# make user_install

設定

# cd prog/detect
# ./sensors-detect
# sensors-detect revision 5729 (2009-06-02 15:51:29 +0200)
# System: O.E.M O.E.M
# Board: FOXCONN 45CTP/45CTD

This program will help you determine which kernel modules you need
to load to use lm_sensors most effectively. It is generally safe
and recommended to accept the default answers to all questions,
unless you know what you're doing.

Some south bridges, CPUs or memory controllers contain embedded sensors.
Do you want to scan for them? This is totally safe. (YES/no):
Silicon Integrated Systems SIS5595...                       No
VIA VT82C686 Integrated Sensors...                          No
VIA VT8231 Integrated Sensors...                            No
AMD K8 thermal sensors...                                   No
AMD K10 thermal sensors...                                  No
Intel Core family thermal sensor...                         No
Intel AMB FB-DIMM thermal sensor...                         No
VIA C7 thermal and voltage sensors...                       No

Some Super I/O chips contain embedded sensors. We have to write to
standard I/O ports to probe them. This is usually safe.
Do you want to scan for Super I/O sensors? (YES/no):
Probing for Super-I/O at 0x2e/0x2f
Trying family `National Semiconductor'...                   No
Trying family `SMSC'...                                     No
Trying family `VIA/Winbond/Fintek'...                       No
Trying family `ITE'...                                      Yes
Found `ITE IT8718F Super IO Sensors'                        Success!
    (address 0xa10, driver `it87')
Probing for Super-I/O at 0x4e/0x4f
Trying family `National Semiconductor'...                   No
Trying family `SMSC'...                                     No
Trying family `VIA/Winbond/Fintek'...                       No
Trying family `ITE'...                                      No

Some systems (mainly servers) implement IPMI, a set of common interfaces
through which system health data may be retrieved, amongst other things.
We first try to get the information from SMBIOS. If we don't find it
there, we have to read from arbitrary I/O ports to probe for such
interfaces. This is normally safe. Do you want to scan for IPMI
interfaces? (YES/no):
Probing for `IPMI BMC KCS' at 0xca0...                      No
Probing for `IPMI BMC SMIC' at 0xca8...                     No

Some hardware monitoring chips are accessible through the ISA I/O ports.
We have to write to arbitrary I/O ports to probe them. This is usually
safe though. Yes, you do have ISA I/O ports even if you do not have any
ISA slots! Do you want to scan the ISA I/O ports? (yes/NO):

Lastly, we can probe the I2C/SMBus adapters for connected hardware
monitoring devices. This is the most risky part, and while it works
reasonably well on most systems, it has been reported to cause trouble
on some systems.
Do you want to probe the I2C/SMBus adapters now? (YES/no):
Using driver `i2c-i801' for device 0000:00:1f.3: Intel 82801G ICH7
Module i2c-dev loaded successfully.

Next adapter: SMBus I801 adapter at 0400 (i2c-0)
Do you want to scan it? (yes/NO/selectively):

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

Driver `it87':            <== Driver 名(1)
  * ISA bus, address 0xa10
    Chip `ITE IT8718F Super IO Sensors' (confidence: 9)

Do you want to generate /etc/sysconfig/lm_sensors? (YES/no):
Copy prog/init/lm_sensors.init to /etc/init.d/lm_sensors
for initialization at boot time.
You should now start the lm_sensors service to load the required
kernel modules.

Unloading i2c-dev... OK 

ドライバのロード

# /sbin/modprobe i2c-i801
# /sbin/modprobe eeprom
# /sbin/modprobe it87    <== (1)のDriver名

確認

# /usr/local/bin/sensors

it8718-isa-0a10
Adapter: ISA adapter
in0:         +1.14 V  (min =  +0.00 V, max =  +4.08 V)
in1:         +1.76 V  (min =  +0.00 V, max =  +4.08 V)
in2:         +3.42 V  (min =  +0.00 V, max =  +4.08 V)
in3:         +2.98 V  (min =  +0.00 V, max =  +4.08 V)
in4:         +3.01 V  (min =  +0.00 V, max =  +4.08 V)
in5:         +0.06 V  (min =  +0.00 V, max =  +4.08 V)
in6:         +0.10 V  (min =  +0.00 V, max =  +4.08 V)
in7:         +2.91 V  (min =  +0.00 V, max =  +4.08 V)
Vbat:        +3.06 V
fan1:       1622 RPM  (min =    0 RPM)     <=ケースFanのようだ
fan2:          0 RPM  (min =    0 RPM)
fan3:          0 RPM  (min =    0 RPM)
temp1:       +37.0°C  (low  = +127.0°C, high = +112.0°C)  sensor = thermal  diode
temp2:       +24.0°C  (low  = +127.0°C, high = +112.0°C)  sensor = thermal diode
temp3:      -128.0°C  (low  = +127.0°C, high = +112.0°C)  sensor = disabled
cpu0_vid:   +2.050 V

tempラベル

以下のファイルを編集するとCPUとMBの温度表示にラベルが付く。fanはだめだった

/etc/sensors3.conf

chip "it87-*" "it8712-*" "it8716-*" "it8718-*" "it8720-*"

# 以下を追加
    label temp1 "CPU Temp"
    label temp2 "M/B Temp"

    label in8 "Vbat"
# /usr/local/bin/sensors
fan2:          0 RPM  (min =    0 RPM)
fan3:          0 RPM  (min =    0 RPM)
CPU Temp:    +37.0°C  (low  = +127.0°C, high = +112.0°C)  sensor = thermal diode
M/B Temp:    +24.0°C  (low  = +127.0°C, high = +112.0°C)  sensor = thermal diode
temp3:      -128.0°C  (low  = +127.0°C, high = +112.0°C)  sensor = disabled

MRTGで結果を表示する

rpmでapache1+phpを利用するときはgd-develも必要なのでapt-getでインストールしておく,また snmpはnet-snmp,net-snmp-utilsになるのでapt-getでインストール

文字コードはEUCなのでUTF-8の場合はEUCに変更して仕様

MRTGでは以下のように起動する

# export LANG=ja_JP.eucJP
# /usr/local/mrtg-2/bin/mrtg /usr/local/mrtg-2/lib/mrtg.cfg

スクリプトを作成しておくといいかも

/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
export LANG=ja_JP.eucJP 
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 "<head>"
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=EUC-JP\">"
echo "</head>"
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