#!/usr/bin/perl
use strict;
use Net::SMTP;
my $max=0.8;
my @msg;
use strict;
use Net::SMTP;
my $max=0.8;
my @msg;
open(FH,"df -P|");
foreach my $data (<FH>){
if(($data=~/^\//)and!($data=~/\/mnt/)){
my(@arr)=split " ",$data;
if($arr[2]/$arr[1]>$max){
push(@msg,"$arr[5] $arr[4]" );
}
}
}
foreach my $data (<FH>){
if(($data=~/^\//)and!($data=~/\/mnt/)){
my(@arr)=split " ",$data;
if($arr[2]/$arr[1]>$max){
push(@msg,"$arr[5] $arr[4]" );
}
}
}
if(defined(@msg)){
foreach my $cont (@msg){
my $mailhost='127.0.0.1';
my lanlan@139.com'">$mailfrom=' lanlan@139.com';
my zhengjun.zhu@163.com'">$mailto=' zhengjun.zhu@163.com';
my $subject="Disk Warn";
my $smtp = Net::SMTP->new($mailhost,Hello =>"localhost",Timeout => 30,Debug => 0,);
$smtp->mail($mailfrom);
$smtp->to($mailto);
$smtp->data();
$smtp->datasend("To: $mailto\n");
$smtp->datasend("From: $mailfrom\n");
$smtp->datasend("Subject: $subject\n");
$smtp->datasend("\n");
$smtp->datasend("磁盘警告:$cont\n");
$smtp->dataend();
$smtp->quit;
}
}
foreach my $cont (@msg){
my $mailhost='127.0.0.1';
my lanlan@139.com'">$mailfrom=' lanlan@139.com';
my zhengjun.zhu@163.com'">$mailto=' zhengjun.zhu@163.com';
my $subject="Disk Warn";
my $smtp = Net::SMTP->new($mailhost,Hello =>"localhost",Timeout => 30,Debug => 0,);
$smtp->mail($mailfrom);
$smtp->to($mailto);
$smtp->data();
$smtp->datasend("To: $mailto\n");
$smtp->datasend("From: $mailfrom\n");
$smtp->datasend("Subject: $subject\n");
$smtp->datasend("\n");
$smtp->datasend("磁盘警告:$cont\n");
$smtp->dataend();
$smtp->quit;
}
}
本文出自 “
坏男孩” 博客,请务必保留此出处
http://5ydycm.blog.51cto.com/115934/116684
转载于:https://blog.51cto.com/ilexes/234682