Skip to contentSkip to conversation

fan control based on hard-drive temperatures

lm-sensors Jelle de Jong 2 participants 6 messages Jul 4, 2010 – Jul 5, 2010

lore
Share & tools
lore
#0 lore raw

Hello everybody,

I switched my motherboard from an Asus M4A78 PRO with ATK0110 and IT8721F to a Gigabyte GA-890GPA-UD3H with an iTE IT8720. This way I was able to control my PWM outputs needed for fan control. (see topic in mail archive)

I want to be able to control one of the PWM outputs based on the average output of the temperature of my hard drives.

I setup /etc/fancontrol but it only looks at temperatures from the motherboard witch is kind of useless for me.

I do not want to use some custom system to directly set the PWM. I can life with a shell script that the fancontrol program can use. Is this possible and how, and if not, would somebody be willing to make this?

Thanks in advance,

With kind regards,

Jelle de Jong

# cat /etc/fancontrol
# Configuration file generated by pwmconfig, changes will be lost
INTERVAL=10
DEVPATH=hwmon0=devices/platform/it87.552
DEVNAME=hwmon0=it8720
FCTEMPS=hwmon0/device/pwm2=hwmon0/device/temp3_input hwmon0/device/pwm1=hwmon0/device/temp2_input
FCFANS=hwmon0/device/pwm2=hwmon0/device/fan2_input hwmon0/device/pwm1=hwmon0/device/fan1_input
MINTEMP=hwmon0/device/pwm2=41 hwmon0/device/pwm1=35
MAXTEMP=hwmon0/device/pwm2=45 hwmon0/device/pwm1=55
MINSTART=hwmon0/device/pwm2=58 hwmon0/device/pwm1=70
MINSTOP=hwmon0/device/pwm2=58 hwmon0/device/pwm1=66
# sensors
it8720-isa-0228
Adapter: ISA adapter
in0:         +0.99 V  (min =  +0.00 V, max =  +4.08 V)
in1:         +1.50 V  (min =  +0.00 V, max =  +4.08 V)
in2:         +3.30 V  (min =  +0.00 V, max =  +4.08 V)
in3:         +2.88 V  (min =  +0.00 V, max =  +4.08 V)
in4:         +3.12 V  (min =  +0.00 V, max =  +4.08 V)
in5:         +1.82 V  (min =  +0.00 V, max =  +4.08 V)
in6:         +4.08 V  (min =  +0.00 V, max =  +4.08 V)
in7:         +2.13 V  (min =  +0.00 V, max =  +4.08 V)
Vbat:        +3.25 V
fan1:        986 RPM  (min =    0 RPM)
fan2:       1626 RPM  (min =    0 RPM)
fan3:          0 RPM  (min =    0 RPM)
fan5:          0 RPM  (min =    0 RPM)
temp1:       +45.0 C  (low  = +127.0 C, high = +127.0 C)  sensor = thermistor
temp2:       +36.0 C  (low  = +127.0 C, high = +127.0 C)  sensor = thermal diode
temp3:       +43.0 C  (low  = +127.0 C, high = +127.0 C)  sensor = thermistor
cpu0_vid:   +0.513 V
# hddtemp /dev/sd[abcdefghijklmnop]
/dev/sda: WDC WD10EARS-00Y5B1: 46 C
/dev/sdb: SAMSUNG HD501LJ: 42 C
/dev/sdc: WDC WD10EARS-00Y5B1: 44 C
/dev/sdd: SAMSUNG HD103UJ: drive is sleeping
/dev/sde: SAMSUNG HD103UJ: drive is sleeping
/dev/sdf: ST3500630AS: 50 C
/dev/sdg: Hitachi HDT725032VLA360: 45 C
/dev/sdh: WDC WD5000AAKS-00V1A0: 40 C
/dev/sdi: WDC WD10EARS-00Y5B1: 48 C
/dev/sdj: SAMSUNG HD501LJ: 44 C
/dev/sdk: WDC WD10EARS-00Y5B1: 47 C
/dev/sdl: SAMSUNG HD103UJ: drive is sleeping
/dev/sdm: SAMSUNG HD103UJ: drive is sleeping
/dev/sdn: ST3500418AS: 40 C
/dev/sdo: Maxtor 6V320F0: 46 C
/dev/sdp: WDC WD5000AAKS-65YGA0: 42 C

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

#1 lore raw
Quoted 10 lines · Jelle de Jong

Hello everybody,

I switched my motherboard from an Asus M4A78 PRO with ATK0110 and IT8721F to a Gigabyte GA-890GPA-UD3H with an iTE IT8720. This way I was able to control my PWM outputs needed for fan control. (see topic in mail archive)

