Script: Hybrid CPU & HD Fan Zone Controller

Joined
May 10, 2017
Messages
838
Yes, it is possible to modify the script to ignore SSDs. I did that exact mod with my adaptation of @Stux's script. On my version of the script, I modified the code in sub get_hd_list to remove SSDs. On my system, the following line works in that subroutine (I added the 'grep -v "SSD" ' to remove lines with "SSD" from the disk list):

Cool, I believe that using "SSD" will work for me as well.

Code:
<ATA WDC WD40EZRZ-00G 0A80>		at scbus0 target 8 lun 0 (pass0,da0)
<ATA WDC WD40EZRZ-00G 0A80>		at scbus0 target 9 lun 0 (pass1,da1)
<ATA WDC WD40EZRZ-00G 0A80>		at scbus0 target 10 lun 0 (pass2,da2)
<ATA WDC WD40EZRZ-00G 0A80>		at scbus0 target 11 lun 0 (pass3,da3)
<ATA WDC WD40EZRZ-00G 0A80>		at scbus0 target 12 lun 0 (pass4,da4)
<ATA WDC WD40EZRZ-00G 0A80>		at scbus0 target 13 lun 0 (pass5,da5)
<ATA WDC WD40EZRZ-00G 0A80>		at scbus0 target 14 lun 0 (pass6,da6)
<ATA WDC WD40EZRZ-00G 0A80>		at scbus0 target 15 lun 0 (pass7,da7)
<CT250MX500SSD1 M3CR010>		   at scbus1 target 0 lun 0 (pass8,ada0)
<CT250MX500SSD1 M3CR010>		   at scbus2 target 0 lun 0 (pass9,ada1)
<CT250MX500SSD1 M3CR010>		   at scbus3 target 0 lun 0 (pass10,ada2)
<CT250MX500SSD1 M3CR010>		   at scbus4 target 0 lun 0 (pass11,ada3)
<CT250MX500SSD1 M3CR010>		   at scbus5 target 0 lun 0 (pass12,ada4)
<CT250MX500SSD1 M3CR010>		   at scbus6 target 0 lun 0 (pass13,ada5)
<CT250MX500SSD1 M3CR010>		   at scbus7 target 0 lun 0 (pass14,ada6)
<CT250MX500SSD1 M3CR010>		   at scbus8 target 0 lun 0 (pass15,ada7)
<CT250MX500SSD1 M3CR010>		   at scbus9 target 0 lun 0 (pass16,ada8)
<CT250MX500SSD1 M3CR010>		   at scbus10 target 0 lun 0 (pass17,ada9)
<CT250MX500SSD1 M3CR010>		   at scbus11 target 0 lun 0 (pass18,ada10)
<CT250MX500SSD1 M3CR010>		   at scbus12 target 0 lun 0 (pass19,ada11)
 

Stux

MVP
Joined
Jun 2, 2016
Messages
4,358
yesterday updated the BMC firmware and completely forgot to shutdown the script, so during the update it lost communication with the BMC and reset it, this is not good during the update and the update failed leaving the IPMI completely nonfunctional, I though I might have bricked it, but to my relief re-flashing it with a DOS flash drive brought it back to life, I'm sharing this so you might consider adding a warning on the first post, this was totally my fault but it might happen to others and really brick the BMC.

Yes, that would be a problem. I’ve made a note in the first post, but of course, the simple solution is to shutdown FreeNAS when updating the IPMI firmware ;)
 

Stux

MVP
Joined
Jun 2, 2016
Messages
4,358

jro

iXsystems
iXsystems
Joined
Jul 16, 2018
Messages
80
Hey Stux, I found a small bug in the script. If you set $fan_duty_high or $hd_fan_duty_high to any value less than 80, then the script freaks out when it activates this duty cycle. It will momentarily set a 100 percent duty cycle, then apply the desired high-level duty cycle, sleep $fan_speed_change_delay seconds, then repeat $bmc_fail_threshold times, after which it resets the BMC.

The following lines (168-170) seem to be the cause of the issue:
Code:
# massage fan speeds
$cpu_max_fan_speed *= 0.8;
$hd_max_fan_speed *= 0.8;
Obviously these calculations aren't aware of the desired max fan speed preference. I'd suggest doing something like the following to achieve the same effect:
Code:
# massage fan speeds
$cpu_max_fan_speed = ($fan_duty_high - 5)/100 * $cpu_max_fan_speed;
$hd_max_fan_speed = ($hd_fan_duty_high - 5)/100 * $hd_max_fan_speed;
It'll still "massage" the max fan speed down a bit, but it will respect setting the desired max duty cycle to values less than 80%. In my own testing, I've found adjusting the "massage" beyond 5% is too severe.
 

