#!/bin/bash
weblist="/root/weblist.txt" //在此目录写入网站地址
tmplist="/root/tmpmail.txt" //邮件内容缓存
> $tmplist //每次运行脚本制空上一次缓存内容
myemail="672156067@qq.com"
for list in `cat $weblistgrep -E -v "#^$"`
do
site=$
httpcode=`curl -o /dev/null -s -w % "$site"`
httptime=`curl -o /dev/null -s -w "time_connect: %\ntime_starttransfer:%\ntime_total: %\n" "$site"grep time_totalawk -F ":" ''`
if [ $httpcode = 200 ][ $httpcode = 301 ][ $httpcode = 302 ]
then
echo "$list运行状态正常!" >>$tmplist
else
echo "$list运行状态故障" >>$tmplist
fi
if [ $httptime -ge 10000 ]
then
echo "$list连接超时!" >>$tmplist
else
echo "$list连接成功!" >>$tmplist
fi
echo "系统打开用时:$httptime" >>$tmplist
done
echo "内容"mutt -s "今日业务系统运行汇报" $myemail
运行实现效果: