Alert on Unhealthy ZPOOL

Anand Bisen bio photo By Anand Bisen Comment

About once a year my home NAS experiences a disk failure. It’s not a catastrophe as much as it is an inconvenience since I use 5 disks in RAID-5 (RAIDZ in ZFS parlance) that can handle a single disk failure. But from the moment there is a disk failure the NAS is in a critical mode as it cannot sustain another disk failure. Time is of an essence here, replacing the failed disk with a healthy disk as soon as possible is very important.

For various reasons (right or wrong) I chose not to use a commercial NAS and instead built it using Solaris 11 & ZFS. And unfortunately it does not comes with a capability for setting e-mail alerts out of the box. So to address that void I wrote a crude script to monitor my ZPOOL and alert me via mail in the event there is a disk failure.

Instructions

  • Place the script below somewhere in the NAS. Ideally under a regular user’s directory
  • Modify the tail end of the script with the SMTP / Authentication information
  • Make the script executable using chmod +x zpool_status.py
  • Modify crontab entry for that user using crontab -e
  • Create an entry 33 * * * * /home/<username>/bin/zpool_status.py
  • Save and Quit…

Sharing the script for everybody to use, if you improve on it and would like to share your modifications please let me know :)

comments powered by Disqus