I want to be able to control one of the PWM outputs based on the average output of the temperature of my hard drives.

Quoted 7 lines

I setup /etc/fancontrol but it only looks at temperatures from the motherboard witch is kind of useless for me.

I do not want to use some custom system to directly set the PWM. I can life with a shell script that the fancontrol program can use. Is this possible and how, and if not, would somebody be willing to make this?

It might be possible to trick fancontrol into using temperature output from a regular file, though I am not sure. Others may know better.

If that works, you could write a little script to run in the background which keeps reading temperature values from the hard drives and writes the average (or maybe better max ?) into that file, where fancontrol would pick it up from there.

Something along the line of

while true
do

	m=0
	for a in `hddtemp -n /dev/sd[a-z]`
	do
		if [ $a -gt $m ]; then
			m=$a
		fi
	done
	echo $m > /tmp/mymaxtemp
	sleep 10

done

and

FCTEMPS=hwmon0/device/pwm2=/tmp/mymaxtemp hwmon0/device/pwm1=hwmon0/device/temp2_input

Guenter

Quoted 57 lines

Thanks in advance,

With kind regards,

Jelle de Jong

# cat /etc/fancontrol
# Configuration file generated by pwmconfig, changes will be lost
INTERVAL
DEVPATH=hwmon0Þvices/platform/it87.552
DEVNAME=hwmon0=it8720
FCTEMPS=hwmon0/device/pwm2=hwmon0/device/temp3_input hwmon0/device/pwm1=hwmon0/device/temp2_input
FCFANS=hwmon0/device/pwm2=hwmon0/device/fan2_input hwmon0/device/pwm1=hwmon0/device/fan1_input
MINTEMP=hwmon0/device/pwm2A hwmon0/device/pwm15
MAXTEMP=hwmon0/device/pwm2E hwmon0/device/pwm1U
MINSTART=hwmon0/device/pwm2X hwmon0/device/pwm1p
MINSTOP=hwmon0/device/pwm2X hwmon0/device/pwm1f
# sensors
it8720-isa-0228
Adapter: ISA adapter
in0:         +0.99 V  (min =  +0.00 V, max =  +4.08 V)
in1:         +1.50 V  (min =  +0.00 V, max =  +4.08 V)
in2:         +3.30 V  (min =  +0.00 V, max =  +4.08 V)
in3:         +2.88 V  (min =  +0.00 V, max =  +4.08 V)
in4:         +3.12 V  (min =  +0.00 V, max =  +4.08 V)
in5:         +1.82 V  (min =  +0.00 V, max =  +4.08 V)
in6:         +4.08 V  (min =  +0.00 V, max =  +4.08 V)
in7:         +2.13 V  (min =  +0.00 V, max =  +4.08 V)
Vbat:        +3.25 V
fan1:        986 RPM  (min =    0 RPM)
fan2:       1626 RPM  (min =    0 RPM)
fan3:          0 RPM  (min =    0 RPM)
fan5:          0 RPM  (min =    0 RPM)
temp1:       +45.0 C  (low  = +127.0 C, high = +127.0 C)  sensor = thermistor
temp2:       +36.0 C  (low  = +127.0 C, high = +127.0 C)  sensor = thermal diode
temp3:       +43.0 C  (low  = +127.0 C, high = +127.0 C)  sensor = thermistor
cpu0_vid:   +0.513 V
# hddtemp /dev/sd[abcdefghijklmnop]
/dev/sda: WDC WD10EARS-00Y5B1: 46 C
/dev/sdb: SAMSUNG HD501LJ: 42 C
/dev/sdc: WDC WD10EARS-00Y5B1: 44 C
/dev/sdd: SAMSUNG HD103UJ: drive is sleeping
/dev/sde: SAMSUNG HD103UJ: drive is sleeping
/dev/sdf: ST3500630AS: 50 C
/dev/sdg: Hitachi HDT725032VLA360: 45 C
/dev/sdh: WDC WD5000AAKS-00V1A0: 40 C
/dev/sdi: WDC WD10EARS-00Y5B1: 48 C
/dev/sdj: SAMSUNG HD501LJ: 44 C
/dev/sdk: WDC WD10EARS-00Y5B1: 47 C
/dev/sdl: SAMSUNG HD103UJ: drive is sleeping
/dev/sdm: SAMSUNG HD103UJ: drive is sleeping
/dev/sdn: ST3500418AS: 40 C
/dev/sdo: Maxtor 6V320F0: 46 C
/dev/sdp: WDC WD5000AAKS-65YGA0: 42 C
Quoted 4 lines

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

