Register for the iXsystems Community to get an ad-free experience

Script to control fan speed in response to hard drive temperatures

mrMuppet

Contributor
Joined
Mar 14, 2014
Messages
191
Hi,

i would like to use your script on my system. But i have a ASRock-board (E3C224D4I-14S). Its the same Board user AlainS has and i have the same error msg:
Code:
bash spincheck.sh
How many whole minutes do you want between spin checks?
1

NOTE ABOUT DUTY CYCLE (Fan%0 and Fan%1):
Some boards apparently report incorrect duty cycle, and can
report duty cycle for zone 1 when that zone does not exist.

Key to drive status symbols:  * spinning;  _ standby;  ? unknown							  Version 2018-01-01

Wednesday, Feb 14
		  da0  da1  da2  da3  da4  da5  Tmax Tmean  ERRc CPU  FAN1  FAN2  FAN3  FAN4  FANA Fan%0 Fan%1 MODE
22:42:10  *34  *36  *35  *33  *35  *36  Unable to send RAW command (channel=0x0 netfn=0x30 lun=0x0 cmd=0x70 rsp=0xc1): Invalid command
Unable to send RAW command (channel=0x0 netfn=0x30 lun=0x0 cmd=0x70 rsp=0xc1): Invalid command
Unable to send RAW command (channel=0x0 netfn=0x30 lun=0x0 cmd=0x45 rsp=0xc1): Invalid command
^36  34.83  1.26  64 1200
1000  1200  1200   ---   ---	 0	 0 Standard^C


i'm having four fans with PWM (1CPU + Fans 1-3) and i was able to display their rpm via ipmi tools and my HDs show temperature, too because they are WD red. What else can i do to adapt this script for my needs?

Edit: ipmi tool shows me:
Code:
...
Sensor ID			  : CPU_FAN1 (0xf)
 Entity ID			 : 7.0
 Sensor Type (Threshold)  : Fan
 Sensor Reading		: 1300 (+/- 0) RPM
 Status				: ok
 Lower Non-Recoverable : na
 Lower Critical		: na
 Lower Non-Critical	: 100.000
 Upper Non-Critical	: na
 Upper Critical		: na
 Upper Non-Recoverable : na
 Positive Hysteresis   : Unspecified
 Negative Hysteresis   : Unspecified
 Assertion Events	  :
 Assertions Enabled	: lnc-
 Deassertions Enabled  : lnc-

Sensor ID			  : FRNT_FAN1 (0x11)
 Entity ID			 : 7.0
 Sensor Type (Threshold)  : Fan
 Sensor Reading		: 1000 (+/- 0) RPM
 Status				: ok
 Lower Non-Recoverable : na
 Lower Critical		: na
 Lower Non-Critical	: 100.000
 Upper Non-Critical	: na
 Upper Critical		: na
 Upper Non-Recoverable : na
 Positive Hysteresis   : Unspecified
 Negative Hysteresis   : Unspecified
 Assertion Events	  :
 Assertions Enabled	: lnc-
 Deassertions Enabled  : lnc-

Sensor ID			  : FRNT_FAN2 (0x12)
 Entity ID			 : 7.0
 Sensor Type (Threshold)  : Fan
 Sensor Reading		: 1300 (+/- 0) RPM
 Status				: ok
 Lower Non-Recoverable : na
 Lower Critical		: na
 Lower Non-Critical	: 100.000
 Upper Non-Critical	: na
 Upper Critical		: na
 Upper Non-Recoverable : na
 Positive Hysteresis   : Unspecified
 Negative Hysteresis   : Unspecified
 Assertion Events	  :
 Assertions Enabled	: lnc-
 Deassertions Enabled  : lnc-

Sensor ID			  : FRNT_FAN3 (0x13)
 Entity ID			 : 7.0
 Sensor Type (Threshold)  : Fan
 Sensor Reading		: 1300 (+/- 0) RPM
 Status				: ok
 Lower Non-Recoverable : na
 Lower Critical		: na
 Lower Non-Critical	: 100.000
 Upper Non-Critical	: na
 Upper Critical		: na
 Upper Non-Recoverable : na
 Positive Hysteresis   : Unspecified
 Negative Hysteresis   : Unspecified
 Assertion Events	  :
 Assertions Enabled	: lnc-
 Deassertions Enabled  : lnc-
...
 
Last edited:

Glorious1

Guru
Joined
Nov 23, 2014
Messages
1,172
These scripts are not designed for ASRock boards. Those boards are set up very differently. See this post and the previous few:
https://forums.freenas.org/index.ph...cro-boards-using-pid-logic.51054/#post-353365

