Linuxサーバ

lm-sensorsでCPUの温度を測定してみる

CPU温度について

電気で動く製品である以上、パソコンの各部品は熱を発生させます。その中でも熱を出しやすいのがCPU。今回交換したQ6600は熱電力が95Wと現行のCPUや以前搭載していたCeleronと比べるとやや高めです。

 

ということは熱をもちやすい→温度が上がって熱暴走→サーバダウンやCPU破損・マザーボード破損などを招くおそれもあるということ。

 

今まであまり(というか全く)気にしていませんでしたが、すぐそばに置いてあるサーバマシンではないのでせめてターミナルからでも温度を把握できるようにしておく必要を感じました。

 

そこで調べた結果「lm-sensors」を使用するのが手っ取り早そうなのでこれを試してみます。

 

lm-sensorsとは

基本的にはマザーボードに設置されたセンサーを読み込んで温度、電圧、ファンの回転数などを計測するツールとドライバの集合体だと解釈しています。

 

それでは早速インストールしてみます

 

インストールと設定

apt-get update

apt-get install lm-sensors

 

するとどうやら自分の環境では最初からインストールされていたようで「既に最新のバージョンです」と表示されました。

 

センサーの検出とカーネルモジュールのリスト作成

センサーを検出すると共に、sensorsデーモンの起動時に自動的にカーネルモジュールを読み込むためのファイルを作成します。コマンドラインから

 

sensors-detect

 

