louwrentius / storagefancontrol

Sets chassis fan speed based on highest disk temperature
69 stars 16 forks source link

No ability to define specific fans in config file #1

Closed hyperbart closed 4 years ago

hyperbart commented 9 years ago

My fan-naming convention differs from the one defined in the script, config file does not offer to specify fan-device.

Furthermore it does not allow to specify more than one fan?

louwrentius commented 8 years ago

My motherboard controls the fan speed of all fans with one device. So I can't test or debug a solution with multiple different fans and devices unfortunately.

However, if you are still interested and are willing to test I can alter the code so that it sets the speed on multiple /sys fan devices. (just a for loop over a list of devices.)

hyperbart commented 8 years ago

Sure! Would be happy to test.

louwrentius commented 8 years ago

It took a while but I now have committed a new version. You can specify multiple devices in the INI file separated by a comma. If the script does an operation, it loops over all devices and performs the operation on all of them. Feedback is appreciated.

hyperbart commented 8 years ago

Hi Louw

Changed the config file and moved it to /etc (file /etc/storagefancontrol)

Contents of storagefancontrol:

# Polling interval in seconds.
polling_interval = 30

# Temperature in Celcius.
target_temperature = 38

# Mode can be 'smart' or 'controller'
mode = controller

[Pid]
# The values in this section are tuned for the author's system.
# They seem sane default values but may require tweaking.

# Proportional: how big the change in percent is when an ajustment is made.
P = 2

# Integral: how much the change will be amplified based on the error.
# where 'error' is the distance from the target temperature.
I = 1

# Derivative: the fan speed will be ajusted by this percent direct after a
# change in temperature, multiplied by the 'error' or distance from the target
# temperature. The value will be zero if there is no change.
D = 5

# When the temperature changes, the initial change will be amplified by D.
# This amplification can be further increased based on the D_aplification
# factor
D_amplification = 0

# I_start determines the fan speed in percent when the script is first started.
I_start = 55

# Determines the minimum and maximum fan speed in percent.
I_max = 100
I_min = 45

[Chassis]
# This is the actual PWM device that controls the speed of the fans.
fan_control_device = /sys/class/hwmon/hwmon2/pwm1,/sys/class/hwmon/hwmon2/pwm2
# You can add multiple devices like this:
# fan_control_device = /sys/class/hwmon/hwmon2/device/pwm2,/sys/class/hwmon/hwmon2/device/pwm3,/sys/class/hwmon/hwmon2/device/pwm4 

# To allow the script to control the fan speed instead of the BIOS
# the script needs to enable manual fan speed control through this
# device. Make sure it matches the fan_control_device value.
fan_control_enable = /sys/class/hwmon/hwmon2/pwm2_enable,/sys/class/hwmon/hwmon2/pwm1_enable 
# You can add multiple devices like this:
# fan_control_enable = /sys/class/hwmon/hwmon2/device/pwm2_enable,/sys/class/hwmon/hwmon2/device/pwm3_enable,/sys/class/hwmon/hwmon2/device/pwm4_enable

# PWM fan speed range is 1-255.
# To protect against the risk of overheating, make sure that pwm_min is set
# to a value that results in a reasonable airflow.
pwm_min = 75
pwm_max = 255

# This setting should protect the system against overheating if the script
# crashes.
pwm_safety = 180

[Smart]
# We only look at the temperature of hard drives we care about.
device_filter = "sd"
# How many instances of 'smartctl' are run in parallel when polling for
# the hard drive temperature.
smart_workers = 30

[Controller]
megacli = /opt/MegaRAID/MegaCli/megacli
ports_per_controller = 8
root@nas:~/Louwrentius/storagefancontrol# cat /sys/class/hwmon/hwmon2/pwm2_enable
1
root@nas:~/Louwrentius/storagefancontrol# cat /sys/class/hwmon/hwmon2/pwm1_enable
1
root@nas:~/Louwrentius/storagefancontrol# cat /sys/class/hwmon/hwmon2/pwm1
50
root@nas:~/Louwrentius/storagefancontrol# cat /sys/class/hwmon/hwmon2/pwm2
50

When I execute the storagefancontrol script:

