第四个shell脚本:查询分区剩余空间的百分比,当小于90%时email报警
#!/bin/bash
#磁盘空间小于90%时email报警
disk_sda2=df -h |sed -n '7p'|awk '{print $5}' |cut -f 1 -d '%'
if
((disk_sda2>90));
then
echo "this is error"
echo date"huaweicloud this is over 90%" |mail -s "disk over 90%,script: sh /home/script/free_space.sh" daigang@rofine.com
else
echo "this is ok"
fi