MAleEgo

Cadet
Joined
Apr 4, 2019
Messages
2
Hi there,
This looks exactly like what I'm after; a solution to control fan speed based on load/temps.
I can't tell, however, if this will work on my system. Is anyone aware if this will work for me; I have an Asus X99-WS/IPMI mobo and running 2 Noctua NF-A14 PWM on the CPU and 4 NF-A8 PWM on the chassis.
Very much appreciate the support.
Thank you.
 

MAleEgo

Cadet
Joined
Apr 4, 2019
Messages
2
I'm not aware of fan zones on my mobo but these are the attached fan names currently set to 'Generic' in the BIOS settings. I know the fans speeds do react to CPU temp changes currently

1554393820855.png
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,702
I can't tell, however, if this will work on my system. Is anyone aware if this will work for me; I have an Asus X99-WS/IPMI mobo and running 2 Noctua NF-A14 PWM on the CPU and 4 NF-A8 PWM on the chassis.
I can confirm that ASUS are clueless and have programmed their IPMI to read fan speeds, but give you the ability to do nothing about that. I opened tickets with them and went through their hoops to have the product team tell me that for sure since nobody else there even knows what IPMI is.

What I ended up doing was adapting the script and doing some hacking to use a Corsair Commander Pro to control the fans instead (see script and code).

Good luck with it. Happy to chip in if it's not clear.
 

Pizza

Cadet
Joined
Mar 16, 2019
Messages
5
I am sorry for this stupid question.. But I'm kind of a noob at this.
Where do I save the fan controller script file? I cannot get this working.. Saved in within a pool on my freenas, but can't get it started?
 
Joined
Dec 2, 2015
Messages
730
I am sorry for this stupid question.. But I'm kind of a noob at this.
Where do I save the fan controller script file? I cannot get this working.. Saved in within a pool on my freenas, but can't get it started?
It should work from pretty much anywhere, but you need to be sure the script is executable by running chmod +x <script name>. For testing, it is best to open a new session in tmux, then run the script from within there with . <script name>. Kill the script with a Ctrl-C if needed. The advantage of using tmux is that the script will keep running even if you close the ssh or console connection.

Once you have tweaked any settings and gains and confirmed the script controls the fans correctly, you should set it up as a Init/Shutdown task in FreeNAS Task section. With the new GUI, you'd make it look like:

Screen Shot 2019-04-11 at 6.13.03 AM.png
 

Pizza

Cadet
Joined
Mar 16, 2019
Messages
5
Thank you @Kevin Horton for the detailed reply. Much appreciated.

Got it working now! So testing it out with ssh and tmux. But there is something not that does not seem to be right because I get the "Unable to send RAW command - Invalid data field in request" message..

Motherboard is Supermicro X9SCM-f

Code:
2019-04-11 23:58:38: CPU Temp: 37.0 dropped below 45, CPU Fan going med.

Unable to send RAW command (channel=0x0 netfn=0x30 lun=0x0 cmd=0x70 rsp=0xcc): Invalid data field in request

2019-04-11 23:58:38: Maximum HD Temperature: 32

2019-04-11 23:58:38: Drives are cool enough, going to 30%

Unable to send RAW command (channel=0x0 netfn=0x30 lun=0x0 cmd=0x70 rsp=0xcc): Invalid data field in request


 
Last edited:
Joined
Dec 2, 2015
Messages
730
Thank you @Kevin Horton for the detailed reply. Much appreciated.

Got it working now! So testing it out with ssh and tmux. But there is something not that does not seem to be right because I get the "Unable to send RAW command - Invalid data field in request" message..

Motherboard is Supermicro X9SCM-f

Code:
2019-04-11 23:58:38: CPU Temp: 37.0 dropped below 45, CPU Fan going med.

Unable to send RAW command (channel=0x0 netfn=0x30 lun=0x0 cmd=0x70 rsp=0xcc): Invalid data field in request

2019-04-11 23:58:38: Maximum HD Temperature: 32

2019-04-11 23:58:38: Drives are cool enough, going to 30%

