■CPU温度について調べてみる。 $ lsb_release -d Description: Debian GNU/Linux 9.5 (stretch) ■lm-sensorsをインストール。 $ apt-cache search lm-sensors libsensors4 - 温度/電圧/ファンセンサへのアクセス用ライブラリ libsensors4-dev - lm-sensors 開発キット lm-sensors - 温度・電圧・ファンセンサ読み取り用ユーティリティ sensors-applet - ハードウェアセンサからの情報を Gnome パネルに表示 fancontrol - utility to control the fan speed mate-sensors-applet - Display readings from hardware sensors in your MATE panel mrtgutils-sensors - Utilities to generate statistics for mrtg (from lm-sensors) nagios-plugins-contrib - Plugins for nagios compatible monitoring systems psensor - display graphs for monitoring hardware temperature psensor-server - Psensor server for monitoring hardware sensors remotely xfce4-goodies - enhancements for the Xfce4 Desktop Environment $ sudo apt-get install -y lm-sensors $ dpkg -L lm-sensors | grep bin/ /usr/bin/sensors /usr/bin/sensors-conf-convert /usr/sbin/isadump /usr/sbin/isaset /usr/sbin/sensors-detect ■4コア/8スレッドのCPUが実装されている。 $ awk 'BEGIN{cnt=0}/model.name/{print cnt,$0;cnt++}' /proc/cpuinfo 0 model name : Intel(R) Core(TM) i7 CPU 870 @ 2.93GHz 1 model name : Intel(R) Core(TM) i7 CPU 870 @ 2.93GHz 2 model name : Intel(R) Core(TM) i7 CPU 870 @ 2.93GHz 3 model name : Intel(R) Core(TM) i7 CPU 870 @ 2.93GHz 4 model name : Intel(R) Core(TM) i7 CPU 870 @ 2.93GHz 5 model name : Intel(R) Core(TM) i7 CPU 870 @ 2.93GHz 6 model name : Intel(R) Core(TM) i7 CPU 870 @ 2.93GHz 7 model name : Intel(R) Core(TM) i7 CPU 870 @ 2.93GHz $ sensors coretemp-isa-0000 Adapter: ISA adapter Core 0: +61.0°C (high = +83.0°C, crit = +99.0°C) Core 1: +61.0°C (high = +83.0°C, crit = +99.0°C) Core 2: +62.0°C (high = +83.0°C, crit = +99.0°C) Core 3: +60.0°C (high = +83.0°C, crit = +99.0°C) nouveau-pci-0100 Adapter: PCI adapter GPU core: +0.90 V (min = +0.88 V, max = +1.08 V) temp1: +51.0°C (high = +95.0°C, hyst = +3.0°C) (crit = +105.0°C, hyst = +5.0°C) (emerg = +135.0°C, hyst = +5.0°C) ■temp1はGPU、temp[2-5]がそれぞれCPU Core[0-3]のセンサー。 $ sensors -u coretemp-isa-0000 Adapter: ISA adapter Core 0: temp2_input: 61.000 temp2_max: 83.000 temp2_crit: 99.000 temp2_crit_alarm: 0.000 Core 1: temp3_input: 62.000 temp3_max: 83.000 temp3_crit: 99.000 temp3_crit_alarm: 0.000 Core 2: temp4_input: 62.000 temp4_max: 83.000 temp4_crit: 99.000 temp4_crit_alarm: 0.000 Core 3: temp5_input: 60.000 temp5_max: 83.000 temp5_crit: 99.000 temp5_crit_alarm: 0.000 nouveau-pci-0100 Adapter: PCI adapter GPU core: in0_input: 0.900 in0_min: 0.880 in0_max: 1.080 temp1: temp1_input: 51.000 temp1_max: 95.000 temp1_max_hyst: 3.000 temp1_crit: 105.000 temp1_crit_hyst: 5.000 temp1_emergency: 135.000 temp1_emergency_hyst: 5.000 ■確認出来る値のリストを一覧化。 $ find /sys/devices/ -type f -name "temp*" | awk '{gsub(".*temp[0-9]_","",$1);a[$1]+=1}END{for(n in a){print a[n],n}}' 4 crit_alarm 1 crit_hyst 5 input 1 max_hyst 1 auto_point1_temp 1 emergency_hyst 1 auto_point1_temp_hyst 5 crit 5 max 4 label 1 emergency 1 auto_point1_pwm ■emergencyとなったのはGPUが135°Cの時。 $ find /sys/devices/ -type f -name "temp*_emergency" | awk '{print "echo -n \042["$1"]:\042;awk \047{printf \042%3.4f\134n\042,$1/1000}\047 "$1}' |sh [/sys/devices/pci0000:00/0000:00:03.0/0000:01:00.0/hwmon/hwmon1/temp1_emergency]:135.0000 ■利用可能なセンサーの値を取得 単位は°C $ find /sys/devices/ -type f -name "temp*_input" | awk '{print "echo -n \042["$1"]:\042;awk \047{printf \042%3.4f\134n\042,$1/1000}\047 "$1}' |sh [/sys/devices/pci0000:00/0000:00:03.0/0000:01:00.0/hwmon/hwmon1/temp1_input]:55.0000 [/sys/devices/platform/coretemp.0/hwmon/hwmon0/temp2_input]:70.0000 [/sys/devices/platform/coretemp.0/hwmon/hwmon0/temp5_input]:73.0000 [/sys/devices/platform/coretemp.0/hwmon/hwmon0/temp3_input]:74.0000 [/sys/devices/platform/coretemp.0/hwmon/hwmon0/temp4_input]:75.0000 ■max(sensorsではhigh)として、95°C(GPU)、83°C(CPU)が定義されている。 $ find /sys/devices/ -type f -name "temp*_max" | awk '{print "echo -n \042["$1"]:\042;awk \047{printf \042%3.4f\134n\042,$1/1000}\047 "$1}' |sh [/sys/devices/pci0000:00/0000:00:03.0/0000:01:00.0/hwmon/hwmon1/temp1_max]:95.0000 [/sys/devices/platform/coretemp.0/hwmon/hwmon0/temp5_max]:83.0000 [/sys/devices/platform/coretemp.0/hwmon/hwmon0/temp2_max]:83.0000 [/sys/devices/platform/coretemp.0/hwmon/hwmon0/temp3_max]:83.0000 [/sys/devices/platform/coretemp.0/hwmon/hwmon0/temp4_max]:83.0000 ■critとして、105°C(GPU)、99°C(CPU)のしきい値がある。 $ find /sys/devices/ -type f -name "temp*_crit" | awk '{print "echo -n \042["$1"]:\042;awk \047{printf \042%3.4f\134n\042,$1/1000}\047 "$1}' |sh [/sys/devices/pci0000:00/0000:00:03.0/0000:01:00.0/hwmon/hwmon1/temp1_crit]:105.0000 [/sys/devices/platform/coretemp.0/hwmon/hwmon0/temp5_crit]:99.0000 [/sys/devices/platform/coretemp.0/hwmon/hwmon0/temp4_crit]:99.0000 [/sys/devices/platform/coretemp.0/hwmon/hwmon0/temp3_crit]:99.0000 [/sys/devices/platform/coretemp.0/hwmon/hwmon0/temp2_crit]:99.0000 ■/sysを直接参照する1秒置きの温度変化を見るには以下のようにする。 $ cat coretemp find /sys/devices/ -type f -name "temp*" | awk '/input$|crit$|max$/{print "echo -n \042["$1"]:\042;awk \047{printf \042%3.4f\134n\042,$1/1000}\047 "$1}' |sh | sort -V $ watch -d -n 1 '/bin/bash coretemp' ■lm-sensorsを使った1秒置きの温度変化を見るには以下のようにする。 $ watch -d -n 1 'sensors' ■その他、間接参照するファイルを追ってみる。 INTEL POWERCLAMP DRIVER https://www.kernel.org/doc/Documentation/thermal/intel_powerclamp.txt $ find /sys/devices/virtual/thermal/cooling_device[0-8] -type f -name "type" | xargs grep . /sys/devices/virtual/thermal/cooling_device0/type:Processor /sys/devices/virtual/thermal/cooling_device1/type:Processor /sys/devices/virtual/thermal/cooling_device2/type:Processor /sys/devices/virtual/thermal/cooling_device3/type:Processor /sys/devices/virtual/thermal/cooling_device4/type:Processor /sys/devices/virtual/thermal/cooling_device5/type:Processor /sys/devices/virtual/thermal/cooling_device6/type:Processor /sys/devices/virtual/thermal/cooling_device7/type:Processor /sys/devices/virtual/thermal/cooling_device8/type:intel_powerclamp $ find /sys/devices/virtual/thermal/cooling_device[0-7] -type l -ls | awk '{print $(NF-2),$NF}' /sys/devices/virtual/thermal/cooling_device0/device ../../../LNXSYSTM:00/LNXCPU:00 /sys/devices/virtual/thermal/cooling_device0/subsystem ../../../../class/thermal /sys/devices/virtual/thermal/cooling_device1/device ../../../LNXSYSTM:00/LNXCPU:01 /sys/devices/virtual/thermal/cooling_device1/subsystem ../../../../class/thermal /sys/devices/virtual/thermal/cooling_device2/device ../../../LNXSYSTM:00/LNXCPU:02 /sys/devices/virtual/thermal/cooling_device2/subsystem ../../../../class/thermal /sys/devices/virtual/thermal/cooling_device3/device ../../../LNXSYSTM:00/LNXCPU:03 /sys/devices/virtual/thermal/cooling_device3/subsystem ../../../../class/thermal /sys/devices/virtual/thermal/cooling_device4/device ../../../LNXSYSTM:00/LNXCPU:04 /sys/devices/virtual/thermal/cooling_device4/subsystem ../../../../class/thermal /sys/devices/virtual/thermal/cooling_device5/device ../../../LNXSYSTM:00/LNXCPU:05 /sys/devices/virtual/thermal/cooling_device5/subsystem ../../../../class/thermal /sys/devices/virtual/thermal/cooling_device6/device ../../../LNXSYSTM:00/LNXCPU:06 /sys/devices/virtual/thermal/cooling_device6/subsystem ../../../../class/thermal /sys/devices/virtual/thermal/cooling_device7/device ../../../LNXSYSTM:00/LNXCPU:07 /sys/devices/virtual/thermal/cooling_device7/subsystem ../../../../class/thermal $ find /sys/class/thermal/cooling_device[0-7] -ls | awk '{print $(NF-2),$NF}' /sys/class/thermal/cooling_device0 ../../devices/virtual/thermal/cooling_device0 /sys/class/thermal/cooling_device1 ../../devices/virtual/thermal/cooling_device1 /sys/class/thermal/cooling_device2 ../../devices/virtual/thermal/cooling_device2 /sys/class/thermal/cooling_device3 ../../devices/virtual/thermal/cooling_device3 /sys/class/thermal/cooling_device4 ../../devices/virtual/thermal/cooling_device4 /sys/class/thermal/cooling_device5 ../../devices/virtual/thermal/cooling_device5 /sys/class/thermal/cooling_device6 ../../devices/virtual/thermal/cooling_device6 /sys/class/thermal/cooling_device7 ../../devices/virtual/thermal/cooling_device7 ■セルシウス度とファーレンハイト度について 「-f」オプションで°Fが出力される。 $ sensors -f coretemp-isa-0000 Adapter: ISA adapter Core 0: +143.6°F (high = +181.4°F, crit = +210.2°F) Core 1: +140.0°F (high = +181.4°F, crit = +210.2°F) Core 2: +141.8°F (high = +181.4°F, crit = +210.2°F) Core 3: +140.0°F (high = +181.4°F, crit = +210.2°F) nouveau-pci-0100 Adapter: PCI adapter GPU core: +0.90 V (min = +0.88 V, max = +1.08 V) temp1: +122.0°F (high = +203.0°F, hyst = +37.4°F) (crit = +221.0°F, hyst = +41.0°F) (emerg = +275.0°F, hyst = +41.0°F) ■highの値は83.0°Cと分かっているので、それぞれ以下の公式に当てはめて計算してみる。 計算しやすいように、9/5=1.8000とする。 °C=(°F-32)/1.8000 °F=1.8000*°C+32 $ echo "scale=4; 9/5" | bc 1.8000 $ echo 181.4 | awk '{printf "%3.1f\n",($1-32)/1.8000}' 83.0 $ echo 83.0 | awk '{printf "%3.1f\n",(1.8*$1)+32}' 181.4