--- spinpid.txt 2016-08-16 22:05:34.000000000 +1000 +++ spinpid-cj.txt 2016-08-16 22:16:29.022212356 +1000 @@ -1,5 +1,6 @@ #!/usr/local/bin/bash # spinpid.sh version 2016-07-02. Run as superuser. See notes at end. +# Patch by @Mr Snow from the FreeNAS forums on 2016-08-16 ############################################## # Get disk name from current LINE of DEVLIST @@ -44,7 +45,8 @@ # Read duty cycle, convert to decimal. # May need to disable these 3 lines as some boards apparently return # incorrect data. In that case just assume $DUTY hasn't changed. - DUTY=$(/usr/local/bin/ipmitool raw 0x30 0x70 0x66 0 0) # in hex + # DUTY=$(/usr/local/bin/ipmitool raw 0x30 0x70 0x66 0 0) # in hex - region 0 (CPU/System) + DUTY=$(/usr/local/bin/ipmitool raw 0x30 0x70 0x66 0 1) # in hex - region 1 (peripherals) DUTY=$(printf "0x%s" $DUTY) # add Ox in front DUTY=`echo $(($DUTY))` # convert to decimal # Read fan mode, convert to decimal. @@ -61,7 +63,8 @@ # Get reported fan speed in RPM. # Takes the line with FAN1, then 2nd through the 5th # digit if there are that many. - RPM=$(/usr/local/bin/ipmitool sdr | grep "FAN1" | grep -Eo '[0-9]{2,5}') + # RPM=$(/usr/local/bin/ipmitool sdr | grep "FAN1" | grep -Eo '[0-9]{2,5}') # FAN1-x are region 0 fans + RPM=$(/usr/local/bin/ipmitool sdr | grep "FANA" | grep -Eo '[0-9]{2,5}') # FANA is region 1 fan header # print current Tmax, speed, mode, and duty printf "^%-3d %5.2f %4d %-8s %2d/" $Tmax $Tmean $RPM $MODEt $DUTY } @@ -85,7 +88,8 @@ # Uncomment for troubleshooting or just more info: printf " ERRc=%6.2f P=%6.2f I=%5.2f D=%6.2f" $ERRc $P $I $D # Set new duty cycle. This inserts a newline ending the log line - /usr/local/bin/ipmitool raw 0x30 0x70 0x66 1 0 $DUTYhex + # /usr/local/bin/ipmitool raw 0x30 0x70 0x66 1 0 $DUTYhex # sets Duty cycle for region 0 + /usr/local/bin/ipmitool raw 0x30 0x70 0x66 1 1 $DUTYhex # sets Duty cycle for region 1 } ########################################### @@ -93,11 +97,11 @@ ########################################### # Settings: SP=33.57 # Setpoint mean temperature -T=5 # Time interval in minutes +T=5 # Time interval in minutes Kp=4 # Proportional tunable constant Ki=0 # Integral tunable constant Kd=40 # Derivative tunable constant -LOG=/mnt/Ark/Jim/spinpid.log +LOG=/mnt/tank/.scripts/spinpid.log # Creates logfile and sends all stdout and stderr to the log, leaving the previous contents in place. # If you want to append to existing log, add '-a' to the tee command. @@ -113,11 +117,12 @@ DEVLIST="$(echo "$DEVLIST1"|sed '/KINGSTON/d;/ADATA/d;/SanDisk/d')" # Set mode to 'Full' to avoid BMC changing duty cycle # Need to wait a tick or it doesn't get 2nd command -/usr/local/bin/ipmitool raw 0x30 0x45 1 1; sleep 1 +# /usr/local/bin/ipmitool raw 0x30 0x45 1 1; sleep 1 # uncomment this line if you are using region 0 # Then start with 50% duty cycle DUTY=50 DUTYhex=$( printf "0x%x" $DUTY ) -/usr/local/bin/ipmitool raw 0x30 0x70 0x66 1 0 $DUTYhex +# /usr/local/bin/ipmitool raw 0x30 0x70 0x66 1 0 $DUTYhex # sets duty cycle for region 0 +/usr/local/bin/ipmitool raw 0x30 0x70 0x66 1 1 $DUTYhex # sets duty cycle for region 1 print_header @@ -161,7 +166,7 @@ # Adjusts fan with PID control to maintain mean drive temp near set point # Logs: -# - disk status (spinning or standby) +# - disk status (spinning or standby) # - disk temperature (Celsius) if spinning # - max and mean disk temperature # - fan rpm and mode