Skip to content

Instantly share code, notes, and snippets.

@sigxcpu76
Created January 11, 2016 16:41
Show Gist options
  • Save sigxcpu76/b4cb66c2fd0cbf6ec227 to your computer and use it in GitHub Desktop.
Save sigxcpu76/b4cb66c2fd0cbf6ec227 to your computer and use it in GitHub Desktop.
#!/usr/bin/bash
if [ "s$1" != "s-H" ]; then
printf "%-22s %-22s %-22s %5s %5s C\n" DISK MODEL SERIAL SIZE TEMP
fi
for i in $(/usr/bin/ls /dev/rdsk | /usr/bin/awk "/s2$/ {print}" | /usr/bin/sed "s/s2//"); do
disk=/dev/rdsk/${i}p0
temp=$(smartctl -d sat,12 -l scttempsts $disk | grep Current | awk '{print $3}')
#model=$(smartctl -d sat,12 -i $disk | grep "Device Model" | awk '{print $3}')
model=$(smartctl -d sat,12 -i $disk | grep "Device Model" | cut -f2 --delimiter=":" | sed -e 's/^[[:space:]]*//' | tr -dc '[:print:]')
serial=$(smartctl -d sat,12 -i $disk | grep "Serial Number" | cut -f2 --delimiter=":" | sed -e 's/^[[:space:]]*//' | tr -dc '[:print:]')
size=$(sysinfo -p | grep $i | cut -f2 --delimiter="==")
if [ -z $temp ]; then
temp="0"
fi
printf "%-22s %-22s %-22s %5s %5s C\n" $i "$model" "$serial" $size $temp
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment