PigLover

Reference Material Supermicro X9/X10/X11 Fan Speed Control

Supermicro fan speed control

  1. weust

    weust Member

    Joined:
    Aug 15, 2014
    Messages:
    294
    Likes Received:
    23
    A while back I made a very small script for my FreeBSD ZFS server.
    BMC is set to full speed, then the script sets the two fan zones on my motherboard to a certain percentage.
    It needs 1 second between lines otherwise it will mess things up.

    The script is placed in /usr/local/etc/rc.d/ iirc, so I can enable it in /etc/rc.conf.

    What I would like to figure out next, with my limited shell scripting knowledge+the internet, is to create a cron job that will check the temperature of the disks, CPU, etc and adjust the fanspeed accordingly.
    Increase or decrease by 5% speed based on 5C temperature increase/decrease. Something like that.
     
    #41
  2. EffrafaxOfWug

    EffrafaxOfWug Radioactive Member

    Joined:
    Feb 12, 2015
    Messages:
    1,077
    Likes Received:
    356
    In the linux universe at least, this was achievable with fancontrol/pwmconfig (although I don't think to the extent of 5% increments*), I'm not sure if FreeBSD has anything to match (wikipedia only mentions OpenBSD or Dragonfly in the context of userspace fan control).

    * The settings I used way back when was basically set a score based on a combination of CPU and HDD temps, and then fiddle the PWM values directly. By the time I found hddfancontrol did the same thing but better, I'd moved to IPMI motherboards where the BIOS made a good enough job of it.
     
    #42
  3. weust

    weust Member

    Joined:
    Aug 15, 2014
    Messages:
    294
    Likes Received:
    23
    The 5% was more an idea. And if I can find some software that does it all for me, even better.
    Saves me time :)
     
    #43
  4. EffrafaxOfWug

    EffrafaxOfWug Radioactive Member

    Joined:
    Feb 12, 2015
    Messages:
    1,077
    Likes Received:
    356
    I assume you're using a Supermicro motherboard and using the raws to control the duty cycle?

    What you'll want to do is cycle through your hard drives (I assume you'll have to use smartctl as I don't think you'll have hddtemp available) and calculate either the peak or average temperature and run your duty cycle parameters accordingly. Here's a very quick'n'dirty way of doing this in bash on linux (don't think BSD uses /sys/block so adapt as necessary) with a dependency on bc to do some of the arithmetic:
    Code:
    #!/bin/bash
    discs=($(find /sys/block -maxdepth 1 -type l -iname 'sd*' -printf '%P '))
    
    all_disc_temps=0
    max_disc_temp=0
    
    for disc in "${discs[@]}";
    do
        disc_temp=$(smartctl -a /dev/"${disc##*/}"|awk '/Temperature_Celsius/{print $10}')
        all_disc_temps=$(echo "$disc_temps + $disc_temp"|bc)
        if [[ $disc_temp -gt $max_disc_temp ]]; then
            max_disc_temp=$disc_temp
        fi
    done
    
    avg_disc_temp="$(echo "$all_disc_temps / ${#discs[@]}"|bc)"
    
    echo "Maximum disc temperature over ${#discs[@]} discs is $max_disc_temp"
    echo "Average disc temperature over ${#discs[@]} discs is $avg_disc_temp"
    (Seriously, the above code won't work directly on BSD and has no error checking so don't be surprised if it doesn't work and makes your server explode. It makes a lot of assumptions and heavily abuses bash's lack of typing, very hacky, YMMV, BOGOF, £0.02, etc)

    The above produces something like this on my current machine:
    Code:
    root@wug:~# /scratch/smart_temps
    Maximum disc temperature over 9 discs is 43
    Average disc temperature over 9 discs is 37
    I don't think there's much benefit in running it every minute (and indeed if you follow my example it's not a fast script to run as it queries each drive sequentially - s'one of the reasons I usually use hddtemp to do it since you can grab all temperatures over a local socket simultaneously and don't need to be root to do it; on a system with a lot of drives the above could conceivably take more than a minute to run anyway) but you could easily add some if blocks for various levels of fan duty cycle at whatever thresholds you want to set e.g. go to maximum duty cycle if the drive temperature exceeds 50. Then, every 5mins, the script will run and adjust the duty cycle accordingly.
     
    #44
    Last edited: Aug 5, 2019
  5. weust

    weust Member

    Joined:
    Aug 15, 2014
    Messages:
    294
    Likes Received:
    23
    I'll have a look someday when I have time and when it rains.
    Also I like to avoid bash and prefer plain sh.

    FreeBSD has smartctl, so I can grep the temps from there.

    Doing it on a disk temp level is a good idea.
    Hadn't thought that far ahead yet.
     
    #45
  6. EffrafaxOfWug

    EffrafaxOfWug Radioactive Member

    Joined:
    Feb 12, 2015
    Messages:
    1,077
    Likes Received:
    356
    I'd say that if you've got bash available, and especially if you're not au fair with scripting, then use it over sh. Plain sh is generally missing a huge amount of terribly useful functionality (depending on which exact sh you're actually using) that makes life much easier for the casual scripter. Much of the script above would be doable without casting into arrays I think but I find arrays, parameter expansion and scoping far too useful to give up.

    As long as you can get the various temperatures you care about into variables that can be treated as numbers, it's pretty trivial to just run them through a set of if statements or a case block to set whatever duty cycle you deem appropriate for that temperature. That'll depend on how your systems are set up, what fans are plugged in to where, what zones you have available in your IPMI, etc - you can start getting into relatively complicated logic quite quickly, so I'd just advise trying a one-size-fits-all approach first.
     
    #46
  7. weust

    weust Member

    Joined:
    Aug 15, 2014
    Messages:
    294
    Likes Received:
    23
    bash is available as either a pkg or in ports, I just don't like to install it.
    I like to keep things as GNU-free as possible.

    I use tcsh as my user shell. The sh is just the one that comes with FreeBSD.

    I am not very experienced in shell scripting (PowerShell is more my thing) but I will give it a go.
    Will see how far I can get.
     
    #47
  8. Falloutboy

    Falloutboy Member

    Joined:
    Oct 23, 2011
    Messages:
    93
    Likes Received:
    13
    Something is a bit off with regard to this and my X10DRX, looking at the motherboard manual on page 1-3 it shows Fan6 as being CPU1 and Fan7 as CPU2.
    At the moment just to get everything up and running this is under Windows 10 Pro with the Superdoctor software, after I have fully validated all the hardware it will be switched to Linux but this is a good time to be learning about such things.. Is the information you mentioned only relevant when read via the BMC?
     
    #48
Similar Threads: Supermicro X9/X10/X11
Forum Title Date
Guides PRTG Hardware Monitoring - Supermicro Jan 6, 2019
Guides Create Custom Fan Speed Maps for SuperMicro X10 Servers via IPMI Apr 28, 2018
Guides Supermicro Chassis parts Mar 11, 2018
Guides Supermicro X11SAT working and complete lm-sensors config Jun 13, 2017

Share This Page