Joseph Trice-Rolph

Members
  • Posts

    6
  • Joined

  • Last visited

Everything posted by Joseph Trice-Rolph

  1. Have been working on a custom script to manage fan control within my external disk only 24 bay chassis using drive temps within unraid. Didnt like the auto fan control plugin or another custom script I found as using smart reports caused drives to spinup unnecessarily. Additionally as using 3x 3A 120mm server fans both noise and power consumption were issues needing bringing in check. So I have parsed the disks.ini file to check temps reported by UNRAID itself. I wanted to go this route to remove any unnecessary additional scripts/dockers/plugins, just simple check unraid reported temps and adjust fans accordingly. Its a little crude right now but seems to be working, after a few hours of testing. Feel free to offer any comments/suggestions but please be gentle as was my first attempt at bash scripting. Can probably reduce the pwm level steps, would like to implement basic logging and needs bit more testing but its a good start. Few ideas/lines were borrowed from another script I found online but struggling to find right now to credit. #!/bin/bash ##VARIABLES MIN_PWM=40 LOW_PWM=50 HIGH_PWM=180 MAX_PWM=220 LOW_TEMP=25 HIGH_TEMP=35 MAX_TEMP=39 ARRAY_FAN=/sys/class/hwmon/hwmon2/pwm3 ##Disk Types Checked (0 disabled, 1 enabled) declare -A diskTypesChecked diskTypesChecked[Parity]=1 diskTypesChecked[Data]=1 diskTypesChecked[Cache]=0 diskTypesChecked[Flash]=0 ##Excluded Disks (name as in disk.ini) excludedDisks=(nvme,cache,cache2,flash) ##Variables isNumber='^[0-9]+$' ##GET LIST OF ARRAY DISKS declare -a fullDiskList while IFS='= ' read var val do if [[ $var == \[*] ]] then section=${var:2:-2} fullDiskList+=($section) eval declare -A ${section}_data elif [[ $val ]] then eval ${section}_data[$var]=$val fi done < /var/local/emhttp/disks.ini ##filter out excluded disks and disk types declare -a diskList for disk in "${fullDiskList[@]}" do diskName=${disk}_data[name] diskType=${disk}_data[type] diskId=${disk}_data[id] diskTypeChecked=${diskTypesChecked[${!diskType}]} if [[ "${!diskId}" == "" ]] ##ignore unassigned slots then : ##dont check elif [[ "${diskName}" == "${excludedDisks[*]}" ]] ##needs improvement then : ##dont check elif (( ${diskTypeChecked} == 0 )) then : ##dont check else diskList+=($disk) fi done ##CHECK DISKS declare -A diskState declare -A diskTemp maxTempC=0 maxTempDisk=null activeDisks=0 for disk in "${diskList[@]}" do ##check disk state eval thisDiskStateVal=${disk}_data[spundown] if (( ${thisDiskStateVal} == 1 )) then thisDiskState=spundown diskState[${disk}]=spundown else thisDiskState=spunup diskState[${disk}]=spunup activeDisks=$((activeDisks+1)) fi ##check disk temp thisDiskTemp=${disk}_data[temp] if [[ "$thisDiskState" == "spunup" ]] then if [[ "${!thisDiskTemp}" =~ $isNumber ]] then diskTemp[${disk}]=${!thisDiskTemp} if (( "${!thisDiskTemp}" > "$maxTempC" )) then maxTempC=${!thisDiskTemp} maxTempDisk=$disk fi else diskTemp[$disk]=unknown fi else diskTemp[$disk]=na fi done echo Hottest Disk is $maxTempDisk at $maxTempC C ##calculate PWM ##maxTempC=26 ##overide temp for manual control # Linear PWM Logic Variables - do not modify NUM_STEPS=$((HIGH_TEMP - LOW_TEMP - 1)) PWM_INCREMENT=$(( (HIGH_PWM - LOW_PWM) / NUM_STEPS)) if (( $activeDisks == 0 )) then ##all disks spun down echo All drives are idle/spundown, setting fans to minimum. FAN_PWM=$MIN_PWM elif (( $maxTempC <= $LOW_TEMP )) then ##if hottest drive below low echo $maxTempC C is below low temp of $LOW_TEMP C, setting fans to minimum. FAN_PWM=$MIN_PWM elif (( $maxTempC > $LOW_TEMP && $maxTempC <= $HIGH_TEMP )) then ##if hottest drive above low but below high echo $maxTempC C is above low temp of $LOW_TEMP C but below high temp of $HIGH_TEMP C, setting fans to ... FAN_PWM=$(( ((maxTempC - LOW_TEMP - 1) * PWM_INCREMENT) + MIN_PWM )) elif (( $maxTempC > $HIGH_TEMP && $maxTempC <= $MAX_TEMP )) then ##if hottest drive above high but below max echo $maxTempC C is above high temp of $HIGH_TEMP C but below max temp of $MAX_TEMP C, setting fans to ... FAN_PWM=$MAX_PWM elif (( $maxTempC > $MAX_TEMP )) then ##if hottest drive exceeds max temp ##pause parity/alert echo $maxTempC C is above max temp of $MAX_TEMP C, setting fans to full and ... FAN_PWM=255 else ##if all else fails - full power fans echo undefined outcome, setting fans to full and ... FAN_PWM=255 fi echo $FAN_PWM > $ARRAY_FAN echo Fan PWM set to $FAN_PWM #for key in "${!diskList[@]}" #do # echo -n "key : $key, " # echo "value: ${diskList[$key]}" #done # #for key in "${!diskTemp[@]}" #do # echo -n "key : $key, " # echo "value: ${diskTemp[$key]}" #done #param=temperature #echo ${!parity_data[@]} #echo ${!disk2_data[@]} #echo \*
  2. So thought it would be good to share progress. First time writing bash script so probably a little crude. Have gotten as far as pulling array of disks from disks.ini along with an array or parameters for each disk and outputting a list of disks with either their unraid temp or 'spundown'. Open to any advice or amendment suggestions. ##GET LIST OF ARRAY DISKS declare -a diskList while IFS='= ' read var val do if [[ $var == \[*] ]] then section=${var:2:-2} diskList+=($section) eval declare -A ${section}_data elif [[ $val ]] then if [[ $var == "temp" ]] then eval ${section}_data[temperature]=$val fi eval ${section}_data[$var]=$val fi done < /var/local/emhttp/disks.ini ##CHECK DISKS #echo disklist for disk in "${diskList[@]}" do checkedtemp=0 temp=${disk}_data[temperature] if [[ ${!temp} =~ ^[0-9]+$ ]] then checkedtemp=${!temp} else checkedtemp=spundown fi echo $disk - temperature = $checkedtemp done
  3. So not sure if it's system temp or fan control plugin but one of the two gives a fan speed display on dashboard. However fans are just numbered. Found else where to set label in the .conf but this only seems to apply to the driver/drop down in the plugin conf in system temps settings. Anyone know a way to set labels for the fans on dashboard? Will sort some screenshots of reffered dashboard panel if havnt explained well enough.
  4. Managed to pull out the temp param ๐Ÿ™‚ sed -nr "/^\[\"disk2\"\]/ { :l /^temp[ ]*=/ { s/.*=[ ]*//; p; q;}; n; b l;}" /var/local/emhttp/disks.ini Looking very promising and cutting out checking for idle etc as can just pull temp direct from that and a chunk of additional complexity in needing to pull from HDDTemp to work around various SMART formats as have mixed drive models. Thanks again, made my evening ๐Ÿ‘
  5. Thanks for the quick reply, looks like that is what I need. It even has temp listed in main gui ๐Ÿ™‚ so could do away with the hddtemp docker for cleaner and simpler system. Not got any unassigned drives installed at the minute, will have to check if/how they show and work on parsing that as you say.
  6. Hi, First time posting on unraid forum ๐Ÿ™‚, been using unraid now for couple of years and loving it. Setup is a Ryzen 3900x on a X470 board with 64GB RAM with 20+2 3TB drives, querky setup with a cut down 24 hotswap bay case for array drives with dual 8088 links, DSub 5W5 power hookup so both main server and drive case powered from main server PSU and most recently PWM passthrough from main server to array case via serial cable with custom fan header links connecting array case fans to main server chasis fan header in main case. Will sort some pictures if anyone interested in seeing my franken server ๐Ÿ™‚ Anyway.... Working on a custom script for the array chassis fans, hardware wise am all sorted passing PWM signal from main server to the 24 bay drive only chassis. It has 3 high speed 120x38 server fans on the array case and need some temp controlled PWM to reduce both the noice and power consumption by these beast of fans. Making with custom script as autofan seems to use smart data and wake spun down drives so am checking state to only check temp for spun up drives following an example script from online. Need to isolate drives which are part of the array and struggling to find a way to do so, as only want to check array drives, pool/cache drives are in main server. Will be keeping the main array in the second case specifically and would rather not hard code drives as intend to use 23 and 24th bays for a pair of hot spares and would prefer script to just check any drives which are part of the array and dont want to forget to update list if/when these are used or a drive replaced or to mess with a UI update method. Topics in searches I did listed disks in /dev specifying sd* but unassigned and pool drives will be included in this. Closest I think I've seen is referring to the super.dat file however struggling to get the data in a useable format. Unfortunately havn't got much experience with shell/bash. Got most of the rest sorted already sored based around the custom fan control script on another site modified to use HDDTemp docker and hdparam to check idle state to bypass spun down drives to avoid spinning up drives unnecessarily. Hopefully someone might be able to offer a suggestion ๐Ÿ™‚