Docker with liquidctl and smartctl - Control your (NZXT USB) fan speeds with HDD temps


PSteward

Recommended Posts

Hello!

 

I've been trying to find a solution to the issue of linux and reading/controlling fans, I stumbled upon liquidctl and the existing docker got me on the path to build something myself that reads hard drive temps, averages them and sets fan speed based on that.

I am using the NZXT RGB & Fan Controller - AC-CRFR0-B1-6 and focusing only on controlling the fan speed (fan1, fan2, fan3).

 

Here is a docker: pstewardyul/liquidtemp:latest

Variables needed to set are:

THRESHOLDS_ENV - Set the temperature thresholds that will change the fan speeds - DEFAULT "20,25,30,35,40,45"

FAN_SPEEDS_ENV - Set the speeds that will change with the threshold temperatures - DEFAULT "20,30,40,50,60,100"

EXCLUDED_DRIVES_ENV - If you need to exclude drives from the average calculation - NO DEFAULT - EXAMPLE "/dev/sda,/dev/sdb"

FAN_QUANTITY_ENV - Set to 1, 2, 3 (how many you are connecting to your controller) - DEFAULT "3"

 

The container requires "privileged" to read/control related hardware. Also recommend to set "--log-opt max-size=50m" in extra parameters to limit the log size as every minute the script will run to check/update fan speed, these changes are viewable in the log.

 

If you don't set any variables - no worries - it will load defaults (except the log limit).

This an AMD64 docker image, not sure how to work with the other platforms, and just started with making scripts and building docker this afternoon so even though it works on my system, not sure of others!

 

FYI - The script just works with /dev/sdX not NVME, also some /dev/sdX don't produce the smart output compatible (like my kingston MSATA).

The script can be found at "/usr/local/bin/fan_control.sh".

 

EDIT: Changed from hddtemp (causing issues with spun down drives) to smartctl and added more error checking.

 

--Phil

Edited by PSteward
Link to comment
  • PSteward changed the title to Docker with liquidctl and smartctl - Control your (NZXT USB) fan speeds with HDD temps
  • 3 weeks later...

Hey Ginhead,

Do you have NZXT RGB & Fan Controller or equiv that works with the liquidctl docker?


If you do:

Go to the docker tab, click Add Container.
Name: liquidtemp
Repository: pstewardyul/liquidtemp:latest

Privileged: ON

Click on Add another Path, Port, Variable, Label or Device:
Config Type: Variable
Name: Thresholds
Key: THRESHOLDS_ENV
Value: 20,25,30,35,40,45
Save.

Click on Add another Path, Port, Variable, Label or Device:
Config Type: Variable
Name: Fan Speeds
Key: FAN_SPEEDS_ENV
Value: 20,30,40,50,60,100
Save.

Click on Add another Path, Port, Variable, Label or Device:
Config Type: Variable
Name: Excluded Drives from temp calc
Key: EXCLUDED_DRIVES_ENV
Value: {ENTER WHAT EVER DRIVES YOU DON'T WANT TO CHECK TEMP,. example "/dev/sda" }
Save.

Click on Add another Path, Port, Variable, Label or Device:
Config Type: Variable
Name: Fans
Key: FAN_QUANTITY_ENV
Value: {ENTER QUANTITY OF FANS UNDER CONTROL, example "3" }
Save.

Click Done, after it loads, check the logs for its run status.

Edited by PSteward
  • Like 1
Link to comment
  • 1 month later...
  • 3 months later...
On 6/27/2023 at 3:15 PM, PSteward said:

Hey Ginhead,

Do you have NZXT RGB & Fan Controller or equiv that works with the liquidctl docker?


If you do:

Go to the docker tab, click Add Container.
Name: liquidtemp
Repository: pstewardyul/liquidtemp:latest

Privileged: ON

Click on Add another Path, Port, Variable, Label or Device:
Config Type: Variable
Name: Thresholds
Key: THRESHOLDS_ENV
Value: 20,25,30,35,40,45
Save.

Click on Add another Path, Port, Variable, Label or Device:
Config Type: Variable
Name: Fan Speeds
Key: FAN_SPEEDS_ENV
Value: 20,30,40,50,60,100
Save.

Click on Add another Path, Port, Variable, Label or Device:
Config Type: Variable
Name: Excluded Drives from temp calc
Key: EXCLUDED_DRIVES_ENV
Value: {ENTER WHAT EVER DRIVES YOU DON'T WANT TO CHECK TEMP,. example "/dev/sda" }
Save.

Click on Add another Path, Port, Variable, Label or Device:
Config Type: Variable
Name: Fans
Key: FAN_QUANTITY_ENV
Value: {ENTER QUANTITY OF FANS UNDER CONTROL, example "3" }
Save.

Click Done, after it loads, check the logs for its run status.

I just wanted to thank you! This was a pretty great workaround for my setup which is ran out of a dual bay HDD enclosure. 

The only option for cooling the drives was a on board temp sensor which wouldn't go off until the drives were well into their 50's

  

This way I don't need to run on max 24x7

  

Thanks again!

Link to comment
  • 1 month later...

Thanks @PSteward for this nicely working script and docker image.

 

I noticed that every time the cron job triggers the fan-control script, the `liquidctl initialize all` will ramp up the fan speed to 100% before continuing to set it to e.g. 60%.

It seems like to occur with the `NZXT RGB & Fan Controller` of mine. I did not test it on other devices, so this might be just specific to this one.

An improvement would be to perform the `liquidctl initialize all` only once at the startup (before cron is setup), instead of the periodically triggered fan-control script.

 

Thanks a lot!

Greg

Link to comment
  • 5 weeks later...

Hey Greg,

 

Never noticed! I put that in because I noticed sometimes when I rebooted or started the server not all fans would work (showing 0 RPM) - honestly it doesn't really fix that issue though. It is REALLY important to check the logs at reboot to ensure that all fans are reporting more than 0 RPM and if not shutdown - then start again (reboot doesn't always resolve). I never had the issue once all fans are running but only on the occasional startup or reboot (I may do that every few months, so definitely important to verify).

 

I'll review the coding and see if I can make some improvements based on how its been working of late - in addition at one point I'd like to extract the data into a plugin and show it on the interface (% + Speed).

Link to comment
  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.