IT二刀流にはプロモーションが含まれています。

ミラクルLinuxでCPUやマザーボードの温度を取得する

CPU

ミラクルLinuxでCPUやマザーボードの温度を取得する方法

ミラクルLinuxではマザーボードやCPUが対応していれば、温度センサーの値を取得できます。

検証した環境

  • MIRACLE LINUX release 8.7 (Peony)
  • lm_sensors 3.4.0

CentOSのサポート終了に伴い、MIRACLE LINUXを使用しています。

余談ですが、「MIRACLE LINUX」ってスペルが覚えられない・・・

マザーボードの温度を取得する

# cat /sys/class/thermal/thermal_zone0/temp
42000

42000は42.000℃です。

zone0となっている箇所はマザーボード上に複数温度センサーがある場合はzone1、zone2のようになるようです。

どの値がどの部分の温度かは、マザーボート等のマニュアルを参照しないとわからないです。

CPUの温度を取得する

CPUの温度はlabelが用意されているので、どのコアの温度がわかります。

MIRACLE LINUXはCentOS7とはディレクトリが変わっていました。

# cd /sys/devices/platform/coretemp.0/hwmon/hwmon1
# cat temp2_label
Core 0
# cat temp2_input
32000
# cat temp3_label
Core 1
# cat temp3_input
31000

Core0:32.000℃
Core1:31.000℃

このサーバはCPUが6コアなのでtemp7(Core 5)までありました。

catで全部確認するのは面倒なので省略します。

lm_sensorsを使用する

毎回、catで出力するのは面倒なのでlm_sensorsを利用します。

lm_sensorsをインストールすればsensorsコマンドで確認することができます。

パッケージ確認

lm_sensorsがインストールできるか確認します。

# dnf search lm_sensors
================================= 名前 完全一致: lm_sensors =================================
lm_sensors.x86_64 : Hardware monitoring tools
=============================== 名前 & 概要 一致: lm_sensors ================================
lm_sensors-devel.i686 : Development files for programs which will use lm_sensors
lm_sensors-devel.x86_64 : Development files for programs which will use lm_sensors
lm_sensors-libs.i686 : Lm_sensors core libraries
lm_sensors-libs.x86_64 : Lm_sensors core libraries
=================================== 名前 一致: lm_sensors ===================================
lm_sensors-sensord.x86_64 : Daemon that periodically logs sensor readings

lm_sensorsをインストール

# dnf install -y lm_sensors
~
インストール済み:
  lm_sensors-3.4.0-23.20180522git70f7e08.el8.x86_64 lm_sensors-libs-3.4.0-23.20180522git70f7e08.el8.x86_64

完了しました!

sensorsコマンド

# sensors
pch_cannonlake-virtual-0
Adapter: Virtual device
temp1:        +42.0°C

coretemp-isa-0000
Adapter: ISA adapter
Package id 0:  +33.0°C  (high = +82.0°C, crit = +100.0°C)
Core 0:        +32.0°C  (high = +82.0°C, crit = +100.0°C)
Core 1:        +31.0°C  (high = +82.0°C, crit = +100.0°C)
Core 2:        +33.0°C  (high = +82.0°C, crit = +100.0°C)
Core 3:        +32.0°C  (high = +82.0°C, crit = +100.0°C)
Core 4:        +33.0°C  (high = +82.0°C, crit = +100.0°C)
Core 5:        +35.0°C  (high = +82.0°C, crit = +100.0°C)

temp1がマザーボード、Core0~Core5がCPUですね。

Package id 0:はおそらくアベレージ(平均)かと。

先ほど直接確認した値と同じです。

他のセンサーの値を取得

sensors-detectで設定すればファンの回転数など温度以外のセンサーの値も取得できるようです。

私の使用しているサーバでは温度以外は取得できませんでした。

ドライバーとかの問題なのかな?

sensors-detectコマンドを実行すると、いろいろ質問されますが、

基本的には全てEnter(yes)でOKです。

[root@miracle001 ~]# sensors-detect
# sensors-detect version 3.4.0+git
# System: HP HP ProDesk 600 G5 SFF
# Board: HP 8597
# Kernel: 4.18.0-477.10.1.el8_8.x86_64 x86_64
# Processor: Intel(R) Core(TM) i5-9500 CPU @ 3.00GHz (6/158/10)

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 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 16h thermal sensors...                           No
AMD Family 17h thermal sensors...                           No
AMD Family 15h power sensors...                             No
AMD Family 16h power sensors...                             No
AMD Family 19h thermal sensors...                           No
Intel digital thermal sensor...                             Success!
    (driver `coretemp')
Intel AMB FB-DIMM thermal sensor...                         No
Intel 5500/5520/X58 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):
Probing for Super-I/O at 0x2e/0x2f
Trying family `National Semiconductor/ITE'...               Yes
Found unknown chip with ID 0x1f11
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):
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):
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):
Using driver `i2c-i801' for device 0000:00:1f.4: Cannon Lake-H (PCH)
Module i2c-dev loaded successfully.

Next adapter: i915 gmbus dpb (i2c-0)
Do you want to scan it? (yes/NO/selectively):

Next adapter: i915 gmbus dpc (i2c-1)
Do you want to scan it? (yes/NO/selectively):

Next adapter: i915 gmbus misc (i2c-2)
Do you want to scan it? (yes/NO/selectively):

Next adapter: i915 gmbus dpd (i2c-3)
Do you want to scan it? (yes/NO/selectively):

Next adapter: AUX B/DDI B/PHY B (i2c-4)
Do you want to scan it? (yes/NO/selectively):

Next adapter: AUX C/DDI C/PHY C (i2c-5)
Do you want to scan it? (yes/NO/selectively):

Next adapter: AUX D/DDI D/PHY D (i2c-6)
Do you want to scan it? (yes/NO/selectively):

Next adapter: SMBus I801 adapter at efa0 (i2c-7)
Do you want to scan it? (YES/no/selectively):
Client found at address 0x50
Probing for `Analog Devices ADM1033'...                     No
Probing for `Analog Devices ADM1034'...                     No
Probing for `SPD EEPROM'...                                 No
Probing for `EDID EEPROM'...                                No


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

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

Do you want to overwrite /etc/sysconfig/lm_sensors? (YES/no):
Unloading i2c-dev... OK

まとめ

CentOSで以前確認した方法とMIRACLE LINUXでは、CPUの温度のディレクトリが若干違っていました。

lm_sensorsを使えば同じように取得できます。

「温度がわかったからってなんなんだ!」と言われると微妙です。

データセンター管理者とかならファンを増やすとか空調を改善するなり対策が可能です。

リモートでサーバを操作していると打つ手はないです。

ちなみにSSDの適正温度は0~60度のようなので、70度超えると安全装置が働き、パフォーマンスが下がるらしいです。

SSDの温度はsmartctlで調べられます。

ITエンジニアの転職

いまITエンジニアの需要は急拡大しています。
ITエンジニアの経験があれば好条件で転職することも難しくありません。

転職ドラフト

☆ 支援ご協力のお願い ☆

この記事が「役に立った」と感じたら

投げ銭の「OFUSEで応援」で支援して頂けたら励みになります!

OFUSEのやり方(説明)

関連記事
記事特集