歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux編程 >> SHELL編程

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

Copyright © Linux教程網 All Rights Reserved