仕組みはPerlでsensorsコマンドを実行し、得られた結果をテキストに保存するだけの簡単な処理です。
lm_sensorsのインストールは前回の記事を参考にしてください。
centos7で温度取得
1.動作テスト
次のPerlコードを実行してsensorsコマンドの結果を取得できるか確認する。#!usr/bin/perl
$ret = `sensors`;
print $ret;
実行結果
acpitz-virtual-0
Adapter: Virtual device
temp1: +40.0ーC (crit = +60.0ーC)
k10temp-pci-00c3
Adapter: PCI adapter
temp1: +43.5ーC (high = +70.0ーC)
it8716-isa-0e80
Adapter: ISA adapter
in0: +1.87 V (min = +0.00 V, max = +4.08 V)
in1: +1.18 V (min = +0.00 V, max = +3.06 V)
in2: +3.38 V (min = +0.00 V, max = +4.08 V)
+5V: +2.98 V (min = +0.00 V, max = +4.08 V)
in4: +2.99 V (min = +0.00 V, max = +4.08 V)
in5: +1.07 V (min = +0.00 V, max = +4.08 V)
in6: +1.09 V (min = +0.00 V, max = +4.08 V)
in7: +4.08 V (min = +0.00 V, max = +4.08 V) ALARM
Vbat: +3.42 V
fan1: 1527 RPM (min = 0 RPM)
fan2: 0 RPM (min = 10 RPM) ALARM
fan3: 0 RPM (min = 10 RPM) ALARM
temp1: +47.0ーC (low = +127.0ーC, high = +112.0ーC) sensor = thermal diode
temp2: +42.0ーC (low = +127.0ーC, high = +112.0ーC) sensor = thermistor
temp3: +74.0ーC (low = +127.0ーC, high = +112.0ーC) sensor = thermal diode
cpu0_vid: +0.375 V
intrusion0: ALARM