netcat6, hddtempをインストールしてncコマンドで温度を取得する。
$ rcsdiff -r1.1 /etc/config-archive/etc/conf.d/hddtemp,v /etc/conf.d/hddtemp =================================================================== RCS file: /etc/config-archive/etc/conf.d/hddtemp,v retrieving revision 1.1 diff -r1.1 /etc/conf.d/hddtemp 12c12 < HDDTEMP_DRIVES="/dev/hda /dev/hdb" --- > HDDTEMP_DRIVES="/dev/sda"
$ nc localhost 7634;echo nc: using stream socket |/dev/sda|ST3250823A|48|C|
rc.localファイルのようなファイルを設置するディレクトリにshスクリプトを設置する。
$ cat /etc/local.d/hddtemp.start | grep -v ^$ | grep -vP '^#(?!!)' #!/bin/sh TEMPLIMIT=48 SLEEP=30 PATH="/bin:/usr/bin" CURRENT_SLEEP=0 BUF="" IFS='|' HDDTEMP=0 CHANGE_MODE="" CURRENT_MODE="" while true do CURRENT_SLEEP=$SLEEP BUF=$(nc localhost 7634 2>/dev/null) set -- $BUF HDDTEMP=$4 if [ "$HDDTEMP" -le $TEMPLIMIT ]; then CHANGE_MODE="low" else CHANGE_MODE="high" fi if [ "$CHANGE_MODE" != "$CURRENT_MODE" ]; then if [ "$CHANGE_MODE" = "low" ]; then logger -t hddtemp "Temperature is Low. Setting Fan Low "`echo $HDDTEMP C` echo -n '\\\\' > /dev/ttyS0 echo -n 'ffff' > /dev/ttyS0 else logger -t hddtemp "Temperature is High. Setting Fan High "`echo $HDDTEMP C` echo -n ']]]]' > /dev/ttyS0 echo -n 'gggg' > /dev/ttyS0 CURRENT_SLEEP=$[ $SLEEP * 10 ] fi fi CURRENT_MODE=$CHANGE_MODE sleep $CURRENT_SLEEP done &
shスクリプトを起動する。
$ sudo chmod +x /etc/local.d/hddtemp.start $ ll /etc/local.d/hddtemp.start -rwxr-xr-x 1 root root 1560 2011-07-11 15:39:23 /etc/local.d/hddtemp.start* $ sudo /etc/local.d/hddtemp.start
確認する。
$ sudo tail -n30 /var/log/messages|grep hddtemp Jul 12 00:54:26 kuroboxhg hddtemp: Temperature is High. Setting Fan High 49 C Jul 12 00:59:26 kuroboxhg hddtemp: Temperature is Low. Setting Fan Low 48 C Jul 12 01:12:28 kuroboxhg hddtemp: Temperature is High. Setting Fan High 49 C Jul 12 01:17:28 kuroboxhg hddtemp: Temperature is Low. Setting Fan Low 48 C Jul 12 02:36:07 kuroboxhg hddtemp: Temperature is High. Setting Fan High 49 C Jul 12 02:41:07 kuroboxhg hddtemp: Temperature is Low. Setting Fan Low 48 C $ pstree -pal 8902 hddtemp.start,8902 /etc/local.d/hddtemp.start └─sleep,17012 30
2.6.25と比べて ttyS0, ttyS1 が違う。
$ uname -a Linux kuroboxhg 2.6.38-gentoo-r6 #2 Wed Jun 15 02:04:57 JST 2011 ppc 82xx Linkstation I/Kurobox(HG) GNU/Linux
0 件のコメント:
コメントを投稿