1.每10分钟执行一次
*/10 * * * * /opt/shell/check_disk.sh
2.脚本内容
for i in `cat /opt/shell/hosts` do # echo $i sys=`ssh $i "df -h |grep ‘\/$‘"` #echo $sys sysc=`echo ${sys}|awk -F ‘ |%‘ ‘{print $5}‘` #echo $sysc if [[ $sysc -gt 85 ]];then curl ‘https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=348wo935-shia-4939-a311-dc221d4sb6c4‘ -H ‘Content-Type: application/json‘ -d ‘ { "msgtype": "markdown", "markdown": { "content": "<font color=\"warning\">‘$i‘</font>的系统磁盘使用率大于85,当前使用率为‘${sysc}‘%,请及时处理!!" } }‘ fi data=`ssh $i "df -h |egrep ‘\/mnt|\/data‘"` #echo $data datac=`echo ${data}|awk -F ‘ |%‘ ‘{print $5}‘` if [[ $datac -gt 85 ]];then curl ‘https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=3482ni35-9a1a-4shi9-a311-dc2sbd4766c4‘ -H ‘Content-Type: application/json‘ -d ‘ { "msgtype": "markdown", "markdown": { "content": "<font color=\"warning\">‘$i‘</font>的数据磁盘使用率大于85,当前使用率为‘${datac}‘%,请及时处理!!" } }‘ fi done