简单的磁盘监控邮件告警

一个简单的磁盘空间邮件告警

#!/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

小弟第一次写,有什么不对的,请各位大神多多指教

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容