IPMI Temperature Script and Crontab in Unraid


Recommended Posts

Hi All,

 

I have a Dell R710, and I found this script (https://github.com/NoLooseEnds/Scripts/blob/master/R710-IPMI-TEMP/R710-IPMITemp.sh) online to automatically control fan speed via IPMI. I was trying to set this up on my server with a custom script. I had a couple of questions regarding this:

 

1) I originally created my own shell script based off the above example in /root of my UNRAID server. The script was working well, but I had to stop the array, and restart the server. When the system rebooted, I noticed that my script stored in the path /root was deleted. This was surprising to me as I had expected the root filesystem to be persistent. Is this not true? If it is, where is a recommended place to store this script?

 

2) I had manually created a crontab entry for the root user to the run the above script periodically. That crontab entry also didn't persist across reboots. I was wondering what's the recommended way (plugin) for doing the crontab entry?

 

Thanks for your help!

Link to comment
5 minutes ago, sibi78 said:

This was surprising to me as I had expected the root filesystem to be persistent. Is this not true? If it is, where is a recommended place to store this script?

Anything not stored in /mnt/diskX (or /mnt/user/) or /boot is not persistent.

 

5 minutes ago, sibi78 said:

I was wondering what's the recommended way (plugin) for doing the crontab entry?

User scripts plugin would be the easiest method

 

Alternatives would be entering the commands in via the "go" file.

Link to comment

@Squid, thanks for the reply, and for the "user scripts" plugin - it's very useful. I've created the same script via the user scripts plugin, and everything works well. I'm looking for a way to capture the output of my script to a log file (preferably in the plugin folder or in /tmp/) to check if everything is running properly. I couldn't find a way when I searched the forum. Could you shed some light into how I'd do this? Thanks!

Link to comment

