Article Title: Monitoring disk space and automatic alarm script. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
#! /Bin/sh
# Make by itbit
Init ()
{
IPADD = 'ifconfig | grep 172.18 | awk '{print $2}' | sed's/addr: // g '';
NOWTIME = 'date + % F-% H: % m ';
MAILTO = "";
MAIL_SUB = "! ** Report-Disk Capacity Report $ NOWTIME **! ";
Tmpfile =/tmp/iamatmpfile. tmp
}
Mhead ()
{
Echo ""> $ tmpfile;
Echo "From: $ IPADD" >>$ tmpfile
Echo "State: Report" >>$ tmpfile
Echo "ReportBy: $0" >>$ tmpfile
Echo "DateTime: $ NOWTIME" >>$ tmpfile
Echo "Info: codfei" >>$ tmpfile
Echo "" >>$ tmpfile;
}
Smail ()
{
Mail-s "$ MAIL_SUB" $ MAILTO <$ tmpfile
}
Init;
For x in 'df | grep/dev | awk '{print $5}' | sed's/% // g''
Do
If [$ x-gt 89]; then
Mhead;
Df-h> $ tmpfile;
Smail;
Exit 0;
Fi
Done