root@nas:~/Louwrentius/storagefancontrol# ./storagefancontrol 
Traceback (most recent call last):
  File "./storagefancontrol", line 495, in <module>
    main()
  File "./storagefancontrol", line 484, in main
    highest_temperature = temp_source.get_highest_temperature()
  File "./storagefancontrol", line 277, in get_highest_temperature
    data = self.fetch_data()
  File "./storagefancontrol", line 259, in fetch_data
    for x in xrange(self.number_of_controllers())]
  File "./storagefancontrol", line 217, in number_of_controllers
    stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0]
  File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory
louwrentius commented 8 years ago

Hi,

Maybe set mode to 'smart' instead of 'controller' unless you use the megacli stuff used with lsi controllers.

I probably should change the default. Make sure smartmontools is installed.

On 26 dec. 2015, at 17:07, hyperbart notifications@github.com wrote:

Hi Louw

Changed the config file and moved it to /etc (file /etc/storagefancontrol)

Contents of storagefancontrol:

[General]

Polling interval in seconds.

polling_interval = 30

Temperature in Celcius.

target_temperature = 38

Mode can be 'smart' or 'controller'

mode = controller

[Pid]

The values in this section are tuned for the author's system.

They seem sane default values but may require tweaking.

Proportional: how big the change in percent is when an ajustment is made.

P = 2

Integral: how much the change will be amplified based on the error.

where 'error' is the distance from the target temperature.

I = 1

Derivative: the fan speed will be ajusted by this percent direct after a

change in temperature, multiplied by the 'error' or distance from the target

temperature. The value will be zero if there is no change.

D = 5

When the temperature changes, the initial change will be amplified by D.

This amplification can be further increased based on the D_aplification

factor

D_amplification = 0

I_start determines the fan speed in percent when the script is first started.

I_start = 55

Determines the minimum and maximum fan speed in percent.

I_max = 100 I_min = 45

[Chassis]

This is the actual PWM device that controls the speed of the fans.

fan_control_device = /sys/class/hwmon/hwmon2/pwm1,/sys/class/hwmon/hwmon2/pwm2

You can add multiple devices like this:

fan_control_device = /sys/class/hwmon/hwmon2/device/pwm2,/sys/class/hwmon/hwmon2/device/pwm3,/sys/class/hwmon/hwmon2/device/pwm4

To allow the script to control the fan speed instead of the BIOS

the script needs to enable manual fan speed control through this

device. Make sure it matches the fan_control_device value.

fan_control_enable = /sys/class/hwmon/hwmon2/pwm2_enable,/sys/class/hwmon/hwmon2/pwm1_enable

You can add multiple devices like this:

fan_control_enable = /sys/class/hwmon/hwmon2/device/pwm2_enable,/sys/class/hwmon/hwmon2/device/pwm3_enable,/sys/class/hwmon/hwmon2/device/pwm4_enable

PWM fan speed range is 1-255.

To protect against the risk of overheating, make sure that pwm_min is set

to a value that results in a reasonable airflow.

pwm_min = 75 pwm_max = 255

This setting should protect the system against overheating if the script

crashes.

pwm_safety = 180

[Smart]

We only look at the temperature of hard drives we care about.

device_filter = "sd"

How many instances of 'smartctl' are run in parallel when polling for

the hard drive temperature.

smart_workers = 30

[Controller] megacli = /opt/MegaRAID/MegaCli/megacli ports_per_controller = 8 root@nas:~/Louwrentius/storagefancontrol# cat /sys/class/hwmon/hwmon2/pwm2_enable 1 root@nas:~/Louwrentius/storagefancontrol# cat /sys/class/hwmon/hwmon2/pwm1_enable 1 root@nas:~/Louwrentius/storagefancontrol# cat /sys/class/hwmon/hwmon2/pwm1 50 root@nas:~/Louwrentius/storagefancontrol# cat /sys/class/hwmon/hwmon2/pwm2 50

When I execute the storagefancontrol script:

root@nas:~/Louwrentius/storagefancontrol# ./storagefancontrol Traceback (most recent call last): File "./storagefancontrol", line 495, in main() File "./storagefancontrol", line 484, in main highest_temperature = temp_source.get_highest_temperature() File "./storagefancontrol", line 277, in get_highest_temperature data = self.fetch_data() File "./storagefancontrol", line 259, in fetch_data for x in xrange(self.number_of_controllers())] File "./storagefancontrol", line 217, in number_of_controllers stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0] File "/usr/lib/python2.7/subprocess.py", line 710, in init errread, errwrite) File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child raise child_exception OSError: [Errno 2] No such file or directory