@Alphahelix, sure. With due credit to the original link (https://github.com/NoLooseEnds/Scripts/blob/master/R710-IPMI-TEMP/R710-IPMITemp.sh ), I made some slight tweaks. Note I can confirm this is working on my dell poweredge R710, your mileage might vary depending on the type of server. It's nothing fancy, but I'm starting out simple to see how it works - I mainly wanted to reduce the fan speeds from ~6K RPM with automatic fan control to something less noisy.

 

The IPMI* variables must be filled with the right values for your server. Hope this helps.

 

# TEMPERATURE
# Change this to the temperature in celcius you are comfortable with.
# If the temperature goes above the set degrees it will send raw IPMI command to enable dynamic fan control
MAXTEMP=33
TEMP_STEP1=28
TEMP_STEP2=30
TEMP_STEP3=32

# 28 -> 20%
# 30 -> 30%
# 32 -> 40%
# 33 -> Automatic control

# 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.
TEMP=$(ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW sdr type temperature |grep Ambient |grep degrees |grep -Po '\d{2}' | tail -1)

echo $TEMP

if [ $TEMP -ge $MAXTEMP ]; then
        echo " $TEMP is > $MAXTEMP. Switching to automatic fan control "
        ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW raw 0x30 0x30 0x01 0x01
elif [ $TEMP -le $TEMP_STEP1 ]; then
        echo " $TEMP is < $TEMP_STEP1. Switching to manual 20% control "
        ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW raw 0x30 0x30 0x01 0x00
        ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW raw 0x30 0x30 0x02 0xff 0x14
elif [ $TEMP -le $TEMP_STEP2 ]; then
        echo " $TEMP is < $TEMP_STEP2. Switching to manual 30% control "
        ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW raw 0x30 0x30 0x01 0x00
        ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW raw 0x30 0x30 0x02 0xff 0x1e
elif [ $TEMP -le $TEMP_STEP3 ]; then
        echo " $TEMP is < $TEMP_STEP3. Switching to manual 40% control "
        ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW raw 0x30 0x30 0x01 0x00
        ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW raw 0x30 0x30 0x02 0xff 0x28
fi
 

Edited by sibi78
Link to comment
  • 5 months later...
On 3/3/2019 at 11:47 PM, sibi78 said:

*snip*

So I'm trying to get this working on my server and I'm having a few issues.

 

#!/bin/bash
# TEMPERATURE
# Change this to the temperature in celcius you are comfortable with.
# If the temperature goes above the set degrees it will send raw IPMI command to enable dynamic fan control
MAXTEMP=33
TEMP_STEP1=28
TEMP_STEP2=30
TEMP_STEP3=32
IPMIHOST=192.168.1.120
IPMIUSER=myUserName
IPMIPW=myPassword

# 28 -> 20%
# 30 -> 30%
# 32 -> 40%
# 33 -> Automatic control

# 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.
TEMP=$(ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW sdr type temperature |grep Ambient |grep degrees |grep -Po '\d{2}' | tail -1)

echo $TEMP

if [ $TEMP -ge $MAXTEMP ]; then
        echo " $TEMP is > $MAXTEMP. Switching to automatic fan control "
        ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW raw 0x30 0x30 0x01 0x01
elif [ $TEMP -le $TEMP_STEP1 ]; then
        echo " $TEMP is < $TEMP_STEP1. Switching to manual 20% control "
        ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW raw 0x30 0x30 0x01 0x00
        ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW raw 0x30 0x30 0x02 0xff 0x14
elif [ $TEMP -le $TEMP_STEP2 ]; then
        echo " $TEMP is < $TEMP_STEP2. Switching to manual 30% control "
        ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW raw 0x30 0x30 0x01 0x00
        ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW raw 0x30 0x30 0x02 0xff 0x1e
elif [ $TEMP -le $TEMP_STEP3 ]; then
        echo " $TEMP is < $TEMP_STEP3. Switching to manual 40% control "
        ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW raw 0x30 0x30 0x01 0x00
        ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW raw 0x30 0x30 0x02 0xff 0x28
fi

I've added variables for IP address, username, and pwd. 

 

When I run the script I get the following:

 

Script location: /tmp/user.scripts/tmpScripts/IPMI_Fan_Control/script
Note that closing this window will abort the execution of this script
/tmp/user.scripts/tmpScripts/IPMI_Fan_Control/script: line 20: ipmitool: command not found

/tmp/user.scripts/tmpScripts/IPMI_Fan_Control/script: line 24: [: -ge: unary operator expected
/tmp/user.scripts/tmpScripts/IPMI_Fan_Control/script: line 27: [: -le: unary operator expected
/tmp/user.scripts/tmpScripts/IPMI_Fan_Control/script: line 31: [: -le: unary operator expected
/tmp/user.scripts/tmpScripts/IPMI_Fan_Control/script: line 35: [: -le: unary operator expected

I found this plugin for IMPI and installed it. It says in the post that IPMI Tool is no longer included in the plugin, but when I go to install the package it throws a bunch of errors at me.

 

 

 

Is there something I am missing/not understanding? I'm trying to increase the WAF of my server in our apartment and it's not going too well haha.

 

EDIT

 

So I had a brain wave and decided to check NerdTools, and there it was!

 

Now I get this error:

 

Script location: /tmp/user.scripts/tmpScripts/IPMI_Fan_Control/script
Note that closing this window will abort the execution of this script
27
27 is < 28. Switching to manual 20% control 

Unable to send RAW command (channel=0x0 netfn=0x30 lun=0x0 cmd=0x30 rsp=0xcc): Invalid data field in request

Any suggestions? 

 

EDIT2

 

Turns out that is a normal message! It works!!

 

Now for another nooby question: How often do I need to run this?

Edited by TheScrantonStrangler
Link to comment
  • 7 months later...

Not sure how often to run this. If you expect to be maxing out your server; quite often (30sec-1min). I am going to run mine every 5 min and see how it goes.

 

Also if you are the following issue. enable the following on iDRAC (R710/R510 for me) in iDRAC settings > Network/Security > IPMI Settings > Enable IPMI Over LAN

Error: Unable to establish IPMI v2 / RMCP+ session

 

Link to comment
  • 2 years later...

Hi

I'm trying to run the script via CA User Scripts.

I have checked and I have Enable IPMI Over Lan activated (DELL R515).

I have installed Nerd Tools and IPMI.

If I go to the terminal I can execute all the IPMI commands and control the fans speed.

If I try to execute the script via CA User Scripts, it doesn't work, returning

 

Error: Unable to establish IPMI v2 / RMCP+ session

/tmp/user.scripts/tmpScripts/fan_ipmi_control/script: line 26: [: -ge: unary operator expected
/tmp/user.scripts/tmpScripts/fan_ipmi_control/script: line 29: [: -le: unary operator expected
/tmp/user.scripts/tmpScripts/fan_ipmi_control/script: line 33: [: -le: unary operator expected
/tmp/user.scripts/tmpScripts/fan_ipmi_control/script: line 37: [: -le: unary operator expected
Script Finished Jun 06, 2022 15:38.21

 

Any Idea?

Link to comment
  • 8 months later...

bpalhares

 

 run (ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW sensor list |grep Temp) to get the list of what your temp sensors are called and replace "Ambient" with whatever sensor you want to run your script off of. then set a cron job for how often you want the script to run. this is set schedule to custom and in the bar that pops up put in the code of numbers need ( this may help https://www.hostinger.com/tutorials/cron-job ).

Link to comment
  • 5 months later...

i am using this script and it works but in my dell r720 both cpus just come up as "temp" and the script is grabbing the lower of the 2 "temp" sensors. is there an edit to take the highest of the 2 sensors "temp"? sorry I've tried looking around and a few edits but cant figure it out any help would really be appreciated, thank you.

Link to comment

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.