Today to their own web site to write shell monitoring, to avoid the site hanging I do not know, the script is to check the status of the Web page and Web Connection time, but also according to their own needs to expand, very powerful.
Script content:
VI check-web.sh
The code is as follows |
Copy Code |
#!/bin/sh Weblist=/root/weblist.txt For list in ' cat $weblist |grep-e-V ' #|^$ ' Todo Httpcode= ' Curl-o/dev/null-s-w%{http_code} ' $list ' Httptime= ' Curl-o/dev/null-s-W ' time_connect:%{time_connect}ntime_starttransfer:%{time_starttransfer}ntime_total :%{time_total}n "" $list "|grep time_total|awk-f": "' {print $2*1000} '" #if [$httpcode = 200]| | [$httpcode = 301]| | [$httpcode = 302]| | [$httpcode = 403]| | [$httpcode = 401] if [$httpcode = 200]| | [$httpcode = 301]| | [$httpcode = 302] Then echo "$list is checked ok!" Else echo "$list is down!" | Mutt-s "web is Down" rocdk@163.com Fi If [$httptime-ge 10000] Then echo "$list is timeout!" | Mutt-s "web is timeout" rocdk@163.com Else echo "$list is connect ok!" Fi Done |
Then create a list of the sites you want to check, formatted as Http://xxx.xxx.xxx
The code is as follows |
Copy Code |
Touch/root/weblist.txt Http://blog.slogra.com
chmod +x/root/soft_shell/check-web.sh
Crontab-e */3 * * * */bin/sh/root/soft_shell/check-web.sh |
The following figure is manually run
OK, this can be relieved.