UbuntuでCPU温度・FAN回転数などの情報を取得する

Linux
この記事は約14分で読めます。

Raspberry Piのハードウェア監視プログラムを流用して、Ubuntuでも似たようなプログラムを作ろうと目論んでいます。

Raspberry Pi OS(旧Raspbian)ではvcgencmdを使って、CPU温度等の情報を取得することができましたが、このコマンドはUbuntuでは使用できません。

ハードウェアの情報を取得するツールとしてlm-sensorsというものがあります。

このlm-sensorsを使って、これらの情報を取得できるようにしていきます。

                 

lm-sensors

lm_sensorsとは

Linux-monitoring sensorsのことで、温度、電圧、湿度、ファン、シャシー侵入検知などの情報を取得できるフリーのソフトウェアです。

このソフトウェアによって取得できる情報の種類は、マザーボードやCPUによって多少変わるようです。

インストール

lm_sensorsはUbuntuに標準でインストールされているツールではなかったのでインストールが必要です。

インストールした環境は次の通りです。

  • Endeavor NP15(CPU:Intel Atom D525/チップセット:Intel NM10 Express)
  • Ubuntu 20.04 LTS

インストールコマンド

sudo apt install lm-sensors
                 

情報取得してみる

lm_sensorsの使い方は、sensorsと入力して実行するだけです。

引数も不要で、一般権限でも実行可能ですので、簡単です。

さっそく実行してみます。

$ sensors
coretemp-isa-0000
Adapter: ISA adapter
Core 0:       +60.0°C  (crit = +100.0°C)
Core 1:       +60.0°C  (crit = +100.0°C)

CPUの温度のみが取得できました。

NP15に搭載されているCPU Intel Atom D525のコア数は2つなので、Core0とCore1の2つの温度情報が表示されています。

https://ark.intel.com/content/www/jp/ja/ark/products/49490/intel-atom-processor-d525-1m-cache-1-80-ghz.html

気づいた方もいるかもしれませんが、lm-sensorsのインストールだけではCPU温度だけの情報しか取得できず、FANの情報などが取得できませんでした。

よくよくしらべてみるとインストール後に設定が必要でした。

次の項に進みます。

                 

設定(sensors-detect)

lm_sensorsをインストールしただけでは、CPUのコアの温度情報しか取得できませんでした。

検出できる情報を設定するために、sensors-detectコマンド実行します。

 

設定コマンド

sudo sensors-detect

Do you want~から始まる対話にはすべて”yes”と答えました。

sensors-detectの対話ログは長いので最後に載せておきます。

これで検出対象が増えたので、再度sensorsコマンドを実行します。

$ sensors
coretemp-isa-0000
Adapter: ISA adapter
Core 0:       +60.0°C  (crit = +100.0°C)
Core 1:       +60.0°C  (crit = +100.0°C)

f71858fg-isa-0a00
Adapter: ISA adapter
+3.3V:         3.31 V  
3VSB:          3.33 V  
Vbat:          3.17 V  
fan1:        3198 RPM
fan2:           0 RPM  ALARM
fan3:           0 RPM  ALARM
temp1:        +43.9°C  (high = +70.0°C, hyst = +60.0°C)
temp2:        +59.1°C  (high = +100.0°C, hyst = +85.0°C)
temp3:          FAULT  (high = +100.0°C, hyst = +85.0°C)

CPU温度だけでなく、ファンの回転数(RPM)が分かるようになりました。

temp1~はマザーボードのセンサーの温度らしいです。

センサーの具体的な場所についてはマザーボードの仕様によってさまざまとのこと。

NP15のマザーボードの仕様書が見つけられないのでどこにセンサーがあるかはわかりませんが、ひとまずはOKです。

                 

sensors-detectの対話ログ

$ sudo sensors-detect
# sensors-detect version 3.6.0
# System: EPSON DIRECT CORP. Endeavor NP15 [Rev 1.xx]
# Board: EPSON DIRECT CORP. NP15
# Kernel: 5.8.0-36-generic x86_64
# Processor: Intel(R) Atom(TM) CPU D525 @ 1.80GHz (6/28/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): yes
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 16h thermal sensors...                           No
AMD Family 17h thermal sensors...                           No
AMD Family 15h power sensors...                             No
AMD Family 16h power sensors...                             No
Hygon Family 18h 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): yes
Probing for Super-I/O at 0x2e/0x2f
Trying family `National Semiconductor/ITE'...               No
Trying family `SMSC'...                                     No
Trying family `VIA/Winbond/Nuvoton/Fintek'...               Yes
Found `Fintek F71858DG Super IO Sensors'                    Success!
    (address 0xa00, driver `f71882fg')
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): yes
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): yes
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): yes
Using driver `i2c-i801' for device 0000:00:1f.3: Intel 82801G ICH7

Next adapter: SMBus I801 adapter at 0400 (i2c-0)
Do you want to scan it? (yes/NO/selectively): yes
Client found at address 0x50
Handled by driver `at24' (already loaded), chip type `spd'
    (note: this is probably NOT a sensor chip!)

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

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

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

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

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

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


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)

Driver `f71882fg':
  * ISA bus, address 0xa00
    Chip `Fintek F71858DG Super IO Sensors' (confidence: 9)

To load everything that is needed, add this to /etc/modules:
#----cut here----
# Chip drivers
coretemp
f71882fg
#----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)yes
Successful!

Monitoring programs won't work until the needed modules are
loaded. You may want to run '/etc/init.d/kmod start'
to load them.

Unloading cpuid... OK

 

sensors-detectの設定が終了すると、/etc/modulesにChip driversの情報が追記されます。

$ cat /etc/modules
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.


# Generated by sensors-detect on Thu Jan 14 11:46:05 2021
# Chip drivers
coretemp
f71882fg

sensors-detectを実行した回数分、この情報は追記されます。

そのままでもsensorsコマンドは動作しますが、うっかり複数回追記してしまった私のような場合は、2回目以降の同じ記述を削除しておいたほうがいいと思います。

時間を見つけてプログラムを書いていこうと思います。

コメント

タイトルとURLをコピーしました