Last update: 2024/12/22
Sysfsを使えば、特別なパッケージをインストールしなくてもcatコマンドで/sys/class/thermal/thermal_zone*/tempを読めば確認することができる。以下の例ではthemal_zone0が27.8℃、themal_zone1が29℃となっている。ただし、どの部分の温度情報が読み取れるかは実行環境(ハードウェア)によって異なる。
$ cat /sys/class/thermal/thermal_zone0/temp
27800
$ cat /sys/class/thermal/thermal_zone1/temp
29000
themal_zone*がどこの温度を測っているかは、typeを読めば確認することができる。以下の例ではthemal_zone0がacpitz(ACPIサーマルゾーン、私の環境ではマザーボード上の温度センサーだと思われる)、themal_zone1がx86_pkg_temp(CPU)の温度となっている。
$ cat /sys/class/thermal/thermal_zone0/type
acpitz
$ cat /sys/class/thermal/thermal_zone1/type
x86_pkg_temp
lm_sensorsパッケージをインストールすれば、sensorsコマンドで温度情報を確認することができる。マルチコアのCPUの場合は、コアごとに温度が表示される。
$ sensors
iwlwifi_1-virtual-0
Adapter: Virtual device
temp1: N/A
acpitz-acpi-0
Adapter: ACPI interface
temp1: +27.8°C (crit = +110.0°C)
coretemp-isa-0000
Adapter: ISA adapter
Package id 0: +31.0°C (high = +105.0°C, crit = +105.0°C)
Core 0: +29.0°C (high = +105.0°C, crit = +105.0°C)
Core 1: +29.0°C (high = +105.0°C, crit = +105.0°C)
Core 2: +29.0°C (high = +105.0°C, crit = +105.0°C)
Core 3: +29.0°C (high = +105.0°C, crit = +105.0°C)
smartmontoolsをインストールすれば、smartctlコマンドでSSD(NVMe)を指定して実行すれば温度センサーを確認することができる。※実行にはroot権限が必要
$ sudo smartctl -a /dev/nvme0
smartctl 7.2 2020-12-30 r5155 [x86_64-linux-5.14.0-362.24.2.el9_3.x86_64] (local build)
Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org
…略…
=== START OF SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED
SMART/Health Information (NVMe Log 0x02)
Critical Warning: 0x00
Temperature: 32 Celsius
Available Spare: 100%
Available Spare Threshold: 10%
Percentage Used: 0%
Data Units Read: 164,810 [84.3 GB]
Data Units Written: 148,243 [75.9 GB]
Host Read Commands: 1,317,771
Host Write Commands: 905,224
Controller Busy Time: 384
Power Cycles: 27
Power On Hours: 558
Unsafe Shutdowns: 5
Media and Data Integrity Errors: 0
Error Information Log Entries: 0
Warning Comp. Temperature Time: 0
Critical Comp. Temperature Time: 0
Temperature Sensor 1: 32 Celsius
Temperature Sensor 2: 34 Celsius
Error Information (NVMe Log 0x01, 16 of 64 entries)
No Errors Logged
Generic Thermal Sysfs driver How To — The Linux Kernel documentation
Copyright (c) 2024 kd