use Redis;  
use Sys::Hostname;
use HTTP::Date qw(time2iso str2time time2iso time2isoz);  
use Net::SMTP;
sub basic() {
     $host = hostname;
     @lines=qx|/sbin/ifconfig|;
     @ip;
    print "-" x 80 ."\n";
    foreach(@lines){
        if(/inet addr:([\d.]+)/){
            push @ip,$1 unless $1 =~ /\A127.0.0.1\z/;
        }
    }
    print "${yellow}HOST: $host => IP: @ip$normal\n";
    print "-" x 80 ."\n";
};
&basic();
sub send_mail{
if (@_ != 2){print "error\n"};
    ($m,$n) = @_; 
    my $to_address  = $m;
my $CurrTime = time2iso(time());
    my $to_address  = $m;
 my $mail_user   = 'zhaoyangjian@zjcap.cn';
    my $mail_pwd    = 'xxxxx';
    my $mail_server = 'smtp.exmail.qq.com';

    my $from    = "From: $mail_user\n";
    my $subject = "Subject: zjcap info\n";
    my $info = "$CurrTime--$n";
     my $message = <<CONTENT; 
     $info
CONTENT
    my $smtp = Net::SMTP->new($mail_server);

    $smtp->auth($mail_user, $mail_pwd) || die "Auth Error! $!";
    $smtp->mail($mail_user);
    $smtp->to($to_address);

    $smtp->data();             # begin the data
    $smtp->datasend($from);    # set user
    $smtp->datasend($subject); # set subject
    $smtp->datasend("\n\n");
    $smtp->datasend("$message\n"); # set content
    $smtp->dataend();
    $smtp->quit();
};
$var;
eval{
my $r = Redis->new( server => "127.0.0.1:6379",reconnect => 1,every=>60) or (die "can't connect to redis");  
$r = Redis->new( password =>  'xxxx' );  
$var=$r->get('test');
print "\$var is $var\n";
$r->quit; 
};

print "$var\n";
if ( defined($var) ){print "redis could connetct\n"}
else
{print "redis is lost",send_mail('zhaoyangjian@zjcap.cn',"@ip-redis is lost\n")};