sensors.cronを拡張したので、分析スクリプト~/bin/logsensor.shも拡張する。
/var/log/sensors.logの出力は以下のようにタイムスタンプに続いて電力、照度、湿度、室温、そして行末までコア温度が並んでいるので、
2014-05-25 00:10:02.960418012+09:00 65.1 117 34 28.0 44.0 45.0
2014-05-25 00:11:03.211234875+09:00 66.3 120 34 28.0 44.0 45.0
2014-05-25 00:12:02.458205126+09:00 63.7 115 34 28.0 44.0 44.0
2014-05-25 00:13:02.715940424+09:00 65.3 120 34 28.0 44.0 46.0
2014-05-25 00:14:02.945108237+09:00 66.9 120 34 28.0 44.0 46.0
2014-05-25 00:15:03.180283106+09:00 65.6 120 34 28.0 43.0 45.0
2014-05-25 00:16:03.946422282+09:00 65.7 120 34 28.0 44.0 46.0
2014-05-25 00:17:03.851754226+09:00 64.4 0 34 28.0 44.0 45.0
2014-05-25 00:18:04.128084906+09:00 65.5 0 34 28.0 43.0 45.0
2014-05-25 00:19:04.019619909+09:00 65.9 0 34 28.0 42.0 46.0
2014-05-25 00:20:02.984672447+09:00 65.3 0 34 28.0 44.0 45.0
2014-05-25 00:21:04.326406869+09:00 65.9 0 34 28.0 44.0 45.0
F-PLUG |
#!/bin/bash結果は以下のように出力され
awk '
BEGIN {
watt_min=999;watt_max=0;watt_sum=0;watt_cnt=0;
temp_min=999;temp_max=0;temp_sum=0;temp_cnt=0;
core_min=999;core_max=0;core_sum=0;core_cnt=0;
}
{
if ( 6 < NF ){
i = 3; // Watt
if($i < watt_min){watt_min=$i};
if(watt_max < $i){watt_max=$i};
watt_sum += $i;
watt_cnt++;
i = 4; // Illuminance
i = 5; // Humidity
i = 6; // Temperature
if($i < temp_min){temp_min=$i};
if(temp_max < $i){temp_max=$i};
temp_sum += $i;
temp_cnt++;
i = 7;
} else
i = 3;
for (; i <= NF; i++ ){
if($i < core_min){core_min=$i};
if(core_max < $i){core_max=$i};
core_sum += $i;
core_cnt++;
}
date=$1;
if(!length(start)){start=date;}
}
END {
printf "%s, %s, %.1f, %.1f, %.1f, ", start, date, watt_min, watt_sum/watt_cnt, watt_max;
printf "%.1f, %.1f, %.1f, ", temp_min, temp_sum/temp_cnt, temp_max;
printf "%.1f, %.1f, %.1f\n", core_min, core_sum/core_cnt, core_max;
}
' $*
yano@ML110G7:~$ ~/bin/logsensor.sh /var/log/sensors.log最低/平均/最高の並びで電力(W)が3.3/49.1/71.1、室温(℃)が12.1/26.2/30.0、コア温度(℃)が22.0/34.6/48.0という事になった。コア温度以外はここ数日分のデータなのだが、最低値は不自然に低いのでどうもゴミデータっぽいな。
2014-05-09, 2014-05-26, 3.3, 49.1, 71.1, 12.1, 26.2, 30.0, 22.0, 34.6, 48.0
yano@ML110G7:~$
【参照】
●Amazon.co.jp https://www.amazon.co.jp/
┗富士通BSC F-PLUG115 電力・温度・湿度・照度測定機能つきプラグ ホワイト BSCESFP0103 4,900円