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)