#2 lore raw
In reply to Jelle de Jong

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Guenter,

Quoted 7 lines · Guenter Roeck

It might be possible to trick fancontrol into using temperature output from a regular file, though I am not sure. Others may know better.

If that works, you could write a little script to run in the background which keeps reading temperature values from the hard drives and writes the average (or maybe better max ?) into that file, where fancontrol would pick it up from there.

It seems to work! I created and tested a little bash program that integrates with fancontrol. Would be great if somebody reviews the attachment.

Thanks in advance,

With kind regards,

Jelle de Jong
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iJwEAQECAAYFAkww80YACgkQ1WclBW9j5HmDtwQAnK0CZ61PzjkErdCqyBlUTrS3 QhGNRlZ72WXDpmZxlDmHUYH1bZbv4c+OXETSpXxfJI5xNMqX8u8r+QXfFP/Tr4vY VHJO1uDH/agG/uFrbAyr0VzSyF95mXSlJwbU70+x43gqqfyH/9GfAR6EwfKJBoTH pH3gDbjHncxtqRO3vj8=
=pxSU
-----END PGP SIGNATURE-----

#!/bin/bash

# Company:  PowerCraft Technology
# Author:   Copyright Jelle de Jong <[email protected]>
# Note:     Please send me an email if you enhanced the document
# Date:     2010-07-04
# License:  CC-BY-SA

# This document is free documentation; you can redistribute it and/or

# modify it under the terms of the Creative Commons Attribution Share
# Alike as published by the Creative Commons Foundation; either version
# 3.0 of the License, or (at your option) any later version.
#
# This document is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# Creative Commons BY-SA License for more details.
#
# http://creativecommons.org/licenses/by-sa/

#-----------------------------------------------------------------------

apt-get install bc hddtemp file fancontrol

#-----------------------------------------------------------------------

echo '#!/bin/bash -e

# Company:  PowerCraft Technology
# Author:   Copyright Jelle de Jong <[email protected]>
# Note:     Please send me an email if you enhanced the script
# Version:  0.0.2
# Date:     2010-07-04

# This program is free software; you can redistribute it and/or modify

# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.

PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin/

LC_ALL=C

# set -x
# exec 2>>/var/log/pct-fancontrol-hddtemp.log
# date=$(date)

DISKS="[abcdefghijklmnop]"

# located in /var/lib/ so it will be there for fancontrol during boot
LOCATION=/var/lib/pct-fancontrol-hddtemp
FILE_MAX="$LOCATION"/pct-fancontrol-hddtemp-maximum
FILE_AVG="$LOCATION"/pct-fancontrol-hddtemp-average

DEGUG=0

[[ -e $LOCATION ]] || mkdir "$LOCATION"

while true

    do
    temperature=0
    summation=0
    maximum=0
    average=0
    count=0
    for value in $(hddtemp -n /dev/sd$DISKS 2>/dev/null)
    do
        temperature="${value//[!0-9]}"
        ((summation+=$temperature))
        ((count+=1))
        if [ $temperature -gt $maximum ]; then
            maximum=$temperature
        fi
        average=$(echo "scale=1; $summation / $count" | bc)
        if [ $DEGUG = 1 ]; then
            echo $summation
            echo $maximum
            echo $average
            echo $count
            echo "-----"
        fi
    done
    # fancontrol output format
    echo "($maximum * 1000)/1" | bc > "$FILE_MAX"
    echo "($average * 1000)/1" | bc > "$FILE_AVG"
    sleep 45

done

exit' | tee /usr/local/bin/pct-fancontrol-hddtemp

chown root:root /usr/local/bin/pct-fancontrol-hddtemp chmod 755 /usr/local/bin/pct-fancontrol-hddtemp ls -hal /usr/local/bin/pct-fancontrol-hddtemp cat /usr/local/bin/pct-fancontrol-hddtemp

#-----------------------------------------------------------------------