— Reply to this email directly or view it on GitHub.

hyperbart commented 8 years ago

First tests are looking good!

Dec 27 00:24:41 nas SFC: Temp: 38 | FAN: 40% | PWM: 102 102 | P=0 | I=45 | D=-5 | Err=0 | Dec 27 00:24:51 nas SFC: Temp: 38 | FAN: 45% | PWM: 114 114 | P=0 | I=45 | D=0 | Err=0 | Dec 27 00:25:01 nas SFC: Temp: 37 | FAN: 38% | PWM: 96 96 | P=-2 | I=45 | D=-5 | Err=-1 | Dec 27 00:25:12 nas SFC: Temp: 37 | FAN: 33% | PWM: 84 84 | P=-2 | I=45 | D=-10 | Err=-1 | Dec 27 00:25:22 nas SFC: Temp: 37 | FAN: 33% | PWM: 84 84 | P=-2 | I=45 | D=-10 | Err=-1 | Dec 27 00:25:32 nas SFC: Temp: 38 | FAN: 40% | PWM: 102 102 | P=0 | I=45 | D=-5 | Err=0 | Dec 27 00:25:43 nas SFC: Temp: 37 | FAN: 38% | PWM: 96 96 | P=-2 | I=45 | D=-5 | Err=-1 | Dec 27 00:25:53 nas SFC: Temp: 37 | FAN: 33% | PWM: 84 84 | P=-2 | I=45 | D=-10 | Err=-1 | Dec 27 00:26:03 nas SFC: Temp: 38 | FAN: 40% | PWM: 102 102 | P=0 | I=45 | D=-5 | Err=0 |

hyperbart commented 8 years ago

However, I did notice sometime the scripts stops outputting to syslog, I will keep an eye on it.

hyperbart commented 8 years ago

It effectively stops logging to syslog after a while

Dec 27 00:49:46 nas SFC: Temp: 37 | FAN: 47% | PWM: 119 119 | P=-2 | I=54 | D=-5 | Err=-1 | Dec 27 00:49:56 nas SFC: Temp: 37 | FAN: 41% | PWM: 104 104 | P=-2 | I=53 | D=-10 | Err=-1 | Dec 27 00:50:06 nas SFC: Temp: 37 | FAN: 40% | PWM: 102 102 | P=-2 | I=52 | D=-10 | Err=-1 | Dec 27 00:50:17 nas SFC: Temp: 37 | FAN: 39% | PWM: 99 99 | P=-2 | I=51 | D=-10 | Err=-1 | Dec 27 00:50:27 nas SFC: Temp: 37 | FAN: 38% | PWM: 96 96 | P=-2 | I=50 | D=-10 | Err=-1 | Dec 27 00:50:37 nas SFC: Temp: 37 | FAN: 37% | PWM: 94 94 | P=-2 | I=49 | D=-10 | Err=-1 | Dec 27 00:50:48 nas SFC: Temp: 37 | FAN: 36% | PWM: 91 91 | P=-2 | I=48 | D=-10 | Err=-1 | Dec 27 00:50:58 nas SFC: Temp: 37 | FAN: 35% | PWM: 89 89 | P=-2 | I=47 | D=-10 | Err=-1 | Dec 27 00:51:08 nas SFC: Temp: 37 | FAN: 34% | PWM: 86 86 | P=-2 | I=46 | D=-10 | Err=-1 | Dec 27 00:51:18 nas SFC: Temp: 37 | FAN: 33% | PWM: 84 84 | P=-2 | I=45 | D=-10 | Err=-1 |

When I stop the script and restart it, all seems to be well for a while again.

louwrentius commented 8 years ago

If it stops logging to syslog it probably crashed? Can you run it from te console manually if you did not already? Might see python error.

I notice that the script is turning the fans lower and lower (not dir real because of safety mechanism) because the target temp is way higher than the actual temp it seems. Y

On 27 dec. 2015, at 00:52, hyperbart notifications@github.com wrote:

It effectively stops logging to syslog after a while

