ZabbixでT2000の温度を監視したかった。
結果が返ってくるまで10秒くらいかかるので注意。Zabbixの場合はServerとAgentの設定ファイルのTimeoutを10以上にする必要がある。
[sourcecode]
#!/bin/sh
if [ $# -ne 1 ]; then
prtpicl -v -c temperature-sensor | awk ‘$0~/Label/ || $0~/:Temp/ {print $2}’| awk ‘{if(NR%2)ORS=" ";else ORS="\n";print}’
return 0
fi
prtpicl -v -c temperature-sensor | awk ‘$0~/Label/ || $0~/:Temp/ {print $2}’| awk ‘{if(NR%2)ORS=" ";else ORS="\n";print}’ | grep "$1" | awk ‘{print $2}’
[/sourcecode]
実行例:
引数なし
[sourcecode]
$ ./temp.sh
T_CORE 71
T_AMB 39
T_TCORE 58
T_BCORE 59
T_AMB 34
T_AMB 27
[/sourcecode]
引数あり
[sourcecode]
$ ./temp.sh T_CORE
71
[/sourcecode]