/usr/local/bin/pct-fancontrol-hddtemp &
cat /var/lib/pct-fancontrol-hddtemp/pct-fancontrol-hddtemp-maximum cat /var/lib/pct-fancontrol-hddtemp/pct-fancontrol-hddtemp-average cat /var/lib/pct-fancontrol-hddtemp/*

watch cat /var/lib/pct-fancontrol-hddtemp/*

#-----------------------------------------------------------------------

vim /etc/fancontrol

    INTERVAL=10
    DEVPATH=hwmon0=devices/platform/it87.552
    DEVNAME=hwmon0=it8720
    FCTEMPS=hwmon0/device/pwm2=/var/lib/pct-fancontrol-hddtemp/pct-fancontrol-hddtemp-maximum hwmon0/device/pwm1=hwmon0/device/temp2_input
    FCFANS=hwmon0/device/pwm2=hwmon0/device/fan2_input hwmon0/device/pwm1=hwmon0/device/fan1_input
    MINTEMP=hwmon0/device/pwm2=41 hwmon0/device/pwm1=35
    MAXTEMP=hwmon0/device/pwm2=51 hwmon0/device/pwm1=55
    MINSTART=hwmon0/device/pwm2=58 hwmon0/device/pwm1=70
    MINSTOP=hwmon0/device/pwm2=58 hwmon0/device/pwm1=66

/etc/init.d/fancontrol restart

#-----------------------------------------------------------------------

/etc/init.d/fancontrol stop

whereis fancontrol
file /usr/sbin/fancontrol

bash -x /usr/sbin/fancontrol

#-----------------------------------------------------------------------

vim /etc/rc.local
/usr/local/bin/pct-fancontrol-hddtemp

cat /etc/rc.local

#-----------------------------------------------------------------------

ps aux | grep fancontrol

#-----------------------------------------------------------------------

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

#3 lore raw
In reply to Jelle de Jong

Hi Jelle,

Quoted 9 lines · Jelle de Jong

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Guenter,

Quoted 3 lines · Guenter Roeck

It might be possible to trick fancontrol into using temperature output from a regular file, though I am not sure. Others may know better.

Quoted 9 lines
Quoted 4 lines

If that works, you could write a little script to run in the background which keeps reading temperature values from the hard drives and writes the average (or maybe better max ?) into that file, where fancontrol would pick it up from there.

It seems to work! I created and tested a little bash program that integrates with fancontrol. Would be great if somebody reviews the attachment.

Excellent!

This looks like it might be quite useful for others as well. Wonder if it would make sense to integrate it info fancontrol and/or pwmconfig.

Couple of minor comments inline.

Quoted 17 lines

Thanks in advance,

With kind regards,

Jelle de Jong
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iJwEAQECAAYFAkww80YACgkQ1WclBW9j5HmDtwQAnK0CZ61PzjkErdCqyBlUTrS3 QhGNRlZ72WXDpmZxlDmHUYH1bZbv4c+OXETSpXxfJI5xNMqX8u8r+QXfFP/Tr4vY VHJO1uDH/agG/uFrbAyr0VzSyF95mXSlJwbU70+x43gqqfyH/9GfAR6EwfKJBoTH pH3gDbjHncxtqRO3vj8> =pxSU
-----END PGP SIGNATURE-----

#!/bin/bash

Quoted 7 lines
# Company:  PowerCraft Technology
# Author:   Copyright Jelle de Jong <[email protected]>
# Note:     Please send me an email if you enhanced the document
# Date:     2010-07-04
# License:  CC-BY-SA

# This document is free documentation; you can redistribute it and/or

That isn't really a documentation, but an installation shell script. Not that I care much, it is just odd to have such a script with an ending of .txt. Is that common nowadays or just your personal touch ?

Quoted 60 lines
# modify it under the terms of the Creative Commons Attribution Share
# Alike as published by the Creative Commons Foundation; either version
# 3.0 of the License, or (at your option) any later version.
#
# This document is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# Creative Commons BY-SA License for more details.
#
# http://creativecommons.org/licenses/by-sa/

#-----------------------------------------------------------------------

apt-get install bc hddtemp file fancontrol

#-----------------------------------------------------------------------

echo '#!/bin/bash -e

# Company:  PowerCraft Technology
# Author:   Copyright Jelle de Jong <[email protected]>
# Note:     Please send me an email if you enhanced the script
# Version:  0.0.2
# Date:     2010-07-04

# This program is free software; you can redistribute it and/or modify

# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.

PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin/

LC_ALL=C

# set -x
# exec 2>>/var/log/pct-fancontrol-hddtemp.log
# date=$(date)

DISKS="[abcdefghijklmnop]"

# located in /var/lib/ so it will be there for fancontrol during boot
LOCATION=/var/lib/pct-fancontrol-hddtemp
FILE_MAX="$LOCATION"/pct-fancontrol-hddtemp-maximum
FILE_AVG="$LOCATION"/pct-fancontrol-hddtemp-average

DEGUG=0

[[ -e $LOCATION ]] || mkdir "$LOCATION"

while true

Quoted 15 lines
    do
    temperature=0
    summation=0
    maximum=0
    average=0
    count=0
    for value in $(hddtemp -n /dev/sd$DISKS 2>/dev/null)
    do
        temperature="${value//[!0-9]}"
        ((summation+=$temperature))
        ((count+=1))
        if [ $temperature -gt $maximum ]; then
            maximum=$temperature
        fi
        average=$(echo "scale=1; $summation / $count" | bc)

"average=$(($summation / $count))" would probably be sufficient here. For a "final" code version, it would be sufficient to calculate the average after the loop. But then you would have to check for $count = 0, so I am not sure if it would be worth it.

Quoted 11 lines
        if [ $DEGUG = 1 ]; then
            echo $summation
            echo $maximum
            echo $average
            echo $count
            echo "-----"
        fi
    done
    # fancontrol output format
    echo "($maximum * 1000)/1" | bc > "$FILE_MAX"
    echo "($average * 1000)/1" | bc > "$FILE_AVG"

"echo $(($average * 1000))" seems to work as well and would be a bit simpler. What is the "/1" for, anyway ? bc doesn't seem to need it.

Also, you are loosing precision because average is calculated (and rounded down) first. You could avoid that with "echo $(($average * 1000 / $count))" if you check for the $count=0 case. But then that doesn't really make much of a difference, so I am not sure if it would be worth it either.

Quoted 41 lines

sleep 45
done

exit' | tee /usr/local/bin/pct-fancontrol-hddtemp

chown root:root /usr/local/bin/pct-fancontrol-hddtemp chmod 755 /usr/local/bin/pct-fancontrol-hddtemp ls -hal /usr/local/bin/pct-fancontrol-hddtemp cat /usr/local/bin/pct-fancontrol-hddtemp

#-----------------------------------------------------------------------

/usr/local/bin/pct-fancontrol-hddtemp &
cat /var/lib/pct-fancontrol-hddtemp/pct-fancontrol-hddtemp-maximum cat /var/lib/pct-fancontrol-hddtemp/pct-fancontrol-hddtemp-average cat /var/lib/pct-fancontrol-hddtemp/*

watch cat /var/lib/pct-fancontrol-hddtemp/*

#-----------------------------------------------------------------------

vim /etc/fancontrol

    INTERVAL
    DEVPATH=hwmon0Þvices/platform/it87.552
    DEVNAME=hwmon0=it8720
    FCTEMPS=hwmon0/device/pwm2=/var/lib/pct-fancontrol-hddtemp/pct-fancontrol-hddtemp-maximum hwmon0/device/pwm1=hwmon0/device/temp2_input
    FCFANS=hwmon0/device/pwm2=hwmon0/device/fan2_input hwmon0/device/pwm1=hwmon0/device/fan1_input
    MINTEMP=hwmon0/device/pwm2A hwmon0/device/pwm15
    MAXTEMP=hwmon0/device/pwm2Q hwmon0/device/pwm1U
    MINSTART=hwmon0/device/pwm2X hwmon0/device/pwm1p
    MINSTOP=hwmon0/device/pwm2X hwmon0/device/pwm1f

/etc/init.d/fancontrol restart

#-----------------------------------------------------------------------

/etc/init.d/fancontrol stop

whereis fancontrol
file /usr/sbin/fancontrol

Quoted 7 lines

bash -x /usr/sbin/fancontrol

#-----------------------------------------------------------------------

vim /etc/rc.local
/usr/local/bin/pct-fancontrol-hddtemp

Might be better to add a startup script in /etc/init.d and/or /etc/rc*.d and make sure it runs before fancontrol is started.

Quoted 7 lines

cat /etc/rc.local

#-----------------------------------------------------------------------

ps aux | grep fancontrol

#-----------------------------------------------------------------------

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

#4 lore raw
In reply to Jelle de Jong

Hi Guenter,

Quoted 3 lines · Guenter Roeck
Quoted 3 lines

This looks like it might be quite useful for others as well. Wonder if it would make sense to integrate it info fancontrol and/or pwmconfig. Couple of minor comments inline.

Thanks for the feedback. I would love to see fancontrol be enhanced with the feature to use the hddtemp average or maximum.

I attached a new version making hddtemp use all harddisk instead of a specified list. (can still be specified) I also moved the calculation of the avarage temperuture outside the main loop when not running in debug mode. This should make the shell scrip slightly faster.

Quoted 3 lines

That isn't really a documentation, but an installation shell script. Not that I care much, it is just odd to have such a script with an ending of .txt. Is that common nowadays or just your personal touch?

The installation document was .txt the script inside was bash both had different licenses and styles, it is more personal touch. I share a lot of this stuff, so it is my standard format.

Quoted 4 lines

"average=$(($summation / $count))" would probably be sufficient here. For a "final" code version, it would be sufficient to calculate the average after the loop. But then you would have to check for $count == 0, so I am not sure if it would be worth it.

We need support for a floating number not a integer. The average temperature can become 39.9 degrees. And with your suggestion this would be rounded in 39, this is not the fan control I need, the shell command I choice makes the average of 39.9 possible.

Quoted 2 lines

"echo $(($average * 1000))" seems to work as well and would be a bit simpler. What is the "/1" for, anyway ? bc doesn't seem to need it.

The scale of a multiplication is min(a+b,max(scale,a,b)), where a and b are the scales of the factors. (and 46.5 has a scale of 1, so the above expression becomes min(0+1,max(0,1,0))=min(1,1)=1. So witouth the /1 part bc returns 46500.0 instead of the needed 46500 for fancontrol. Adding the /1 over the results makes bc return 46500 and this can be used by fancontrol (notice the support for the extra precision because of the earlier use of bc)

Quoted 5 lines

Also, you are loosing precision because average is calculated (and rounded down) first. You could avoid that with "echo $(($average * 1000 / $count))" if you check for the $count==0 case. But then that doesn't really make much of a difference, so I am not sure if it would be worth it either.

I don't see any precession loss. There would be precession loss with the previous suggestions, maybe I am seeing it wrong :D

Quoted 2 lines

Might be better to add a startup script in /etc/init.d and/or /etc/rc*.d and make sure it runs before fancontrol is started.

True, but I am not going to maintain a starup script, when there is a useful excising starup script for fan control.

If somebody want they can pick it up and integrate it with fancontrol, as long I don’t lose temperature precession or the possibility to use the maximum or average.

With kind regards,

Jelle de Jong

# Company:  PowerCraft Technology
# Author:   Copyright Jelle de Jong <[email protected]>
# Note:     Please send me an email if you enhanced the document
# Date:     2010-07-04 / 2010-07-05
# License:  CC-BY-SA

# This document is free documentation; you can redistribute it and/or

# modify it under the terms of the Creative Commons Attribution Share
# Alike as published by the Creative Commons Foundation; either version
# 3.0 of the License, or (at your option) any later version.
#
# This document is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# Creative Commons BY-SA License for more details.
#
# http://creativecommons.org/licenses/by-sa/

#-----------------------------------------------------------------------

apt-get install bc hddtemp file fancontrol

#-----------------------------------------------------------------------

echo '#!/bin/bash -e

# Company:  PowerCraft Technology
# Author:   Copyright Jelle de Jong <[email protected]>
# Note:     Please send me an email if you enhanced the script
# Version:  0.0.4
# Date:     2010-07-04 / 2010-07-05

# This program is free software; you can redistribute it and/or modify

# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.

PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin/

LC_ALL=C

# set -x
# exec 2>>/var/log/pct-fancontrol-hddtemp.log
# date=$(date)

DISKS="/dev/sd[a-z]"

# located in /var/lib/ so it will be there for fancontrol during boot
LOCATION=/var/lib/pct-fancontrol-hddtemp
FILE_MAX="$LOCATION"/pct-fancontrol-hddtemp-maximum
FILE_AVG="$LOCATION"/pct-fancontrol-hddtemp-average

DEGUG=0

[[ -e $LOCATION ]] || mkdir "$LOCATION"

while true

    do
    temperature=0
    summation=0
    maximum=0
    average=0
    count=0
    for value in $(hddtemp -n $DISKS 2>/dev/null)
    do
        temperature="${value//[!0-9]}"
        ((summation+=$temperature))
        ((count+=1))
        if [ $temperature -gt $maximum ]; then
            maximum=$temperature
        fi
        if [ $DEGUG = 1 ]; then
            average=$(echo "scale=1; $summation / $count" | bc)
            echo $summation
            echo $maximum
            echo $average
            echo $count
            echo "-----"
        fi
    done
    average=$(echo "scale=1; $summation / $count" | bc)
    # fancontrol output format
    echo "($maximum * 1000)/1" | bc > "$FILE_MAX"
    echo "($average * 1000)/1" | bc > "$FILE_AVG"
    sleep 45

done

exit' | tee /usr/local/bin/pct-fancontrol-hddtemp

chown root:root /usr/local/bin/pct-fancontrol-hddtemp chmod 755 /usr/local/bin/pct-fancontrol-hddtemp ls -hal /usr/local/bin/pct-fancontrol-hddtemp cat /usr/local/bin/pct-fancontrol-hddtemp

#-----------------------------------------------------------------------

bash -x /usr/local/bin/pct-fancontrol-hddtemp /usr/local/bin/pct-fancontrol-hddtemp &
cat /var/lib/pct-fancontrol-hddtemp/pct-fancontrol-hddtemp-maximum cat /var/lib/pct-fancontrol-hddtemp/pct-fancontrol-hddtemp-average cat /var/lib/pct-fancontrol-hddtemp/*

watch cat /var/lib/pct-fancontrol-hddtemp/*

#-----------------------------------------------------------------------

vim /etc/fancontrol

    INTERVAL=10
    DEVPATH=hwmon0=devices/platform/it87.552
    DEVNAME=hwmon0=it8720
    FCTEMPS=hwmon0/device/pwm2=/var/lib/pct-fancontrol-hddtemp/pct-fancontrol-hddtemp-maximum hwmon0/device/pwm1=hwmon0/device/temp2_input
    FCFANS=hwmon0/device/pwm2=hwmon0/device/fan2_input hwmon0/device/pwm1=hwmon0/device/fan1_input
    MINTEMP=hwmon0/device/pwm2=41 hwmon0/device/pwm1=35
    MAXTEMP=hwmon0/device/pwm2=51 hwmon0/device/pwm1=55
    MINSTART=hwmon0/device/pwm2=58 hwmon0/device/pwm1=70
    MINSTOP=hwmon0/device/pwm2=58 hwmon0/device/pwm1=66

/etc/init.d/fancontrol restart

#-----------------------------------------------------------------------

/etc/init.d/fancontrol stop

whereis fancontrol
file /usr/sbin/fancontrol

bash -x /usr/sbin/fancontrol

#-----------------------------------------------------------------------

vim /etc/rc.local
/usr/local/bin/pct-fancontrol-hddtemp

cat /etc/rc.local

#-----------------------------------------------------------------------

ps aux | grep fancontrol

#-----------------------------------------------------------------------

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

#5 lore raw
In reply to Jelle de Jong
Quoted 28 lines · Jelle de Jong

Hi Guenter,

Quoted 3 lines · Guenter Roeck
Quoted 3 lines

This looks like it might be quite useful for others as well. Wonder if it would make sense to integrate it info fancontrol and/or pwmconfig. Couple of minor comments inline.

Thanks for the feedback. I would love to see fancontrol be enhanced with the feature to use the hddtemp average or maximum.

I attached a new version making hddtemp use all harddisk instead of a specified list. (can still be specified) I also moved the calculation of the avarage temperuture outside the main loop when not running in debug mode. This should make the shell scrip slightly faster.

Quoted 3 lines

That isn't really a documentation, but an installation shell script. Not that I care much, it is just odd to have such a script with an ending of .txt. Is that common nowadays or just your personal touch?

The installation document was .txt the script inside was bash both had different licenses and styles, it is more personal touch. I share a lot of this stuff, so it is my standard format.

Quoted 4 lines

"average=$(($summation / $count))" would probably be sufficient here. For a "final" code version, it would be sufficient to calculate the average after the loop. But then you would have to check for $count = 0, so I am not sure if it would be worth it.

Quoted 5 lines

We need support for a floating number not a integer. The average temperature can become 39.9 degrees. And with your suggestion this would be rounded in 39, this is not the fan control I need, the shell command I choice makes the average of 39.9 possible.

Ok, understood.

Quoted 10 lines
Quoted 2 lines

"echo $(($average * 1000))" seems to work as well and would be a bit simpler. What is the "/1" for, anyway ? bc doesn't seem to need it.

The scale of a multiplication is min(a+b,max(scale,a,b)), where a and b are the scales of the factors. (and 46.5 has a scale of 1, so the above expression becomes min(0+1,max(0,1,0))=min(1,1)=1. So witouth the /1 part bc returns 46500.0 instead of the needed 46500 for fancontrol. Adding the /1 over the results makes bc return 46500 and this can be used by fancontrol (notice the support for the extra precision because of the earlier use of bc)

Ok, thanks for the clarification.

Quoted 10 lines
Quoted 6 lines

Also, you are loosing precision because average is calculated (and rounded down) first. You could avoid that with "echo $(($average * 1000 / $count))" if you check for the $count=0 case. But then that doesn't really make much of a difference, so I am not sure if it would be worth it either.

I don't see any precession loss. There would be precession loss with the previous suggestions, maybe I am seeing it wrong :D

You are right ...

Thanks,
Guenter

Quoted 157 lines
Quoted 2 lines

Might be better to add a startup script in /etc/init.d and/or /etc/rc*.d and make sure it runs before fancontrol is started.

True, but I am not going to maintain a starup script, when there is a useful excising starup script for fan control.

If somebody want they can pick it up and integrate it with fancontrol, as long I don’t lose temperature precession or the possibility to use the maximum or average.

With kind regards,

Jelle de Jong

# Company:  PowerCraft Technology
# Author:   Copyright Jelle de Jong <[email protected]>
# Note:     Please send me an email if you enhanced the document
# Date:     2010-07-04 / 2010-07-05
# License:  CC-BY-SA

# This document is free documentation; you can redistribute it and/or

# modify it under the terms of the Creative Commons Attribution Share
# Alike as published by the Creative Commons Foundation; either version
# 3.0 of the License, or (at your option) any later version.
#
# This document is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# Creative Commons BY-SA License for more details.
#
# http://creativecommons.org/licenses/by-sa/

#-----------------------------------------------------------------------

apt-get install bc hddtemp file fancontrol

#-----------------------------------------------------------------------

echo '#!/bin/bash -e

# Company:  PowerCraft Technology
# Author:   Copyright Jelle de Jong <[email protected]>
# Note:     Please send me an email if you enhanced the script
# Version:  0.0.4
# Date:     2010-07-04 / 2010-07-05

# This program is free software; you can redistribute it and/or modify

# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.

PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin/

LC_ALL=C

# set -x
# exec 2>>/var/log/pct-fancontrol-hddtemp.log
# date=$(date)

DISKS="/dev/sd[a-z]"

# located in /var/lib/ so it will be there for fancontrol during boot
LOCATION=/var/lib/pct-fancontrol-hddtemp
FILE_MAX="$LOCATION"/pct-fancontrol-hddtemp-maximum
FILE_AVG="$LOCATION"/pct-fancontrol-hddtemp-average

DEGUG=0

[[ -e $LOCATION ]] || mkdir "$LOCATION"

while true

    do
    temperature=0
    summation=0
    maximum=0
    average=0
    count=0
    for value in $(hddtemp -n $DISKS 2>/dev/null)
    do
        temperature="${value//[!0-9]}"
        ((summation+=$temperature))
        ((count+=1))
        if [ $temperature -gt $maximum ]; then
            maximum=$temperature
        fi
        if [ $DEGUG = 1 ]; then
            average=$(echo "scale=1; $summation / $count" | bc)
            echo $summation
            echo $maximum
            echo $average
            echo $count
            echo "-----"
        fi
    done
    average=$(echo "scale=1; $summation / $count" | bc)
    # fancontrol output format
    echo "($maximum * 1000)/1" | bc > "$FILE_MAX"
    echo "($average * 1000)/1" | bc > "$FILE_AVG"
    sleep 45

done

exit' | tee /usr/local/bin/pct-fancontrol-hddtemp

chown root:root /usr/local/bin/pct-fancontrol-hddtemp chmod 755 /usr/local/bin/pct-fancontrol-hddtemp ls -hal /usr/local/bin/pct-fancontrol-hddtemp cat /usr/local/bin/pct-fancontrol-hddtemp

#-----------------------------------------------------------------------

bash -x /usr/local/bin/pct-fancontrol-hddtemp /usr/local/bin/pct-fancontrol-hddtemp &
cat /var/lib/pct-fancontrol-hddtemp/pct-fancontrol-hddtemp-maximum cat /var/lib/pct-fancontrol-hddtemp/pct-fancontrol-hddtemp-average cat /var/lib/pct-fancontrol-hddtemp/*

watch cat /var/lib/pct-fancontrol-hddtemp/*

#-----------------------------------------------------------------------

vim /etc/fancontrol

    INTERVAL
    DEVPATH=hwmon0Þvices/platform/it87.552
    DEVNAME=hwmon0=it8720
    FCTEMPS=hwmon0/device/pwm2=/var/lib/pct-fancontrol-hddtemp/pct-fancontrol-hddtemp-maximum hwmon0/device/pwm1=hwmon0/device/temp2_input
    FCFANS=hwmon0/device/pwm2=hwmon0/device/fan2_input hwmon0/device/pwm1=hwmon0/device/fan1_input
    MINTEMP=hwmon0/device/pwm2A hwmon0/device/pwm15
    MAXTEMP=hwmon0/device/pwm2Q hwmon0/device/pwm1U
    MINSTART=hwmon0/device/pwm2X hwmon0/device/pwm1p
    MINSTOP=hwmon0/device/pwm2X hwmon0/device/pwm1f

/etc/init.d/fancontrol restart

#-----------------------------------------------------------------------

/etc/init.d/fancontrol stop

whereis fancontrol
file /usr/sbin/fancontrol

bash -x /usr/sbin/fancontrol

#-----------------------------------------------------------------------

vim /etc/rc.local
/usr/local/bin/pct-fancontrol-hddtemp

Quoted 7 lines

cat /etc/rc.local

#-----------------------------------------------------------------------

ps aux | grep fancontrol

#-----------------------------------------------------------------------

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors