在网上测试了一段shell脚本,可以使用
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
#!/bin/sh # func: watch the disk size and send warning mail # usage: crontab or while sleep # note: sendmail service is needed # send_attachement: uuencode test.txt test | mail -#s "hello,see the attachement" admin@mzone.cc<mail.txt watch_percent=12 to_addr="weiruoyuboke@abc.com 547153532@qq.com" cc_addr="weiry@126.com" #show_myaddr="fb79@172.20.1.134/58.222.102.64" #while sleep 10m #do for i in `df -h |sed -n '2,8p'|awk '{print $5}' |sed 's/%//g'` do if [ $i -gt $watch_percent ];then echo $i% echo "Please check my disk size,This is dudu_zabbix_192.168.1.55, It is beyond $watch_percent%." | \ mail -s "[test mail] dudu_zabbix_55 use $i%" -c $cc_addr $to_addr break fi done #done |
发送的结果是这样的
来源:https://my.oschina.net/guyson/blog/223081
剩下的加入到定时任务即可 crontab
很实用的小方法,不错哦
这个不错。
不错,收藏