Dec 27 00:49:46 nas SFC: Temp: 37 | FAN: 47% | PWM: 119 119 | P=-2 | I=54 | D=-5 | Err=-1 | Dec 27 00:49:56 nas SFC: Temp: 37 | FAN: 41% | PWM: 104 104 | P=-2 | I=53 | D=-10 | Err=-1 | Dec 27 00:50:06 nas SFC: Temp: 37 | FAN: 40% | PWM: 102 102 | P=-2 | I=52 | D=-10 | Err=-1 | Dec 27 00:50:17 nas SFC: Temp: 37 | FAN: 39% | PWM: 99 99 | P=-2 | I=51 | D=-10 | Err=-1 | Dec 27 00:50:27 nas SFC: Temp: 37 | FAN: 38% | PWM: 96 96 | P=-2 | I=50 | D=-10 | Err=-1 | Dec 27 00:50:37 nas SFC: Temp: 37 | FAN: 37% | PWM: 94 94 | P=-2 | I=49 | D=-10 | Err=-1 | Dec 27 00:50:48 nas SFC: Temp: 37 | FAN: 36% | PWM: 91 91 | P=-2 | I=48 | D=-10 | Err=-1 | Dec 27 00:50:58 nas SFC: Temp: 37 | FAN: 35% | PWM: 89 89 | P=-2 | I=47 | D=-10 | Err=-1 | Dec 27 00:51:08 nas SFC: Temp: 37 | FAN: 34% | PWM: 86 86 | P=-2 | I=46 | D=-10 | Err=-1 | Dec 27 00:51:18 nas SFC: Temp: 37 | FAN: 33% | PWM: 84 84 | P=-2 | I=45 | D=-10 | Err=-1 |

— Reply to this email directly or view it on GitHub.

louwrentius commented 8 years ago

P.s. All fans are nicely speeding up/down?

On 27 dec. 2015, at 00:42, hyperbart notifications@github.com wrote:

First tests are looking good!


Dec 27 00:24:51 nas SFC: Temp: 38 | FAN: 45% | PWM: 114 114 | P=0 | I=45 | D=0 | Err=0 |
Dec 27 00:25:01 nas SFC: Temp: 37 | FAN: 38% | PWM: 96 96 | P=-2 | I=45 | D=-5 | Err=-1 |
Dec 27 00:25:12 nas SFC: Temp: 37 | FAN: 33% | PWM: 84 84 | P=-2 | I=45 | D=-10 | Err=-1 |
Dec 27 00:25:22 nas SFC: Temp: 37 | FAN: 33% | PWM: 84 84 | P=-2 | I=45 | D=-10 | Err=-1 |
Dec 27 00:25:32 nas SFC: Temp: 38 | FAN: 40% | PWM: 102 102 | P=0 | I=45 | D=-5 | Err=0 |
Dec 27 00:25:43 nas SFC: Temp: 37 | FAN: 38% | PWM: 96 96 | P=-2 | I=45 | D=-5 | Err=-1 |
Dec 27 00:25:53 nas SFC: Temp: 37 | FAN: 33% | PWM: 84 84 | P=-2 | I=45 | D=-10 | Err=-1 |
Dec 27 00:26:03 nas SFC: Temp: 38 | FAN: 40% | PWM: 102 102 | P=0 | I=45 | D=-5 | Err=0 |

—
Reply to this email directly or view it on GitHub.
hyperbart commented 8 years ago

Do you mind telling me how to get the debug output exactly?

I'm running the following command right now:

./Louwrentius/storagefancontrol/storagefancontrol export DEBUG=true

But not seeing anything on the console, is the export debug=true a config parameter for the config file?

louwrentius commented 8 years ago

Sure! First run the export debug line to set the environment and then just run the script ./storagefancontrol -> you should see output in the console normaly seen in syslog. Then let it run for a while.

On 27 dec. 2015, at 11:24, hyperbart notifications@github.com wrote:

Do you mind telling me how to get the debug output exactly?

I'm running the following command right now:

./Louwrentius/storagefancontrol/storagefancontrol export DEBUG=true

But not seeing anything on the console, is the export debug=true a config parameter for the config file?

— Reply to this email directly or view it on GitHub.

hyperbart commented 8 years ago

I seem to have some problems running the script in debug, can't get it to stop with Ctrl C and no output is shown.

louwrentius commented 8 years ago

Strange, you do something like this?

root@nano:~# export DEBUG=True root@nano:~# /usr/sbin/storagefancontrol Temp: 29 | FAN: -21% | PWM: 100 | P=-11 | I=45 | D=-55 | Err=-11|