Sunday, March 20, 2011

Monitoring zpool with email alert «Solaris 11 Express»

Crontab job to scrub zpool once a week and check zpool status

45 3 * * 0 /usr/sbin/zpool scrub MydataZpool

45 3 * * 1 /usr/sbin/zpool scrub rpool

15 8 * * * /pathToperlScript/Zpool_check

Perl script to send email alert when zpool is not healthy



my $command_output = `zpool status -x`;

if ($command_output eq "all pools are healthy\n") {

print "all pools are healthy";





print "zpool not healthy";


$from= 'alert@MYDOMAIN.COM';

$subject='zfs alert';

open(MAIL, "/usr/sbin/sendmail -t");

## Mail Header

print MAIL "To: $to\n";

print MAIL "From: $from\n";

print MAIL "Subject: $subject\n\n";

## Mail Body

print MAIL "Zfs alert \n";

print MAIL $command_output;



Configure sendmail if not already done...

Add this line to “/etc/mail/cf/cf/”


define(`SMART_HOST', `')

define(`confFALLBACK_SMARTHOST', `mailhost$?m.$m$.')dnl

No comments: