Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

BASH script to inventory UNRAID drives for including in other scripts

Featured Replies

I created a bash script that will loop over the "Tools > Vars" UNRAID web page and build an array list of every drive assigned to UNRAID. You are welcome to use/modify this code as you see fit as long as the credit given at top is included.

 

Parity drives will be listed first, followed by diskx assignments, followed by cache drive(s).

 

# Get a list of UNRAID variables which contains drive information
# Base code by John Bartlett (Support @ Lime-Tech: http://goo.gl/k533BE)
wget --quiet --output-document=/tmp/diskspeedvars.txt http://localhost/Tools/Vars
# Init variables
FoundArray=0
InDiskInfo=0
EndScan=0
i=-1
# List of drive attributes to extract, pipe delimited with leading & trailing pipe
# Array variables will be named "Disk_[attrib]" - for example, "Disk_name" and "Disk_id"
# Remove/Add attributes you want, "device" is required below
Attribs="|id|idx|device|name|size|status|temp|numReads|numWrites|numErrors|format|type|fsSize|fsFree|"

# Loop over the Vars HTML
while read line
do
# Check to see if we're past the drive section
if [[ ${line:0:9} == "[display]" ]]; then
	EndScan=1
fi
if [[ $EndScan == 0 ]]; then
	# Check to see if we've found the start of the drive information
	if [[ $FoundArray -eq 0 ]]; then
		if [[ $line == "[disks] => Array" ]]; then
			FoundArray=1
		fi
	else
		# Check to see if we're at the start of a new drive
		if [[ $InDiskInfo -eq 0 ]]; then
			IsParity2=0
			if [[ ${line:0:7} == "[parity" ]] || [[ ${line:0:5} == "[disk" ]] || [[ ${line:0:6} == "[cache" ]]; then
				InDiskInfo=1
				let i++
			fi
			if [[ ${line:0:7} == "[disk1]" ]]; then
				i=2
			fi
			if [[ ${line:0:9} == "[parity2]" ]]; then
				IsParity2=1
			fi
		fi
		# Check to see if we're at the end of a drive's information
		if [[ $InDiskInfo -eq 1 ]] && [[ $line == ")" ]]; then
			InDiskInfo=0
		fi
		# If we're in the middle of a drive's information, log the data
		if [[ $InDiskInfo -eq 1 ]]; then
			tmp=($line)
			CurrVar=${tmp[0]//[\[\]]/}
			CurrVal=${tmp[2]}
			# If temp attribute, check for strange length and override if the temp is reported as "*" and bash evalutes it strange
			if [[ $CurrVar == "temp" ]] && [[ ${#CurrVal} -gt 3 ]]; then
				CurrVal="N/A"
			fi
			if [[ $Attribs =~ "|$CurrVar|" ]]; then
				if [[ $IsParity2 -eq 0 ]]; then
					eval "tmpDisk_$CurrVar[i]=$CurrVal"
				else
					eval "tmpDisk_$CurrVar[1]=$CurrVal"
				fi
			fi
		fi
	fi
fi
done < /tmp/diskspeedvars.txt
rm /tmp/diskspeedvars.txt

# Rebuild Arrays to remove empty drive assignments
AttribArray=(${Attribs//|/ })
q=-1
for (( d=0; d <= $i; d++ ))
do
if [[ ${tmpDisk_device[d]} != "" ]]; then
	let q++
	for f in "${AttribArray[@]}"
	do
		eval "Disk_$f[$q]=\${tmpDisk_$f[$d]}"
	done
fi
done

UNRAIDDrives=$q

# Example report
for (( d=0; d <= $UNRAIDDrives; d++ ))
do
echo "${Disk_name[d]} (${Disk_device[d]}) ${Disk_id[d]}  Temp: ${Disk_temp[d]}"
done

Archived

This topic is now archived and is closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.