Temperature monitoring with hourly reports to a CSV file.

I hacked this script together for an old good friend of mine. Recently one of his NAS drives bit the dust and among many of the paranoid questions I inquired was “Do you know the recent temperatures of the drives?” He didn’t, FreeBSD, Solaris, Linux don’t have an easy way to do this from command line. So I hacked this together:

First you’ll need to configure the sudoer’s file to allow “/usr/local/sbin/smartctl” be ran from a cronjob as root; to do this run:

sudo nano /etc/sudoers

Add at the bottom of this file:

userNAME ALL = NOPASSWD:/usr/local/sbin/smartctl

You may need to check to make sure this is the correct path to smartctl; I built mine from source. To check run:

whereis smartctl


which smartctl

After this you’ll need to schedule the cron to run, I’ve chosen hourly for this example.

crontab -e

Add this to the bottom:

01 * * * * /home/userNAME/HDtemps.sh

Also if you prefer nano over vi then run this:

export EDITOR=nano

Next well need to download the script to our home directory and modify the file to our liking. You will need to edit the uNAME and POOL variables at the very least.

After all is set you’ll be able to grab the CSV file and import it to Excel, Open Office, Libre Office, etc and make nice graphs like so:

This script has been tested on my Solaris 11 Express box, some executable paths may need to be modified.

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

One Response to Temperature monitoring with hourly reports to a CSV file.

  1. Kirk McCann says:

    This doesnt seem to work anymore. the file zpool no longer exists.

Leave a Reply

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