Thanks alot for sharing this! I just signed up for this.
I'm not actually using Xpenology but rather Openmediavault and the fans seem to kick in to 100% and then ramp down. Your code helped me figure out how to manage the fans.
For reference to anyone stumbling on this thread and wants to port it to OMV:
1. You need to change where the drives are detected since it's different from DSM. For me it was located in /run/disks
EDIT: These did not exist by default. I've created this directory and just created empty files inside (as root):
mkdir /run/disks
cd /run/disks
touch sda sdb sdc
This far from perfect and if you're a Linux wizard you probably can do something better with regex, e.g. /dev/sd*[a-z]
2. Replace the directory in line 51 (fancontrol.cpp) with the directory containing your drives. For me that was:
const static char * synostoragedir = "/run/disks";
3. Compile fancontrol.cpp and run with sudo.
Tip: You can use a docker gcc image to avoid installing dependencies on OMV/Debian/Ubuntu
Pull the image:
docker pull gcc
Compile fancontrol.cpp (you must be in the same directory)
docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp gcc gcc -o fancontrol fancontrol.cpp
Make sure run with fancontrol with sudo.