I actually like the way ASRock boards are set up fanwise. Each fan header is essentially its own zone and can be controlled independently. It would be interesting to play with that, but I don't have such a board and don't know all the raw commands. If you can get all that info, it should be possible to modify the scripts to work.

(BTW that is the discussion forum for the script you appear to be using, unless it is one @Kevin Horton modified)
 

Makaveli6103

Contributor
Joined
Mar 18, 2012
Messages
104
I have an X9 board and my fan speeds will not change at all when I set the mode. I tried changing the mode in the BIOS, IPMI tool and via raw command but they do not change. Any ideas?
 

Stux

MVP
Joined
Jun 2, 2016
Messages
4,248
I have an X9 board and my fan speeds will not change at all when I set the mode. I tried changing the mode in the BIOS, IPMI tool and via raw command but they do not change. Any ideas?

Do you have 4 pin PWM controllable fans?
Are you running the latest IPMI/BIOS for your board?
 

leonroy

Explorer
Joined
Jun 15, 2012
Messages
77
I have an X9 board and my fan speeds will not change at all when I set the mode. I tried changing the mode in the BIOS, IPMI tool and via raw command but they do not change. Any ideas?

Not all X9 boards support fan control. I believe they need vPro support on the chipset which the C20X series do not. What board do you have?
 

GrumpyBear

Contributor
Joined
Jan 28, 2015
Messages
141
I have the X9SCL+-F which has the C202 chipset
It should work. Try resetting the Baseband Management Controller (BMC) either by using IPMItool or the IPMI LAN interface (safest). You should be able to reset the BMC on the system live without having to shutdown freenas.

In the IPMI web interface or in IPMItools do the sensors report the rpm of the fans and show them connected to the same headers as they are connected to?
 

moelassus

Dabbler
Joined
May 15, 2018
Messages
30
I have an X9 board and my fan speeds will not change at all when I set the mode. I tried changing the mode in the BIOS, IPMI tool and via raw command but they do not change. Any ideas?

I have an X11SSM board that also doesn't respond to fan speed control. They all run at max RPM. Thankfully they are all Noctua fans so they aren't terrible but it would be nice if they could be dialed back a bit. The low noise adapters cut the fan speed too much.

I have the CPU on Fan Header 1 and the other fans plugged into the other available headers. I couldn't find any settings in the BIOS. I am running the latest firmware for the IPMI.

I tried the spin test script but at all duty cycles the fans stay at the same RPMs.
 

Makaveli6103

Contributor
Joined
Mar 18, 2012
Messages
104
It should work. Try resetting the Baseband Management Controller (BMC) either by using IPMItool or the IPMI LAN interface (safest). You should be able to reset the BMC on the system live without having to shutdown freenas.

In the IPMI web interface or in IPMItools do the sensors report the rpm of the fans and show them connected to the same headers as they are connected to?

Yes the web interface shows the fans connected to the same headers and same fan speeds the bios lists. I reset the BMC via the web interface and IPMITool but no go.
 

moelassus

Dabbler
Joined
May 15, 2018
Messages
30
Yes the web interface shows the fans connected to the same headers and same fan speeds the bios lists. I reset the BMC via the web interface and IPMITool but no go.

Interesting. I reset my BMC and now when I change the fans from Full to Standard the fans constantly cycle between their slowest and their fastest. Grrr.
 

GrumpyBear

Contributor
Joined
Jan 28, 2015
Messages
141
Interesting. I reset my BMC and now when I change the fans from Full to Standard the fans constantly cycle between their slowest and their fastest. Grrr.
You need to change the lower non-critical threshold for the fans from whatever it is to something under the minimum rpm of the fan that you have connected. If you have big, slow 120 or 140mm fans try 100
 

GrumpyBear

Contributor
Joined
Jan 28, 2015
Messages
141
Yes the web interface shows the fans connected to the same headers and same fan speeds the bios lists. I reset the BMC via the web interface and IPMITool but no go.
Do changes to the fan mode In The web interface change the fan speeds?

Which mode are you running? Which fan header(s) are the fans connected To?
 

Makaveli6103

Contributor
Joined
Mar 18, 2012
Messages
104
Do changes to the fan mode In The web interface change the fan speeds?

Which mode are you running? Which fan header(s) are the fans connected To?

Weird thing I noticed before is I cannot change my fan mode in the web interface. I can in the IPMI view app but it doesn't do anything to my speeds.


Sent from my iPhone using Tapatalk
 

moelassus

