一个简单的磁盘空间邮件告警
#!/bin/bash
date_today=`date +%Y-%m-%d`
time_today=`date +%H:%M`
subject="磁盘告警"
content="Dear All,
The server DB(xxxx) disk has reached the warning value of 90% ,please take action for it. many thanks!
------------------------------------------------------------------------------------------------
数据库服务(xxxx)磁盘空间已达到预警值90%,请通知相关人员及时处理,非常感谢!
检测时间:$date_today $time_today
"
for d in `df -P | grep /dev | awk '{print $5}' | sed 's/%//g'`
do
if [ $d -gt 90 ]; then
echo "$content" | mail -s "$subject" chenglong@bamboocloud.cn
exit 0;
fi
done
注:需要Linux中/etc/mail.rc文件末尾添加发送服务
# For Linux send mail by out smpt
set from=xxx@126.com smtp=smtp.126.com smtp-auth-user=xxx@126.com smtp-auth-password=xxxx smtp-auth=login
小弟第一次写,有什么不对的,请各位大神多多指教