Mysql replication heartbeat script

#!/usr/bin/perl -w

## On a slave server, check to see that the slave hasn't stopped.

use strict;
use DBIx::DWIW;

my $conn = DBIx::DWIW->Connect(
DB => "mysql",
User => "root",
Pass => "7mailliw",
Host => "localhost",
) or exit;

my $info = $conn->Hash("SHOW SLAVE STATUS");

if (exists $info->{Slave_SQL_Running} and $info->{Slave_SQL_Running} eq 'No')
{
warn "slave SQL thread has stopped\n";

my $to = 'rootnotification@aghealth123.com';
my $from = 'root@avenger.aghealth123.com';
my $subject = '*******Avenger Replication Failed*******';
open(MAIL, "|/usr/sbin/sendmail -t");
print MAIL "To: $to\n";
print MAIL "From: $from\n";
print MAIL "Subject: $subject\n\n";
print MAIL "Mysql heartbeat script has detected that mysql replication
has failed between agdb1 and avenger.

Thanks...
root\n";
close(MAIL);

}
elsif (exists $info->{Slave_IO_Running} and $info->{Slave_IO_Running} eq 'No')
{
warn "slave IO thread has stopped\n";

my $to = 'rootnotification@aghealth123.com';
my $from = 'root@avenger.aghealth123.com';
my $subject = '*******Avenger Replication Failed*******';
open(MAIL, "|/usr/sbin/sendmail -t");
print MAIL "To: $to\n";
print MAIL "From: $from\n";
print MAIL "Subject: $subject\n\n";
print MAIL "Mysql heartbeat script has detected that mysql replication
has failed between agdb1 and avenger.

Thanks...
root\n";
close(MAIL);
}
elsif (exists $info->{Slave_Running} and $info->{Slave_Running} eq 'No')
{
warn "slave has stopped\n";

my $to = 'rootnotification@aghealth123.com';
my $from = 'root@avenger.aghealth123.com';
my $subject = '*******Avenger Replication Failed*******';
open(MAIL, "|/usr/sbin/sendmail -t");
print MAIL "To: $to\n";
print MAIL "From: $from\n";
print MAIL "Subject: $subject\n\n";
print MAIL "Mysql heartbeat script has detected that mysql replication
has failed between agdb1 and avenger.

Thanks...
root\n";
close(MAIL);
}