FreeNAS CPU core and disk temperature check script

This is a nice simple script to display CPU core and disk temperatures on a FreeNAS server. Tested with FreeNAS 9.10.2-U1

Create a file with the following content – Mine is just called “temps_check_script.sh” as an example.


# 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, '/da/')) 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

Run it with ./temps_check_script.sh – The output looks like this:

System Temperatures - Wed Jun 21 07:53:16 AEST 2017

System Load: 0.17

CPU Temperature:
dev.cpu.3.temperature: 40.0C
dev.cpu.2.temperature: 44.0C
dev.cpu.1.temperature: 40.0C
dev.cpu.0.temperature: 42.0C

HDD Temperature:
ada0: 27 C - Hitachi HDS5C3020ALA632 (SERIALNUMBERGOESHERE)
ada1: 27 C - Hitachi HDS5C3020ALA632 (SERIALNUMBERGOESHERE)
ada2: 27 C - Hitachi HDS5C3020ALA632 (SERIALNUMBERGOESHERE)
ada3: 28 C - Hitachi HDS5C3020ALA632 (SERIALNUMBERGOESHERE)
ada4: 28 C - Hitachi HDS5C3020ALA632 (SERIALNUMBERGOESHERE)
ada5: 27 C - Hitachi HDS5C3020ALA632 (SERIALNUMBERGOESHERE)
da0: 32 C - TOSHIBA MD04ACA400 (SERIALNUMBERGOESHERE)
da1: 31 C - TOSHIBA MD04ACA400 (SERIALNUMBERGOESHERE)
da2: 29 C - TOSHIBA MD04ACA400 (SERIALNUMBERGOESHERE)
da3: 30 C - TOSHIBA MD04ACA400 (SERIALNUMBERGOESHERE)
da4: 31 C - TOSHIBA MD04ACA400 (SERIALNUMBERGOESHERE)
da5: 30 C - TOSHIBA MD04ACA400 (SERIALNUMBERGOESHERE

Running fsck via Leaseweb FreeBSD Rescue 2.1 on UFS partitions

I’ve been running a FreeBSD 10 based dedicated server with Leaseweb NL for a little over a year now. This morning I noticed the server was down.

Unfortunately Leaseweb don’t seem to provide any KVM style access, or in any case I don’t have that functionality with this server from them. I rebooted the server via the Leaseweb panel, without any success. My suspicion was that the filesystem might be dirty, and FreeBSD was stuck on a screen waiting for fsck to be launched.

Using Leaseweb’s panel I booted into their “FreeBSD Rescue 2.1”. I tried to run fsck across my partitions, however I would constantly get the error:
fsck: Could not determine filesystem type

For this particular server I am still using UFS rather than ZFS. It turns out you have to define the type in the fsck command.

In the end I did the following:
ls /dev/ad* #to list out all partitions
fsck -y -t ufs /dev/ad3s1 #ran this same command across every partition

It was the /usr partition that was marked as “dirty”. After running the above fsck command across it, I rebooted the server and everything came back as normal.