How will we achieve this?
In Proxmox, we will create a cron job that will run a script to check the current servers ambient temperature and set the fan speeds accordingly. The script will need to use two main components to achieve this:
- ipmitool for Debian (Proxmox) to use use ipmi protocols in the cli.
- A iDRAC user account that the script will use to access the iDRAC.
- Dells iDRAC (iDRAC 6 on the Dell R710) to get the servers ambient temperature and to set the fan speeds.
Just as a side note, I have created a “Management” (10.0.0.0/24) network were things such as the iDRAC and other other management related software / devices are connected to. Having a separate and tightly locked down network where all the IT infrastructure is managed is very important.
I will do a write up on my network design in a future post, but for now I wanted to get this post out to help people silence their server and also help save some electricity in the process.
Set your iDRAC LAN Settings and main admin user
In order for us to access the iDRAC web portal, we will need to give the iDRAC NIC an IP address and create the main “Admin” user we can use to login and administrate the server.
make sure to have your iDRAC NIC connected to your desired network
- To get to the iDRAC bios / settings Turn on your server and press the “CTRL + E” key on your keyboard when you see the following message:
"Press CTRL + E for Remote Access Setup within 5 sec"
- Make sure the that the
iDRAC6 LAN
andIPMI Over LAN
options are set toon
- Next goto the
LAN Parameters
section, navigate down until you get to theIPv4 Settings
section and fill in your desired IP details.
- Lastly, go to the
LAN User Configuration
to create the main user you will use to access iDRAC and administrate your server.
- Make sure to set the
IPMI LAN Privilege
toAdmin
, set theAccount Access
toEnabled
and set the user name and password you would like to use.
- press
ESC
to exit and save your changes.
Create a new iDRAC user for our script
We don’t want to use our main Administrator account for this as having those details in plain text in a script is very dangerous. We will instead create a new user that we will give permissions to use the IPMI.
- Login to your iDRAC web portal entering your iDRAC IP address in your browser, mine is as follows: https://10.0.0.4/login.html
-
Login using the user details that you created in the previous section.
-
Once logged in. In the menu on the left side. Open the
iDRAC Settings
section
- Now open the
Network/Security
sub menu.
- Now select the
users
section
- click on a free “User ID” number.
- Select the “Configure User” radio button, and click “Next”.
-
Set the following settings:
The
Enable User
check box should be ticked. Enter a username. Enter a password. A max of twenty alpha-numeric password is needed. SetMaximum LAN User Privilege Granted
toAdministrator
. TheEnable Serial Over LAN
check box should be ticked. Everything else should be default, which will effectively be no permissions.
- Scroll to the bottom of the page and click “Apply” to create the new user.
IPMI Encryption
Under the Network
section of the iDRAC Settings
. You are able to set a 40 character hex value that will be used for encrypting your connections. For this guide I will leave it all as “0”.
Install IPMI Tools on Proxmox
I will now login to my host operating system (Proxmox) in my case. I will login to the Proxmox web interface and use the built in shell / terminal. You can use SSH if you prefer that.
-
Do a repository update and then install ipmitools using the following:
sudo apt update && sudo apt install ipmitool
if you are already a root user you can just run the following command:
apt update && apt install ipmitool
- We can test if it is working by running the following command:
ipmitool -I lanplus -H <ip> -U <user> -P <pass> -y <enc> sdr type temperature
Make sure to replace the following with your details: = your iDRAC IP = the user you created in the previous section = the users password = your encryption string
So in my case it will be as follows:
ipmitool -I lanplus -H 10.0.0.4 -U fan-admin -P asd123asd -y 0000000000000000000000000000000000000000 sdr type temperature
If everything is correct, you will get a table with some temperature values.
The script
-
I will create a new folder in the
root
users home folder where I will store the script.mkdir fancontrol
-
I will then use
nano
to create a file calledsetspeed.sh
nano setspeed.sh
The below script is a modified version of the script found here https://github.com/NoLooseEnds/Scripts/tree/master/R710-IPMI-TEMP
The original script was split into two files which I found was unnecessary and got confusing to edit. So I merged them into one file to be easier to maintain.
I also added a FANSPEED
variable to make it easier to set the fan speed by utilisation percentage as the original script did not have that function.
- Copy and paste the below script into nano
#!/bin/bash
# IPMI IP address
IPMIHOST=10.0.0.4
# IPMI Username
IPMIUSER=fan-admin
# IPMI Password
IPMIPW=y0urPassw0rd
# Your IPMI Encryption Key
IPMIEK=0000000000000000000000000000000000000000
# Fan Speed / utilisation in percentage, for example 9 for 9% utilisation
# Please note that each fan can have a different rpm and will not all be the same speed
FANSPEED=9
# TEMPERATURE
# Change this to the temperature in Celsius you are comfortable with.
# If the temperature goes above the set degrees it will send raw IPMI command to enable dynamic fan control
MAXTEMP=27
# This variable sends a IPMI command to get the temperature, and outputs it as two digits.
# Do not edit unless you know what you do.
# Side note, if you are running ipmitool on the system you are controlling, you don't need to specify -H,-U,-P - from the OS installed on the host, ipmitool is assumed permitted. You only need host/user/pass for remote access.
TEMP=$(ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW -y $IPMIEK sdr type temperature |grep Ambient |grep degrees |grep -Po '\d{2}' | tail -1)
# Dont edit this, this converts decimal to hex
SPEEDHEX=$( printf "%x" $FANSPEED )
if [[ $TEMP > $MAXTEMP ]];
then
printf "Warning: Temperature is too high! Activating dynamic fan control! ($TEMP C)" | systemd-cat -t R710-IPMI-TEMP
echo "Warning: Temperature is too high! Activating dynamic fan control! ($TEMP C)"
# This sets the fans to auto mode, so the motherboard will set it to a speed that it will need do cool the server down
ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW -y $IPMIEK raw 0x30 0x30 0x01 0x01
else
printf "Temperature is OK ($TEMP C)" | systemd-cat -t R710-IPMI-TEMP
printf "Activating manual fan speeds! (1560 RPM)"
# This sets the fans to manual mode
ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW -y $IPMIEK raw 0x30 0x30 0x01 0x00
# This is where we set the slower, quiet speed
ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW -y $IPMIEK raw 0x30 0x30 0x02 0xff 0x$SPEEDHEX
fi
-
press
ctrl + x
to close nano, then pressY
to save your changes. -
We then need to give the file executable permissions
chmod +x setspeed.sh
- You can test your script to make sure it is working, set a speed in the script and run it.
./setspeed.sh
In your iDRAC web portal, under the fans
section, you can see the current rpm of each fan.
So at 9 percent speed my fans run at around 2040 rpm.
And at 50 percent speed my fans run at around 7320 rpm.
Create a cron job
Next we need to create a cron job that Proxmox will run on startup and every minute (in this case) you can change how often the job runs. That is up to you.
- Open crontab
crontab -e
- Add the following line to the end of the file
*/1 * * * * /bin/bash /root/fancontrol/setspeed.sh > /dev/null 2>&1
- You can then exit and save the file. Then in Proxmox, if we look at the syslog, we will see that in a minutes time, the cron job will execute.
Conclusion
You will now have a script that will run every minute, check on the servers ambient temperature and then set the fan speeds accordingly.