と入力すると以下のように表示され、ところどころ質問が入ります(太字の行が質問です)。全て「y」を入力してすすめて問題ないようです。
# sensors-detect revision 5984 (2011-07-10 21:22:53 +0200)
# System: マシンの名称
# Board: マザーボードの名称

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): y
Module cpuid loaded successfully.
Silicon Integrated Systems SIS5595... No
VIA VT82C686 Integrated Sensors... No
VIA VT8231 Integrated Sensors... No
AMD K8 thermal sensors... No
AMD Family 10h thermal sensors... No
AMD Family 11h thermal sensors... No
AMD Family 12h and 14h thermal sensors... No
AMD Family 15h thermal sensors... No
AMD Family 15h power sensors... No
Intel digital thermal sensor... Success!
(driver `coretemp')
Intel AMB FB-DIMM thermal sensor... No
VIA C7 thermal sensor... No
VIA Nano thermal sensor... 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): y
Probing for Super-I/O at 0x2e/0x2f
Trying family `National Semiconductor/ITE'... No
Trying family `SMSC'... No
Trying family `VIA/Winbond/Nuvoton/Fintek'... No
Trying family `ITE'... Yes
Found `ITE IT8718F Super IO Sensors' Success!
(address 0x290, driver `it87')
Probing for Super-I/O at 0x4e/0x4f
Trying family `National Semiconductor/ITE'... No
Trying family `SMSC'... No
Trying family `VIA/Winbond/Nuvoton/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): y
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): y
Probing for `National Semiconductor LM78' at 0x290... No
Probing for `National Semiconductor LM79' at 0x290... No
Probing for `Winbond W83781D' at 0x290... No
Probing for `Winbond W83782D' at 0x290... 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): y
Using driver `i2c-i801' for device 0000:00:1f.3: Intel ICH9
Module i2c-i801 loaded successfully.
Module i2c-dev loaded successfully.

Next adapter: SMBus I801 adapter at 1c20 (i2c-0)
Do you want to scan it? (yes/NO/selectively): y
Client found at address 0x50
Probing for `Analog Devices ADM1033'... No
Probing for `Analog Devices ADM1034'... No
Probing for `SPD EEPROM'... Yes
(confidence 8, not a hardware monitoring chip)
Probing for `EDID EEPROM'... No
Client found at address 0x51
Probing for `Analog Devices ADM1033'... No
Probing for `Analog Devices ADM1034'... No
Probing for `SPD EEPROM'... Yes
(confidence 8, not a hardware monitoring chip)
Client found at address 0x52
Probing for `Analog Devices ADM1033'... No
Probing for `Analog Devices ADM1034'... No
Probing for `SPD EEPROM'... Yes
(confidence 8, not a hardware monitoring chip)

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

Driver `it87':
* ISA bus, address 0x290
Chip `ITE IT8718F Super IO Sensors' (confidence: 9)

Driver `coretemp':
* Chip `Intel digital thermal sensor' (confidence: 9)

To load everything that is needed, add this to /etc/modules:
#----cut here----
# Chip drivers
coretemp
it87
#----cut here----
If you have some drivers built into your kernel, the list above will
contain too many modules. Skip the appropriate ones!

Do you want to add these lines automatically to /etc/modules? (yes/NO)y
Successful!

Monitoring programs won't work until the needed modules are
loaded. You may want to run 'service module-init-tools start'
to load them.

Unloading i2c-dev... OK
Unloading i2c-i801... OK
Unloading cpuid... OK

 

これで/etc/modulesに必要な情報が書き込まれます。

 

カーネルモジュールの組込み

「modprobe」コマンドを使用してカーネルモジュールを組み込みます。

 

probe coretemp

modprobe it87

 

これで事前準備は終了です。あとは測定するのみ!

 

sensorsコマンドで測定してみる

ターミナルで「sensors」と入力してみます。以下のように表示されました。

 

# sensors
coretemp-isa-0000
Adapter: ISA adapter
Core 0: +47.0°C (high = +82.0°C, crit = +100.0°C)
Core 1: +45.0°C (high = +82.0°C, crit = +100.0°C)
Core 2: +43.0°C (high = +82.0°C, crit = +100.0°C)
Core 3: +40.0°C (high = +82.0°C, crit = +100.0°C)

it8718-isa-0290
Adapter: ISA adapter
in0: +1.22 V (min = +0.77 V, max = +1.54 V)
in1: +1.79 V (min = +1.62 V, max = +1.98 V)
in2: +3.25 V (min = +2.96 V, max = +3.63 V)
+5V: +2.93 V (min = +2.54 V, max = +3.46 V)
in4: +3.01 V (min = +2.70 V, max = +3.30 V)
in5: +0.00 V (min = +0.02 V, max = +4.06 V)
in6: +0.53 V (min = +0.02 V, max = +4.06 V)
in7: +2.51 V (min = +2.24 V, max = +2.75 V)
Vbat: +3.25 V
fan1: 2051 RPM (min = 1500 RPM)
fan2: 1630 RPM (min = 1149 RPM)
fan3: 1541 RPM (min = 1149 RPM)
fan4: 1520 RPM (min = 1149 RPM)
fan5: 0 RPM (min = 10 RPM) ALARM
temp1: +46.0°C (low = +5.0°C, high = +62.0°C) sensor = thermistor
temp2: +35.0°C (low = +5.0°C, high = +62.0°C) sensor = thermistor
temp3: +57.0°C (low = +5.0°C, high = +90.0°C) sensor = thermal diode
cpu0_vid: +0.000 V
intrusion0: ALARM

 

とりあえずlm-sensorsが動くようになりました。下のほうで表示されるtemp1~3の温度については、どれがどの辺りのセンサーに該当するのかイマイチ分かりません。この辺はマザーボードのマニュアルか何かを読んで調べる必要があるかもしれません。

 

まとめ

コマンドラインから簡単にPC内の温度や電圧を管理できるようになったのは、リモートでのメンテ中心の自分にとってはありがたいことです。

 

CPU交換前にこの作業を実施していれば現状と比較することでCPUの発熱状況をより詳しく分析できたかも・・・と思いますがひとまず数値で把握することが重要かと思うのでこれで良しとします。

 

あとはこれをグラフ化したり、累積して異常発生時の早期発見に役立てたりできればよいなぁ・・と考えています。

オススメの記事

-Linuxサーバ
-, ,