安装包
root@k8s-master:~/sh# apt install mailutils
添加配置文件
root@k8s-master:~/sh# cat /etc/mail.rc
set from=298880864@qq.com
set smtp=smtp.qq.com
set smtp-auth-user=298880864@qq.com
set smtp-auth-password=nhnilnvzspetbjjb
配置脚本,磁盘使用率大于80告警
root@k8s-master:~/sh# cat disk_use.sh
waring=80
disk_space=`df |grep '/dev/'|grep -Eo '[0-9]+%'|tr -d %|sort -nr |head -n1`
[ "$disk_space" -gt "$waring" ] && echo "disk will be full,$disk_space"|mail -s "disk warning" 236@163.com