March 31, 20251 yr I just wanted to share this since it's helped me and I thought others might find it useful. This script checks for when parity check is running and automatically sets the fan speed to 60% then automatically reverts back to automatic control when parity check ends. You can set the speed to whatever you want I just find 60% works well for my specific circumstances. This was made with chatgpt so please excuse if there is a better way of doing this, I'd appreciate any feedback if it could be improved. #!/bin/bash # Configuration IPMI_USER="enter username" # IPMI username IPMI_PASS='enter password' # IPMI password IPMI_IP="enter ip of server" # IPMI IP address FAN_SPEED=60 # Desired fan speed percentage (60%), only used to display fan speed % CHECK_INTERVAL=60 # Time (in seconds) between checks LOG_FILE="/mnt/user/appdata/scripts/fan_control.log" # Commands to enable manual fan control, set fan speed, and revert to automatic ENABLE_MANUAL_FAN_CMD="ipmitool -I lanplus -H $IPMI_IP -U $IPMI_USER -P $IPMI_PASS raw 0x30 0x30 0x01 0x00" SET_FAN_SPEED_CMD="ipmitool -I lanplus -H $IPMI_IP -U $IPMI_USER -P $IPMI_PASS raw 0x30 0x30 0x02 0xff 0x3C" SET_AUTO_FAN_CMD="ipmitool -I lanplus -H $IPMI_IP -U $IPMI_USER -P $IPMI_PASS raw 0x30 0x30 0x01 0x01" # Function to log events with a timestamp log_event() { echo "$(date '+%Y-%m-%d %H:%M:%S') - $1" >> $LOG_FILE } # Function to check if a parity check is running based on mdResync is_parity_check_running() { mdResync=$(mdcmd status | grep -oP 'mdResync=\K[0-9]+') if [[ "$mdResync" -gt 0 ]]; then return 0 # Parity check is running else return 1 # Parity check is not running fi } # Main script loop log_event "Starting IPMI Fan Control Script for Parity Check..." FAN_SPEED_SET=false MANUAL_CONTROL_ENABLED=false while true; do if is_parity_check_running; then # If a parity check is running if [ "$FAN_SPEED_SET" = false ]; then # Enable manual fan control only once when parity check starts if [ "$MANUAL_CONTROL_ENABLED" = false ]; then log_event "Enabling manual fan control..." eval $ENABLE_MANUAL_FAN_CMD MANUAL_CONTROL_ENABLED=true fi # Set fan speed to 60% once when parity check starts log_event "Parity check detected. Setting fan speed to ${FAN_SPEED}%. " eval $SET_FAN_SPEED_CMD FAN_SPEED_SET=true fi else # If no parity check is running if [ "$FAN_SPEED_SET" = true ]; then # Revert to automatic fan control after parity check completes log_event "Parity check completed. Reverting fan control to automatic." eval $SET_AUTO_FAN_CMD FAN_SPEED_SET=false MANUAL_CONTROL_ENABLED=false fi fi sleep $CHECK_INTERVAL done Edited March 31, 20251 yr by Android_18
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.