#! /bin/bash
disk_sda2=`df | grep /dev/sda2 | awk '{print$5}' | cut -f1 -d%`
disk_f2A=`df | grep /dev/sdb1 | awk '{print$5}' | cut -f1 -d%`
disk_f2B=`df | grep /dev/sdc1 | awk '{print$5}' | cut -f1 -d%`

:> /home/CGCG/shell/df.txt
if [ $disk_sda2 -gt 95 ]
then
    echo "Frames2服务器/根分区使用率已超过95%,请及时处理。" >> /home/df.txt
fi

if [ $disk_f2A -gt 95 ]
then
    echo "Frames2服务器/f2A分区使用率已超过95%,请及时处理。" >> /home/df.txt
fi

if [ $disk_f2B -gt 95 ]
then
    echo "Frames1服务器/f2B分区使用率已超过95%,请及时处理。" >> /home/df.txt
fi

=================================================================

#! /usr/bin/perl

use Net::SMTP;
use Tie::File;
$File='/home/xxx/shell/df.txt';
if (-f $File and -z _) {
       print "磁盘容量未超过90%\n";
} else {
       
open (MAIL,$File) or die "Can not open df.txt\n";
@Message=<MAIL>;

$subject="Data3 磁盘容量";
$mail_server='mail';
$mail_from='Disk_monitor@xxx.com.cn';
$mail_to='sys_xm@xxxx.com.cn';
$username='Disk_monitor';
$passwd='xxxx';

$smtp=Net::SMTP->new("$mail_server",debug=>1);
$smtp->auth("$username","$passwd");
$smtp->mail("$mail_from");
$smtp->to("$mail_to");
$smtp->data();

$smtp->datasend("To: $mail_to\n");
$smtp->datasend("From: $mail_from\n");
$smtp->datasend("Subject: $subject\n");
$smtp->datasend("\n");

$smtp->datasend("\n@Message");
$smtp->dataend();

$smtp-quit;
}