用脚本来判断根目录使用率超过75%报警到139邮箱

新公司第二天写的,需要用到sendEmail.

#wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz

#tar zxvf sendEmail-v1.56.tar.gz

#cd sendEmail-v1.56.tar.gz

#cp sendEmail /usr/local/bin

#chmod +x /usr/local/bin/sendEmail

脚本如下

#!/bin/bash
size=`df -h |grep "/$"|awk '{print $4}' |cut -f 1 -d %`
if [ "$size" -lt "75" ];then
echo "disk space / is below 75%"
else
echo "disk space / is over 75%"
sendEmail -f [email protected] -t [email protected] -s mail.163.com -u "disk space warning" -m "disk space / is over 75%" -xu xxx -xp xxxx
fi
 

你可能感兴趣的:(shell,职场,sendEmail,休闲)