shell 告警脚本

shell 告警脚本

功能:执行URL,超过30秒就发邮件进行告警

#!/bin/sh
Path="/root/shell"
MailList="[email protected]  [email protected]"
Date=`date '+%Y-%m-%d %H:%M:%S'`
for url in $(cat /home/caozm/moniter/url.txt)
do
Time=`curl -o /dev/null -s -w "time_connect: %{time_connect} time_starttransfer: %{time_starttransfer} time_total: %{time_total}" ${url}`
TimeTotal=`echo $Time | awk -F " " '{print $6}'`
if [ $(echo "$TimeTotal > 30"|bc) == 1 ]
then
{
echo "${Date} ${Time} $url"  | mail -s "${url}" ${MailList}
}
fi

相关推荐