[root@localhost ~]# yum -y install mailx[root@localhost ~]# vim /etc/mail.rc
在文件的最下方添加以下几条
setfrom=***********@qq.com
set smtp=smtp.qq.com
set smtp-auth-user=*********@qq.com
set smtp-auth-password=phkmhskdybdxefci
set smtp-auth=login
编写txt文件 里面存储监控的域名
[root@localhost ~]# vim url.txt
www.baidu.com
www.qq.com
www.ahdahfioahwfwsjfbsfb.com
编写脚本
[root@localhost ~]# vim /root/yxbj.sh
#!/bin/bash
website=$(cat url.txt)for i in $websitedo
code=$(curl -I -m 1 -o /dev/null -s -w %{
http_code}$i)if[$code-eq 200 ];then
echo"$i is ok"elseecho"$i is not ok,please check!!"echo"$i is not ok,please check!!"|mail -s "url check"***********@qq.com
fi
done