Unable to send RAW command (channel=0x0 netfn=0x30 lun=0x0 cmd=0x70 rsp=0xcc): Invalid data field in request


The script was written for X10 series motherboards. It is possible that it is sending commands that aren't understood by an X9 board. Ask Supermicro if it is possible to read and set fan duty cycle on your board. If it is possible, ask what the correct ipmitool commands are for your board.
 

Xyrgh

Explorer
Joined
Apr 11, 2016
Messages
69
I'm having an issue with the hard drive duty lower threshold. There is no way my drives stay cool enough at 30%, so I've set the
$hd_fan_duty_low to 50, but when the drives are below temp, the script is still forcing 30%.

Any ideas why it's doing this? Pasting specific part of the script:

Code:
## HD FAN DUTY LEVELS
## These levels are used to control the HD fans
$hd_fan_duty_high     = 100;    # percentage on, ie 100% is full speed.
$hd_fan_duty_med_high     = 75;
$hd_fan_duty_med_low    = 65;
$hd_fan_duty_low     = 50;    # some 120mm fans stall below 30.
 

Beemer533

Dabbler
Joined
Sep 29, 2018
Messages
27
Stux, thanks a lot for this script! I stumbled upon it trying to fix my surging Noctua and CPU fans in my new build and it worked like a charm. I am running a Supermicro X11SSM-F MB and it worked without any changes, as far as I can tell.

Thanks again...
 

Jatrabari

Contributor
Joined
Sep 23, 2017
Messages
100
I have 2 SATA DOMs and a regular SSD (ada*) that run much hotter than my HDDs. Can I exclude them from the script so it won't use them as reference to adjust the fan speeds?
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,702
I have 2 SATA DOMs and a regular SSD (ada*) that run much hotter than my HDDs. Can I exclude them from the script so it won't use them as reference to adjust the fan speeds?
Yes, but you probably don't have to do anything as it's already allowed for generally in the script to ignore SSDs.
 

Jatrabari

Contributor
Joined
Sep 23, 2017
Messages
100
Yes, but you probably don't have to do anything as it's already allowed for generally in the script to ignore SSDs.

When I tested the script in screen it took the max temp from one of the SSD (ada) at 41 C when the HDDs (da) were about 30 C.

Code:
2019-05-17 17:44:11: Setting fan mode to 1 (full)
2019-05-17 17:44:16: CPU Temp: 24.0
2019-05-17 17:44:16: CPU Temp: 24.0 <= 35, CPU Fan going low.
2019-05-17 17:44:16: CPU Fan: low
2019-05-17 17:44:16: CPU Fan changing... (low)
2019-05-17 17:44:16: Setting Zone 0 duty cycle to 30%
2019-05-17 17:44:16: /dev/da0: 30
2019-05-17 17:44:16: /dev/da1: 29
2019-05-17 17:44:16: /dev/da2: 30
2019-05-17 17:44:16: /dev/da3: 29
2019-05-17 17:44:16: /dev/da4: 29
2019-05-17 17:44:16: /dev/da5: 29
2019-05-17 17:44:16: /dev/da6: 29
2019-05-17 17:44:16: /dev/da7: 29
2019-05-17 17:44:16: /dev/ada0: 33
2019-05-17 17:44:16: /dev/ada1: 37
2019-05-17 17:44:16: /dev/ada2: 41
2019-05-17 17:44:16: Maximum HD Temperature: 41
2019-05-17 17:44:16: Drives are too hot, going to 100%
2019-05-17 17:44:16: Setting Zone 1 duty cycle to 100%
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,702
Have a look in your script for this section and use the code below instead... you can play around with the grep as needed.

Code:
sub get_hd_list
{
    my $disk_list = `camcontrol devlist | grep -v "SSD" | grep -v "Verbatim" | grep -v "KINGSTON" | sed 's:.*(::;s:).*::;s:,pass[0-9]*::;s:pass[0-9]*,::' | egrep '^[a]*da[0-9]+\$' | tr '\012' ' '`;
    dprint(3,"$disk_list\n");

    my @vals = split(" ", $disk_list);
   
    foreach my $item (@vals)
    {
        dprint(2,"$item\n");
    }

    return @vals;
}


You may want to consider looking for @Kevin Horton 's version, which deals much better with granular fan speed vs temperature and has had a bit more tweaking over time.
https://github.com/khorton/nas_fan_control
 
Top