Dabbler
Joined
May 15, 2018
Messages
30
You need to change the lower non-critical threshold for the fans from whatever it is to something under the minimum rpm of the fan that you have connected. If you have big, slow 120 or 140mm fans try 100

I tinkered with the thresholds but the fans continue to cycle. They cycle quicker now. ;)
 

moelassus

Dabbler
Joined
May 15, 2018
Messages
30
I tried running spinpid2.sh but now it wants to reset the BMC each time saying that the fan speed is too high or too low for the duty cycle. I reset the BMC back to factory and I'll mess with it more after I've had a chance to read up on this.
 

Makaveli6103

Contributor
Joined
Mar 18, 2012
Messages
104
It should work. Try resetting the Baseband Management Controller (BMC) either by using IPMItool or the IPMI LAN interface (safest). You should be able to reset the BMC on the system live without having to shutdown freenas.

In the IPMI web interface or in IPMItools do the sensors report the rpm of the fans and show them connected to the same headers as they are connected to?

Yes the web interface shows the fans connected to the same headers and same fan speeds the bios lists. Reset BMC and nothing. Below is sensor readings of my board. You can see it is set to full and I tried to modify the speed but it raw command would not work. Also a photo from the web interface of my fans.

Code:
root@tardis:~ # ipmitool sensor
System Temp	  | 34.000	 | degrees C  | ok	| -9.000	| -7.000	| -5.000	| 80.000	| 85.000	| 90.000
Peripheral Temp  | 31.000	 | degrees C  | ok	| -9.000	| -7.000	| -5.000	| 80.000	| 85.000	| 90.000
CPU Temp		 | 0x0		| discrete   | 0x0000| na		| na		| na		| na		| na		| na
FAN 1			| 600.000	| RPM		| nc	| 300.000   | 450.000   | 600.000   | 18975.000 | 19050.000 | 19125.000
FAN 2			| 825.000	| RPM		| ok	| 300.000   | 450.000   | 600.000   | 18975.000 | 19050.000 | 19125.000
FAN 3			| 1125.000   | RPM		| ok	| 300.000   | 450.000   | 600.000   | 18975.000 | 19050.000 | 19125.000
FAN 4			| 525.000	| RPM		| nc	| 300.000   | 450.000   | 600.000   | 18975.000 | 19050.000 | 19125.000
FAN A			| 600.000	| RPM		| nc	| 300.000   | 450.000   | 600.000   | 18975.000 | 19050.000 | 19125.000
Vcore			| 0.824	  | Volts	  | ok	| 0.480	 | 0.512	 | 0.544	 | 1.488	 | 1.520	 | 1.552
3.3VCC		   | 3.344	  | Volts	  | ok	| 2.816	 | 2.880	 | 2.944	 | 3.584	 | 3.648	 | 3.712
12V			  | 12.137	 | Volts	  | ok	| 10.494	| 10.600	| 10.706	| 13.091	| 13.197	| 13.303
VDIMM			| 1.512	  | Volts	  | ok	| 1.152	 | 1.216	 | 1.280	 | 1.760	 | 1.776	 | 1.792
5VCC			 | 4.992	  | Volts	  | ok	| 4.096	 | 4.320	 | 4.576	 | 5.344	 | 5.600	 | 5.632
-12V			 | -11.322	| Volts	  | ok	| -13.844   | -13.650   | -13.456   | -10.934   | -10.740   | -10.546
VBAT			 | 3.104	  | Volts	  | ok	| 2.816	 | 2.880	 | 2.944	 | 3.584	 | 3.648	 | 3.712
VSB			  | 3.376	  | Volts	  | ok	| 2.816	 | 2.880	 | 2.944	 | 3.584	 | 3.648	 | 3.712
AVCC			 | 3.360	  | Volts	  | ok	| 2.816	 | 2.880	 | 2.944	 | 3.584	 | 3.648	 | 3.712
Chassis Intru	| 0x0		| discrete   | 0x0000| na		| na		| na		| na		| na		| na
root@tardis:~ # ipmitool raw 0x30 0x45 0x00
 01
root@tardis:~ # ipmitool raw 0x30 0x70 0x66 0x01 0x00 0x32
Unable to send RAW command (channel=0x0 netfn=0x30 lun=0x0 cmd=0x70 rsp=0xcc): Invalid data field in request


omnp7wS.jpg
 

Makaveli6103

Contributor
Joined
Mar 18, 2012
Messages
104
Do changes to the fan mode In The web interface change the fan speeds?

Which mode are you running? Which fan header(s) are the fans connected To?

I just found this post on reddit. But this is now giving me the error below.
https://www.reddit.com/r/homelab/comments/8fhomj/getting_those_supermicro_x9_motherboard_fans/

