您的位置:首页 > 运维架构 > Linux

centos磁盘容量监控

2017-01-02 11:20 253 查看
监控centos磁盘如果超过设置大小发送邮件提醒

#!/bin/bash
##################################################
#监控磁盘空间的shell,如果满了发送邮件
# vim /etc/crontab
# 30 09 * * * root sh
##################################################
function SendMail(){
#接收者
email_reciver="xx@qq.com xx@163.com"
#smtp服务器地址
email_smtphost=smtp.exmail.qq.com
#发送者邮箱
email_sender=xx@qq.com
#邮箱用户名
email_username=xx
#使用qq邮箱进行发送需要注意:首先需要开启:POP3/SMTP服务。
email_password=
#服务器ip
local_ip=`ifconfig|grep Bcast|awk -F: '{print $2}'|awk -F " " '{print $1}'|head -1`
#主题
email_title="服务器${local_ip}磁盘报警信息"
#邮件内容
email_content="磁盘使用量超过80%"
/opt/sendEmailTool/sendEmail -f ${email_sender} -t ${email_reciver} -s ${email_smtphost} -u ${email_title} -xu ${email_username} -xp ${email_password} -m ${email_content} -o message-charset=utf-8
}
for d in `df -P | grep /dev | awk '{print $5}' | sed 's/%//g'`
do
if [ $d -gt 80 ]; then
SendMail;
exit 0;
fi
done

发送工具参考 上一篇文章的发送工具
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  centos 磁盘监控