Since I’m using consumer drives that are prone to failure (one already failed within 2 days, but ZFS prevented any data loss).
I am using the script located here:
http://www.sun.com/bigadmin/scripts/submittedScripts/zpadmin.txt.
This will script allows for regular monitoring and scrubs of the pool with email alerting.
These next bunch of steps may not be necessary for everyone. I’m essentially setting up sendmail to use a smarthost. Even if you do need to use a smarthost, there may be an easier way by just modifying one line in the script.
Set smarthost for sendmail email delivery since ATT blocks outgoing port 25 on home DSL connections.
Steps learned from:
Edited sendmail.mc
cd /usr/lib/mail/cf
nano sendmail.mc
This line only needed if relay not using port 25:
define(`RELAY_MAILER_ARGS', `TCP $h 587')dnl
Added:
define(`RELAY_MAILER',`esmtp')dnl
define(`SMART_HOST', `relay:[SmartHostAddressGoesHere]')dnl
Commented out by adding # the followng line:
#define(`confFALLBACK_SMARTHOST', `mailhost$?m.$m$.')dnl
Then at the command line:
m4 /usr/lib/mail/m4/cf.m4 sendmail.mc > /etc/mail/sendmail.cf
Restarted sendmail
svcadm restart sendmail
Then I had to get the script working:
Steps taken:
- Created a directory called scripts
- downloaded the script
- renamed it
- set it to be executable
- edited settings
- scheduled with cron
mkdir /scripts
cd /scripts
wget http://www.sun.com/bigadmin/scripts/submittedScripts/zpadmin.txt
mv zpadmin.txt zpadmin.pl
chmod ug+x zpadmin.pl
Edit script. Need to at minimum change:
my $log_path=
Set mine to "/var/log/zpool_adm_log"
my $mailto =
I had to set my $mailhost = "127.0.0.1" might be due to some sort of misconfiguration on my end. This also means that some of the steps above for configuring the smarthost could have been avoided. I still think they are worthwhile because sendmail may be needed to send other sorts of alerts in the future.
Add to cron:
crontab -e
Crontab uses vi, so we need to enter:
G goes to last line of file
o opens new line after line you’re on and gets you into edit mode
Enter the following. Feel free to omit the commented lines if you’d like.
# ZPOOL MONITOR ->
0 * * * * /scripts/zpadmin.pl
# ZPOOL WEEKLY SCRUB ->
0 5 * * 0 /scripts/zpadmin.pl -scrub
Press Esc to get out of edit mode
Then :wq which tells vi to write the file and then quit.
Now your pools will be checked every hour and will be scrubbed once a week on Sunday at 5AM.
See cron on Wikipedia for more information.