The Code
use Mail::Sendmail;
use strict;
my $BBSRPTEST = "bbsrptest.exe";
my $SMTP_SERVER = "smtp.server.com";
my $NO_OF_BES_SERVERS = 1;
my $EMAIL_TO = 'email@domain.com,anotheremail@domain.com';
my $EMAIL_FROM = 'email@domain.com';
my $output = `$BBSRPTEST`;
my $success_count = () = $output =~ /Successful/gs;
if ($success_count < $NO_OF_BES_SERVERS) {
my $failures = $NO_OF_BES_SERVERS - $success_count;
my %mail_options = (
To => $EMAIL_TO,
From => $EMAIL_FROM,
Subject => "[$ENV{COMPUTERNAME}] BB SRP Down!",
Body => "There was $failures SRP failures. Output was:\n$output\n",
);
sendmail(%mail_options);
}
This Perl code uses the Mail::Sendmail Perl module, which doesn't come with the default distribution from ActiveState (which must be downloaded from http://www.activestate.com/store/languages/register.plex?id=ActivePerl). You'll need to install it by typing ppm install Mail::Sendmail from a command prompt. Type the following code into Notepad (or your favorite text editor) and save it as bbsrptest.pl. Of course, you will need to modify the variables at the top of the file.