Code:
root@tardis:~ # ipmitool raw 0x30 0x91 0x5A 0x3 0x10 0x7f
Unable to send RAW command (channel=0x0 netfn=0x30 lun=0x0 cmd=0x91 rsp=0x82): Unknown (0x82)
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
7,430
On a bit of a tangent, I have recently spent a bit of time adapting the script together with having the need to develop a method to control the fans in my case (the same Norco 4U chassis used by @Stux), since I'm using a (cheaper... perhaps too cheap) Mobo from ASUS (Z10PA-D8), and they are morons and couldn't see the need to make fan control available with their implementation of the exact same IPMI chip used by supermicro and AsRock, so I went down what felt like a few hundred dead-ends (including a support ticket to ASUS, who asked me what IPMI was and if it was one of their products... trying to drop my request before it even had a fair hearing), looking for FreeBSD fan control methods, scripts, add-on cards/accessories for fan control and modding (all of which have plenty of options and bundled software for Windows and some where there are linux tools, but no BSD)... all ending badly.

I finally found that there's a product range from Corsair which subscribes to the concept of CorsairLink, which has been (at least partially) reverse engineered by the linux community to a project called OpenCorsairLink, which I had seen somebody had ported to MacOS... finally, something to give me some hope. I rushed out and ordered the Commander Pro (one of the products in that range), which has 4 temperature sensors, 6 PWM fan ports, a USB connection to the MoBo (and a hub in case you still need the header for other connections), plus some controls for LED lighting (in case you're one of "those people").

So I got it hooked up on a test system and went about downloading the project and installing it in order to compile and (in my mind at the time) just go ahead and start adapting the script in this thread to initiate fan controls to it instead of ipmitool. I was a little mistaken.

Once I got it to compile in a combination of a jail with the bulk of the gcc compiling tools and the FreeNAS main system itself hacked a bit to have a smaller subset of them (but the crucial libusb and usbhid libraries that wouldn't go in a jail... at least they wouldn't cooperate for me... maybe someone more clever could have done it... or maybe someone more clever would just have done it on a clean FreeBSD system and copied over the binary... more on that later), I ran the executable with the --help switch and had a read, to find that I could mostly make sense of the required commands in order to set and get fan speeds in PWM (%) and RPM. Great! (or so I thought).

I then discovered that I was far from where I wanted to be and on inspection of the source code (wasn't easy as I'm a VB6 guy from way back, not a C programmer, plus the way the files were structured is kind of counter-intuitive, splitting by the device types withing the product range, but also by function and abstraction level... protocol, lowlevel, logic), I could see all the right things there waiting to be run, but I couldn't see where they would be called/run based on the commands I was issuing.

I finally concluded that there were indeed no hooks to make the code run for my scenario, so I rolled up my proverbial sleeves and started to hack my way down into the mess.

After about a thousand tests and re-compiles (this is where I would have been kicking myself to need to copy over a recompiled binary every time to test) interspersed with bashing my head against various walls of different size and hardness, including finding that a lot of the code that was there pre-written for the case I needed was incorrect (by small or even major degrees), so I ended up doing a lot to write/fix it while still not really being 100% sure about what I was doing (having never written in C before, never developed a driver before, working at such low level pushing around bytes directly to hardware and reading results back a byte or two at a time).

To end the story, I managed to get a working file that can control the Commander Pro and its 6 ports, accurately read the temperatures from the 4 sensors, read and set the fan speed in % and read the surrent fan % and RPM in a command that meets the same specs as the output of ipmitool for the RPM.

I have adapted the script (just an if statement in each case where ipmitool is run to direct the commands to my opencorsairlink command instead (a little diversion on a couple of bits as I have the 6 headers and wanted to avoid the cable headache of splitters for the most part (so I use FAN 1 and FAN 2 for the CPU and Exhaust fans (using a splitter each there) and then FAN 3, FAN 4 and FAN 5 for the HD fans, so I benefit from one of Kevin's excellent additions to the script there being able to specify all 3 HD fans for the checks.

I also made a small correction to add single quotes around the fan name in both get_fan_speed and get_fan_speed2, also noting that in get_fan_speed, the call incorrectly passes $fan_name to the ipmi commandline instead of the resolved $fan.

All this to say Thanks to both @Stux and @Kevin Horton for making this available... it works brilliantly.

---- Edit ----

Happy to share any details or answer questions on what I did if it's interesting. (I guess it means this script can be adapted for use in almost any system provided you can buy one of the corsair devices)
 
Last edited:
Top