Skip to content

Instantly share code, notes, and snippets.

@BjornRuud
Created March 17, 2020 14:49
Show Gist options
  • Save BjornRuud/688ed6cbcaf5de86df5583864077184e to your computer and use it in GitHub Desktop.
Save BjornRuud/688ed6cbcaf5de86df5583864077184e to your computer and use it in GitHub Desktop.
View CPU and HDD temperatures on FreeBSD
#!/bin/sh
# Write some general information
echo System Temperatures - `date`
uptime | awk '{ print "\nSystem Load:",$10,$11,$12,"\n" }'
# Write CPU temperatures
echo "CPU Temperature:"
sysctl -a | egrep -E "cpu\.[0-9]+\.temp"
# Write HDD temperatures and status
echo "HDD Temperature:"
for i in $(sysctl -n kern.disks | awk '{for (i=NF; i!=0 ; i--) if(match($i, '/ada/')) print $i }' ) ; do
echo $i: `smartctl -a -n standby /dev/$i | awk '/Temperature_Celsius/{DevTemp=$10;} /Serial Number:/{DevSerNum=$3}; /Device Model:/{DevVendor=$3; DevName=$4} END {printf "%s C - %s %s (%s)", DevTemp,DevVendor,DevName,DevSerNum }'`;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment