Displaying SATA hard drive temperatures on Solaris 11 Express.

Coming from FreeNAS I used to pull up the Disk Info page on the WebGUI to conveniently check the hard drive temperatures. I did this mostly out of curiosity at the time, as the drives had a 120mm fan per three drives using a Lian Li HDD cage. I’ve since switched to a 20 bay server case and swapped the tornado fans that came with the case for some silent fans which don’t pull as much air but I also can’t hear them across my 850 Sq. Ft. condo. Since I live in Santa Fe I largely don’t run my air conditioner because the daily highs are rarely above 93° F and condo seems to keep cool from the chilly nights. As such monitoring the temperatures has become a little more important.

As far as I can tell Solaris doesn’t have an easy way to monitor/display HD temperatures. So I wrote a little script to parse the drive names from the zpool status output.

#!/bin/bash

POOL="ZFS"

LIST=`zpool status $POOL | grep -o "c[0-9].*d0"`

foo ()
{
for DRIVE_NAME in $*
do
TEMPerature_C=`pfexec /usr/local/sbin/smartctl -d sat -a /dev/rdsk/$DRIVE_NAME | grep "Temperature_Celsius" | grep -o "\ \ \ \ [0-9][0-9]" | grep -o "[0-9][0-9]"`
TEMP_f=$(echo "scale=2;((9/5) * $TEMPerature_C) + 32" |bc)

echo "/dev/rdsk/$DRIVE_NAME is $TEMPerature_C degrees celsius or $TEMP_f degrees fahrenheit"

done
}

foo $LIST

Perhaps not the most efficient use of grep with so many nests but it does display to readable output:

/dev/rdsk/c0t5000C5002A8B94A2d0 is 37 degrees celsius or 98.60 degrees fahrenheit
/dev/rdsk/c0t5000C50029D920C0d0 is 41 degrees celsius or 105.80 degrees fahrenheit
/dev/rdsk/c0t5000C50029DA7CD1d0 is 41 degrees celsius or 105.80 degrees fahrenheit
/dev/rdsk/c0t5000C50029EE83C4d0 is 38 degrees celsius or 100.40 degrees fahrenheit
/dev/rdsk/c0t5000CCA221DB6854d0 is 42 degrees celsius or 107.60 degrees fahrenheit
/dev/rdsk/c0t5000CCA369D14DEBd0 is 37 degrees celsius or 98.60 degrees fahrenheit
/dev/rdsk/c0t5000CCA369D14E86d0 is 36 degrees celsius or 96.80 degrees fahrenheit
/dev/rdsk/c0t5000C50037F61096d0 is 37 degrees celsius or 98.60 degrees fahrenheit
/dev/rdsk/c0t5000C5002F1F88F3d0 is 34 degrees celsius or 93.20 degrees fahrenheit
/dev/rdsk/c0t5000CCA369D15061d0 is 38 degrees celsius or 100.40 degrees fahrenheit

This does require compiling smartmontools from source.

This entry was posted in How To and tagged , , , , , . Bookmark the permalink.

One Response to Displaying SATA hard drive temperatures on Solaris 11 Express.

  1. Adam Felson says:

    I had to modify the script to make it work on sol11. My drives complained about the ‘-H’ part of the ‘smartctl -a’ command so I reduced its output. Also traded multiple greps for cut -d’ ‘ -f#.
    Final version I’m running is:
    #!/bin/bash

    POOL=”tank”

    LIST=`zpool status $POOL | ggrep -o “c[0-9].*d0″`

    foo ()
    {
    for DRIVE_NAME in $*
    do
    TEMPerature_C=`smartctl -d sat -A /dev/rdsk/$DRIVE_NAME | ggrep “Temperature_Celsius” | cut -d’ ‘ -f10`
    TEMP_f=$(echo “scale=2;((9/5) * $TEMPerature_C) + 32” |bc)

    echo “/dev/rdsk/$DRIVE_NAME is $TEMPerature_C degrees celsius or $TEMP_f degrees fahrenheit”

    done
    }

    foo $LIST

Leave a Reply

Your email address will not be published. Required fields are marked *