Difference between revisions of "Fannyd - control the temperature and fan of your LinkStation"
Davy gravy (Talk | contribs) (→BACKGROUND) |
Davy gravy (Talk | contribs) (→BACKGROUND) |
||
(6 intermediate revisions by the same user not shown) | |||
Line 15: | Line 15: | ||
Tested only on a KuroHG running OpenEmbedded/OpenLink, but should run on any PPC LinkStation that that has [[avr_evtd]] and [http://freshmeat.net/projects/hddtemp/ hddtemp] installed, perhaps with some modifications for the paths to the executables. | Tested only on a KuroHG running OpenEmbedded/OpenLink, but should run on any PPC LinkStation that that has [[avr_evtd]] and [http://freshmeat.net/projects/hddtemp/ hddtemp] installed, perhaps with some modifications for the paths to the executables. | ||
− | The code for it is listed below. If you are suggesting modifications to it, | + | The code for it is listed below. '''If you are suggesting modifications to it, please perform those on the discussion page on the back''', and also '''please''' comment your changes so that others can readily see your intent. Thank you. |
'''Package for download''': A package (.ipk) is available for anyone who wants it - it has been tested on the OpenEmbedded/OpenLink beta distro, running on a KuroHG. Send [[User:davy_gravy|me]] a PM and I'll email you a copy. | '''Package for download''': A package (.ipk) is available for anyone who wants it - it has been tested on the OpenEmbedded/OpenLink beta distro, running on a KuroHG. Send [[User:davy_gravy|me]] a PM and I'll email you a copy. | ||
====DESCRIPTION==== | ====DESCRIPTION==== | ||
− | fannyd is a daemon that controls the fan speed on a PPC LinkStation by checking the temperature (hddtemp -n /dev/sda, for instance) and comparing that against a user-determined temperature limit. If that limit is exceeded, then it sends a command such as | + | fannyd is a simple wrapper of avr_evtd and hddtemp. It starts a daemon that controls the fan speed on a PPC LinkStation by checking the temperature (hddtemp -n /dev/sda, for instance) and comparing that against a user-determined temperature limit. If that limit is exceeded, then it sends a command such as |
echo -n "]]]]" > /dev/ttyS0 | echo -n "]]]]" > /dev/ttyS0 | ||
to the AVR chip to switch the fan to high speed. This check is done periodically, according to a time-check period defined by the user. If the temperature is less than or equal to the set limit, fannyd lets the fan run a bit longer, and then drops the fan to lower speed. | to the AVR chip to switch the fan to high speed. This check is done periodically, according to a time-check period defined by the user. If the temperature is less than or equal to the set limit, fannyd lets the fan run a bit longer, and then drops the fan to lower speed. | ||
Line 33: | Line 33: | ||
UARTPORT=/dev/ttyS0 | UARTPORT=/dev/ttyS0 | ||
− | Note that CHECKPERIOD is in seconds and TEMPLIMIT is in Celsius. Also note that the UARTPORT value will vary depending on which distro you are running. | + | Note that CHECKPERIOD is in seconds and TEMPLIMIT is in Celsius. Also note that the UARTPORT value will vary depending on which distro you are running. |
====OPTIONS==== | ====OPTIONS==== | ||
Line 47: | Line 47: | ||
/usr/sbin/fanny | /usr/sbin/fanny | ||
/etc/fannyd.conf | /etc/fannyd.conf | ||
− | /etc/init.d/fannyd | + | /etc/init.d/fannyd-daemon |
====BACKGROUND==== | ====BACKGROUND==== | ||
− | I wrote the scripts/code below up because of heat problems in | + | I wrote the scripts/code below up because of heat problems in one of my boxes. I noticed how hot the air coming out from the back was - much hotter than from my LS-HG. The KuroHG has a Maxtor HD, which brandwise seem to run hot. Knowing that heat decreases component life, I naturally saw the need to crank up the fan - but it made sense to have it on high only when needed - based on temp. |
Since the HD is the greatest contributor to heat in our boxes I felt like smartmontools might have some potential for use here. Researching it, I saw hddtemp, which is much cleaner for this purpose. | Since the HD is the greatest contributor to heat in our boxes I felt like smartmontools might have some potential for use here. Researching it, I saw hddtemp, which is much cleaner for this purpose. | ||
Line 56: | Line 56: | ||
After writing it up and testing it, a few conversations with other members here made me wonder if anyone else had stumbled upon the need for this type of functionality. Certainly there have been others, like this article entitled [http://www.kurobox.com/mwiki/index.php/Fan_Control Fan Control] at Kurobox.com. | After writing it up and testing it, a few conversations with other members here made me wonder if anyone else had stumbled upon the need for this type of functionality. Certainly there have been others, like this article entitled [http://www.kurobox.com/mwiki/index.php/Fan_Control Fan Control] at Kurobox.com. | ||
− | Thanks to lb_worm for avr_evtd and Emmanuel Varagnat for | + | Thanks to lb_worm for avr_evtd and Emmanuel Varagnat for hddtemp, respectively - they did all of the hard work that made this so easy for me. |
− | + | ||
====CODE==== | ====CODE==== | ||
Line 64: | Line 63: | ||
+ | #! /bin/sh | ||
+ | # | ||
+ | # fan-temperature control daemon - fannydee | ||
+ | # | ||
+ | # this script checks the hdd temp on any LS-PPC that is running avr_evtd | ||
+ | # and has hddtemp installed. If the temperature is greater than the | ||
+ | # defined limit, it kicks the fan up to high speed. | ||
+ | # | ||
+ | # After the checkperiod elapses, it checks again. If the temperature is | ||
+ | # below that limit, then it drops it back to low speed. | ||
+ | # | ||
+ | # | ||
+ | # In /etc/fannyd.conf, mak sure you define your devices that you want to check the temperature on | ||
+ | # e.g. /dev/hda or /dev/sda , the temperature limit, time check, etc. | ||
+ | # You can declare more than one hard drive, but that is not a likely situation. | ||
+ | |||
+ | source /etc/fannyd.conf | ||
+ | |||
+ | |||
+ | |||
+ | while : ; do | ||
+ | |||
+ | for A in $DEVICES ; do | ||
+ | TEMPERATURE=$(/usr/sbin/hddtemp -n $A) | ||
+ | if [ $TEMPERATURE -gt $TEMPLIMIT ]; then | ||
+ | echo -n "]]]]" > $UARTPORT | ||
+ | else | ||
+ | sleep 600 # overcompensate w/ 10 min of extra fan time | ||
+ | echo -n "\\\\" > $UARTPORT | ||
+ | fi | ||
+ | done | ||
+ | sleep $CHECKPERIOD | ||
+ | |||
+ | done | ||
+ | |||
+ | |||
+ | exit 0 | ||
− | /etc/init.d/fannyd #startup script | + | |
+ | /etc/init.d/fannyd-daemon #startup script | ||
+ | |||
+ | #! /bin/sh | ||
+ | # | ||
+ | # start/stop script for fannyd fan/temperature control daemon | ||
+ | # | ||
+ | |||
+ | case "$1" in | ||
+ | start) | ||
+ | echo -n "Starting fannyd" | ||
+ | /usr/sbin/fannyd & | ||
+ | ;; | ||
+ | stop) | ||
+ | echo -n "Stopping fannyd" | ||
+ | killall fannyd | ||
+ | ;; | ||
+ | restart) | ||
+ | echo -n "Stopping fannyd" | ||
+ | killall fannyd | ||
+ | echo -n "Starting fannyd" | ||
+ | /usr/sbin/fannyd & | ||
+ | ;; | ||
+ | *) | ||
+ | echo "Usage: $0 {start|stop|restart}" | ||
+ | exit 1 | ||
+ | ;; | ||
+ | esac | ||
Line 72: | Line 135: | ||
/etc/fannyd.conf #the configuration file | /etc/fannyd.conf #the configuration file | ||
+ | |||
+ | # config file for fan-temperature control daemon - fannydee | ||
+ | # | ||
+ | # The script checks the hdd temp on any LS-PPC that is running avr_evtd | ||
+ | # and has hddtemp installed. If the temperature is greater than the | ||
+ | # defined limit, it kicks the fan up to high speed. | ||
+ | # | ||
+ | # After the checkperiod elapses, it checks again. If the temperature is | ||
+ | # below that limit, then it drops it back to low speed. | ||
+ | # | ||
+ | # | ||
+ | # Define your devices that you want to check the temperature on | ||
+ | # e.g. /dev/hda or /dev/sda | ||
+ | # You can declare more than one, but that is not a likely situation. | ||
+ | |||
+ | DEVICES=/dev/sda | ||
+ | |||
+ | |||
+ | # | ||
+ | # define the timelimit in seconds. It is suggested to use a value | ||
+ | # around 300 to 600 seconds | ||
+ | # | ||
+ | |||
+ | CHECKPERIOD=600 | ||
+ | |||
+ | |||
+ | |||
+ | # | ||
+ | # define a temperature limit at which you want the fan to kick up at | ||
+ | # a good value is around 38C. Yes, use celsius. | ||
+ | |||
+ | TEMPLIMIT=40 | ||
+ | |||
+ | |||
+ | # | ||
+ | # set your UART/AVR serial port that accepts commands here | ||
+ | # it can be determined by grepping your ps aux output for | ||
+ | # avr_evtd. it will be either /dev/ttyS0 or /dev/ttyS1 | ||
+ | # test for avr_evtd running (to be implemented) | ||
+ | |||
+ | UARTPORT=/dev/ttyS0 |
Latest revision as of 10:13, 23 June 2008
Contents
fannyd
NAME
fannyd - a simple daemon for controlling fan speed and temperature on PPC LinkStations
SYNOPSIS
fannyd
AVAILABILITY
Tested only on a KuroHG running OpenEmbedded/OpenLink, but should run on any PPC LinkStation that that has avr_evtd and hddtemp installed, perhaps with some modifications for the paths to the executables.
The code for it is listed below. If you are suggesting modifications to it, please perform those on the discussion page on the back, and also please comment your changes so that others can readily see your intent. Thank you.
Package for download: A package (.ipk) is available for anyone who wants it - it has been tested on the OpenEmbedded/OpenLink beta distro, running on a KuroHG. Send me a PM and I'll email you a copy.
DESCRIPTION
fannyd is a simple wrapper of avr_evtd and hddtemp. It starts a daemon that controls the fan speed on a PPC LinkStation by checking the temperature (hddtemp -n /dev/sda, for instance) and comparing that against a user-determined temperature limit. If that limit is exceeded, then it sends a command such as
echo -n "]]]]" > /dev/ttyS0
to the AVR chip to switch the fan to high speed. This check is done periodically, according to a time-check period defined by the user. If the temperature is less than or equal to the set limit, fannyd lets the fan run a bit longer, and then drops the fan to lower speed.
fannyd produces no output.
Settings for fannyd are sourced from /etc/fannyd.conf , which is a readable, well-commented file. The default values are as follows:
DEVICES = /dev/sda1 CHECKPERIOD=600 TEMPLIMIT=40 UARTPORT=/dev/ttyS0
Note that CHECKPERIOD is in seconds and TEMPLIMIT is in Celsius. Also note that the UARTPORT value will vary depending on which distro you are running.
OPTIONS
There are no options, but fannyd also comes with fanny , which is a non-daemon form of fannyd that performs a temperature check and fan adjust a single time when it is executed. In addition, it produces output that shows the hard drive temperature and which UART port is set.
RESOURCES
fannyd requires avr_evtd and hddtemp.
FILES
/usr/sbin/fannyd /usr/sbin/fanny /etc/fannyd.conf /etc/init.d/fannyd-daemon
BACKGROUND
I wrote the scripts/code below up because of heat problems in one of my boxes. I noticed how hot the air coming out from the back was - much hotter than from my LS-HG. The KuroHG has a Maxtor HD, which brandwise seem to run hot. Knowing that heat decreases component life, I naturally saw the need to crank up the fan - but it made sense to have it on high only when needed - based on temp.
Since the HD is the greatest contributor to heat in our boxes I felt like smartmontools might have some potential for use here. Researching it, I saw hddtemp, which is much cleaner for this purpose.
After writing it up and testing it, a few conversations with other members here made me wonder if anyone else had stumbled upon the need for this type of functionality. Certainly there have been others, like this article entitled Fan Control at Kurobox.com.
Thanks to lb_worm for avr_evtd and Emmanuel Varagnat for hddtemp, respectively - they did all of the hard work that made this so easy for me.
CODE
/usr/sbin/fannyd #the script for the fan daemon
#! /bin/sh # # fan-temperature control daemon - fannydee # # this script checks the hdd temp on any LS-PPC that is running avr_evtd # and has hddtemp installed. If the temperature is greater than the # defined limit, it kicks the fan up to high speed. # # After the checkperiod elapses, it checks again. If the temperature is # below that limit, then it drops it back to low speed. # # # In /etc/fannyd.conf, mak sure you define your devices that you want to check the temperature on # e.g. /dev/hda or /dev/sda , the temperature limit, time check, etc. # You can declare more than one hard drive, but that is not a likely situation. source /etc/fannyd.conf while : ; do for A in $DEVICES ; do TEMPERATURE=$(/usr/sbin/hddtemp -n $A) if [ $TEMPERATURE -gt $TEMPLIMIT ]; then echo -n "]]]]" > $UARTPORT else sleep 600 # overcompensate w/ 10 min of extra fan time echo -n "\\\\" > $UARTPORT fi done sleep $CHECKPERIOD done exit 0
/etc/init.d/fannyd-daemon #startup script
#! /bin/sh # # start/stop script for fannyd fan/temperature control daemon # case "$1" in start) echo -n "Starting fannyd" /usr/sbin/fannyd & ;; stop) echo -n "Stopping fannyd" killall fannyd ;; restart) echo -n "Stopping fannyd" killall fannyd echo -n "Starting fannyd" /usr/sbin/fannyd & ;; *) echo "Usage: $0 {start|stop|restart}" exit 1 ;; esac
/etc/fannyd.conf #the configuration file
# config file for fan-temperature control daemon - fannydee # # The script checks the hdd temp on any LS-PPC that is running avr_evtd # and has hddtemp installed. If the temperature is greater than the # defined limit, it kicks the fan up to high speed. # # After the checkperiod elapses, it checks again. If the temperature is # below that limit, then it drops it back to low speed. # # # Define your devices that you want to check the temperature on # e.g. /dev/hda or /dev/sda # You can declare more than one, but that is not a likely situation. DEVICES=/dev/sda # # define the timelimit in seconds. It is suggested to use a value # around 300 to 600 seconds # CHECKPERIOD=600 # # define a temperature limit at which you want the fan to kick up at # a good value is around 38C. Yes, use celsius. TEMPLIMIT=40 # # set your UART/AVR serial port that accepts commands here # it can be determined by grepping your ps aux output for # avr_evtd. it will be either /dev/ttyS0 or /dev/ttyS1 # test for avr_evtd running (to be implemented) UARTPORT=/dev/ttyS0