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:
After this you’ll need to schedule the
cron to run, I’ve chosen hourly for this example.
Add this to the bottom:
01 * * * * /home/userNAME/HDtemps.sh
Also if you prefer
vi then run this:
Next well need to download the script to our home directory and modify the file to our liking. You will need to edit the
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.