No changes to the code, but I've moved hosting of this script to Github. The button will take you to the project page, or you can download the script directly by running fetch https://raw.githubusercontent.com/danb35/zpscan/master/zpscan.sh.
For reasons unclear to me, the email logic I'd added seemed to break things, so I've removed it. The script now will send an email when it detects a failure. By default, the email will go to root; if you want it to go to some other address, specify it on the command line: zpscan.sh poolname email@example.com.