Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # ----------------------------------------------------------------------------------
- # Script for checking the temperature reported by the ambient temperature sensor,
- # and if deemed too high send the raw IPMI command to enable dynamic fan control.
- #
- # This script was designed around the X11sat-f motherboard and having a nonPWM CPU fan
- #
- # Requires:
- # ipmitool: apt-get install ipmitool
- # slacktee.sh: https://github.com/course-hero/slacktee
- #https://gist.github.com/kidpixo/04d61b42221f6bc8489b
- #https://forums.servethehome.com/index.php?resources/supermicro-x9-x10-x11-fan-speed-control.20/
- # ----------------------------------------------------------------------------------
- ### VARIABLES FOR USER TO SET ###
- # unRAID drives that are in the array/backplane of the fan we need to control
- HD[1]=/dev/sdb
- HD[2]=/dev/sdc
- HD[3]=/dev/sdd
- HD[4]=/dev/sde
- HD[5]=/dev/sdf
- HD[6]=/dev/sdg
- HD[7]=/dev/sdh
- HD[8]=/dev/sdi
- HD[9]=/dev/sdj
- HD[10]=/dev/sdk
- HD[11]=/dev/sdl
- HD[12]=/dev/sdm
- HD[13]=/dev/sdn
- HD[14]=/dev/sdo
- HD[15]=/dev/sdp
- HD[16]=/dev/sdq
- #HD[17]=/dev/sdr
- #HD[18]=/dev/sds
- #HD[19]=/dev/sdt
- #HD[20]=/dev/sdu
- #HD[21]=/dev/sdv
- #HD[22]=/dev/sdw
- #HD[23]=/dev/sdx
- #HD[24]=/dev/sdy
- # Temperatures to change fan speed at
- # Any temp between OFF and HIGH will cause fan to run in a mapped value between idle and high speed
- TEMP_IDLE=28 # Anything between this number and below - fan is at idle speed
- TEMP_HIGH=40 # Anything above this number - fan is at alert speed
- # Fan speed settings. For my board its a value between 0x00 and 0x64 (0% to 100%)
- FAN_OFF=0
- FAN_IDLE=8
- FAN_HIGH=20
- FAN_ALERT=50
- ### END USER SET VARIABLES ###
- # Do not modify anything below
- # Init Program variables
- NUM_OF_DRIVES=${#HD[@]}
- TEMP_HIGHEST=0
- CURRENT_DRIVE=1
- TEMP_CURRENT=0
- # while loop to get the highest temperature of active drives.
- # If all are spun down then high temp will be set to 0.
- while [ "$CURRENT_DRIVE" -le "$NUM_OF_DRIVES" ]
- do
- #echo "Loop of: "${HD[$CURRENT_DRIVE]}
- SLEEPING=`hdparm -C ${HD[$CURRENT_DRIVE]} | grep -c standby`
- #echo $SLEEPING
- if [[ $SLEEPING -eq 0 ]]
- then
- TEMP_CURRENT=`smartctl -A ${HD[$CURRENT_DRIVE]} | grep Temperature_Celsius | awk '{print $10}'`
- if [ $TEMP_HIGHEST -le $TEMP_CURRENT ]; then
- TEMP_HIGHEST=$TEMP_CURRENT
- fi
- fi
- #echo $TEMP_CURRENT
- let "CURRENT_DRIVE+=1"
- done
- echo "Highest temp is: "$TEMP_HIGHEST
- # Set the PWM through IPMI
- INTERPOL_RANGE=$(($TEMP_HIGHEST-$TEMP_IDLE))
- if [ $TEMP_HIGHEST -gt $TEMP_HIGH ]
- then
- FAN_SPEED=$FAN_ALERT
- elif [ $INTERPOL_RANGE -gt 0 ]
- then
- FAN_SPEED=$((((($TEMP_HIGHEST - $TEMP_IDLE) * ($FAN_HIGH - $FAN_IDLE)) / ($TEMP_HIGH - $TEMP_IDLE)) + $FAN_IDLE))
- else
- FAN_SPEED=$FAN_IDLE
- fi
- #echo "Setting fan speed to: "$FAN_SPEED
- if [ $FAN_SPEED -lt 10 ]
- then
- COMMANDSTR="ipmitool raw 0x30 0x70 0x66 0x01 0x00 0x0"$FAN_SPEED
- else
- COMMANDSTR="ipmitool raw 0x30 0x70 0x66 0x01 0x00 0x"$FAN_SPEED
- fi
- echo "Running command: "$COMMANDSTR
- `$COMMANDSTR`
Advertisement
Add Comment
Please, Sign In to add comment