Fan Control
From NAS-Central Buffalo - The Linkstation Wiki
(Difference between revisions)
(→Method 3) |
m |
||
| (3 intermediate revisions not shown) | |||
| Line 1: | Line 1: | ||
| + | {{Articles|Kurobox|Hardware}} | ||
| + | |||
== Method 1 == | == Method 1 == | ||
http://spock.ss.u-tokai.ac.jp/~kamii/kurobox/hddtemp.shtml | http://spock.ss.u-tokai.ac.jp/~kamii/kurobox/hddtemp.shtml | ||
| Line 88: | Line 90: | ||
== Method 3 == | == Method 3 == | ||
| - | To install this one | + | ===To install this one=== |
* # su (Become root) | * # su (Become root) | ||
* # mkdir /usr/scripts (Create a directory for your scripts) | * # mkdir /usr/scripts (Create a directory for your scripts) | ||
| Line 96: | Line 98: | ||
* # vim /etc/crontab (Edit your crontab and add the next line) | * # vim /etc/crontab (Edit your crontab and add the next line) | ||
<pre>*/7 * * * * root /usr/scripts/fanctrl auto</pre> | <pre>*/7 * * * * root /usr/scripts/fanctrl auto</pre> | ||
| + | |||
| + | The number 7 means in how frequently cron will run the fanctrl (in minutes) | ||
| + | |||
| + | ===Suggested Improvements=== | ||
| + | 'Give up' cooling the HD if tried successively for more than x minutes. | ||
<pre> | <pre> | ||
Latest revision as of 00:15, 23 August 2007
Contents |
Method 1
http://spock.ss.u-tokai.ac.jp/~kamii/kurobox/hddtemp.shtml
% cat /usr/local/bin/HDDtempChk
#!/bin/sh
PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin
export PATH
REC=/var/spool/rwho/ondorec
LOG=/var/spool/rwho/temp
time=`date '+%y-%m-%d %H:%M'`
data=`hddtemp -nq $1`
ondo=`expr "$data" : '.*: *\([0-9][0-9]*\)[^0-9]*'`
fastspeed()
{
/bin/echo -n ']]]]' > /dev/ttyS1
}
slowspeed()
{
/bin/echo -n '\\\\' > /dev/ttyS1
}
if [ -f $REC ] ; then
count=`cat $REC`
else
echo 0 > $REC
count=-1
fi
if [ $ondo -ge $2 ] ; then
count=`expr $count + 1`
echo $count > $REC
if [ $count -lt 3 ] ; then
ACT=fastspeed
elif [ $count -eq 3 ] ; then
ACT=slowspeed
else
ACT=
fi
else
if [ $count -ne 0 ] ; then
ACT=slowspeed
echo 0 > $REC
else
ACT=
fi
fi
echo "$time $data ($ondo : $2) $ACT" >> $LOG
tail -24 $LOG > ${LOG}x
mv ${LOG}x $LOG
#exit
if [ "$ACT" = "fastspeed" ] ; then
fastspeed
elif [ "$ACT" = "slowspeed" ] ; then
slowspeed
fi
exit
Method 2
http://www.kurobox.info/bbs/index.php?showtopic=550
# Check HD temperature to control the fan speed
#
MAX_TEMP=35
HD_TEMP=`smartctl -A /dev/hda | awk '/^194/ { print($10) }'`
# AVR
#
TTY="/dev/ttyS1"
STR_L="\\\\"
STR_H="]]]]"
# ... check temperature and "silence" the fan
if [ $HD_TEMP -lt $MAX_TEMP ]; then
# tell the AVR Low-speed
echo -n "${STR_L}" > $TTY
else
# tell the AVR High-speed
echo -n "${STR_H}" > $TTY
fi
Method 3
To install this one
- # su (Become root)
- # mkdir /usr/scripts (Create a directory for your scripts)
- # vim /usr/scripts/fanctrl (Create a directory for your scripts)
- (Paste the script in there, than save and exit)
- # chmod 755 /usr/scripts/fanctrl (Make the file executable)
- # vim /etc/crontab (Edit your crontab and add the next line)
*/7 * * * * root /usr/scripts/fanctrl auto
The number 7 means in how frequently cron will run the fanctrl (in minutes)
Suggested Improvements
'Give up' cooling the HD if tried successively for more than x minutes.
#!/bin/sh
#
if [ $# -ne 1 ]; then
cat 2>&1 << EOF
##############################################
fanctrl
-------
purpose: adjusts Kurobox fan speed based on supplied argument
author: Mathias Weiersmueller ( matti_at_weiersmuellerdotcom )
version: 1.0
date: 20060917
license: LGPL, no warranty, use at your own risk
arguments:
auto = sets fan to low/high speed depending on current temp
(based in variable HD_TEMP)
low = sets fan to low speed
high = sets fan to high speed
(number) = sets fan to high speed if HD temp is
equal or higher than (number), or to low speed
if HD temp is lower
###############################################
EOF
exit 127
fi
MAX_TEMP=37 # this is Celsius, not Fahrenheit
HD_TEMP=`/usr/sbin/hddtemp -nq /dev/hda`
# AVR
#
TTY="/dev/ttyS1"
STR_L="\\\\"
STR_H="]]]]"
###############################
# functions
fanlow() {
echo -n "${STR_L}" > $TTY
echo LOW
}
fanhigh() {
echo -n "${STR_H}" > $TTY
echo HIGH
}
################################
# main
case $1 in
auto)
if [ $HD_TEMP -ge $MAX_TEMP ]
then fanhigh
else fanlow
fi
;;
low)
fanlow
;;
high)
fanhigh
;;
-h|--help|-help|-\?)
exec fanctrl # calls fanctrl without arguments, thus displaying help...
;;
*)
if expr "$1" : "[0-9][0-9]" >/dev/null # check for 2-digit number
then
if [ $HD_TEMP -ge $1 ]
then fanhigh
else fanlow
fi
else echo "error: wrong arguments";exit 127;
fi
;;
esac

