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

«Zpool_check»

#!/usr/bin/perl

my $command_output = `zpool status -x`;

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

print "all pools are healthy";

exit;

}

else

{

print "zpool not healthy";

$to='MYEMAIL@MYPROVIDER.com';

$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;

close(MAIL);

}

Configure sendmail if not already done...

Add this line to “/etc/mail/cf/cf/sendmail.mc”

DOMAIN(`solaris-generic')dnl

define(`SMART_HOST', `SMTP.MYPROVIDER.com')

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



1 comment:

parkleyjacobine said...

The Best Roulette Casinos in New Jersey 2021 - JT Hub
What 구미 출장마사지 casinos 울산광역 출장샵 are there? · PlayAmo Casino · Bet365 Casino · 바카라 사이트 Barstool Casino · GVC 속초 출장샵 Play · Red Tiger 김해 출장샵 Casino.