#! /bin/bash
Ctime= ' Date +%x%t '
monitor_dir=/home/jk/
if [!-D $monitor _dir]; Then
mkdir $monitor _dir
Fi
CD $monitor _dir
Web_stat_log=web.status
if [!-f $web _stat_log]; Then
Touch $web _stat_log
Fi
Server_list_file=server.list
if [!-f $server _list_file]; Then
echo "' Date ' +%y-%m-%d%h:%m:%s ' ERROR: $server _list_file not exists!" >> $web _stat_log
Exit 1
Fi
For website in ' Cat $server _list_file '
Do
Url= "/http $website/index.html"
Server_status_code= ' Curl-o/dev/null-s-M--connect-timeout 10-w%{http_code} "$url" '
If ["$server _status_code" = "200"]; Then
echo "' Date ' +%y-%m-%d%h:%m:%s ' visit $website status code OK" >> $web _stat_log
Else
echo "' Date ' +%y-%m-%d%h:%m:%s ' visit $website $server _status_code error!!! Server can ' t connect at 10s or stop response at ten s, send alerm sms ... ">> $web _stat_log
echo "$website's not open for 10 seconds! # $server _status_code# "| Mail-s $ctime ***@139.com
Fi
Done
Exit 0
Linux Monitoring Server Scripts