タイトルの通りです。
環境
- Ubuntu 20.04
CPU の温度観測プローブを調べる
以下の記事が参考になりました。
/sys/class/thermal
に thermal_zone0
〜 thermal_zone3
の4つのディレクトリがあり、このうちのどれかが CPU の温度観測用のファイルのようです。
これらの中にある type
ファイルを見ることで、何の温度を表しているかが分かるようです。
$ cat /sys/class/thermal/thermal_zone0/type
acpitz
$ cat /sys/class/thermal/thermal_zone1/type
acpitz
$ cat /sys/class/thermal/thermal_zone2/type
pch_skylake
$ cat /sys/class/thermal/thermal_zone3/type
x86_pkg_temp
どうやら私の環境では thermal_zone3
が CPU の温度のようです。
なので、/sys/class/thermal/thermal_zone3/temp
を見ることで CPU の温度が取得できます。
$ cat /sys/class/thermal/thermal_zone3/temp
35000
1000 倍された値が表示されるので、上記の場合 35℃ です。
Telegraf の設定
上記のファイルを監視するように、telegraf.conf
に以下を記述するだけです。
[[inputs.file]]
files = ["/sys/class/thermal/thermal_zone3/temp"]
name_override = "cpu_temperature"
data_format = "value"
data_type = "integer"