#!/bin/bash
# this script is created by caimengzhi
# e_mail:610658552@qq.com
# qqinfo:610658552
# function:caimengzhi trainning stript check_sevice.
# version:1.1
###################################################
# caimengzhi tranning infor. #
# QQ 610658552 #
# site:www.caimz.cn #
# blog:http://caimengzhi.blog.51cto.com #
###################################################
. /etc/init.d/functions
RETVAL=0
FAILCOUNT=0
SCRIPTS_PATH=/root/shell/20150108
MAIL_GROUP="610658552@qq.com caimengzhi@njleco.com"
#MAIL_GROUP="17714246708 18936049021"
##web detection function
LOG_FILE="/tmp/web_check.log"
function GetUrlStatus()
{
for((i=1;i<=3;i++))#检测网站三次
do
wget -T 3 --tries=1 --spider htt://${1} >/dev/null 2>&1
[ $? -ne 0 ] && let FAILCOUNT+=1
done
if [ $FAILCOUNT -gt 1 ];then
RETVAL=1
NowTime=`date +"%m-%d %H:%M:%S"`
SC="http://${HOST_NAME} service is error ,${NowTime}"
echo"send to :$MAIL_USER,Title:SC">$LOG_FILE
for MAIL_USER in $MAIL_GROUP
do
mail -s "$SC" $MAIL_USER<$LOG_FILE #mial mutt
done
else #web is ok
RETVAL=0
fi
return $RETVAL
}
#func end
[ ! -d "$SCRIPTS_PATH" ] &&{
mkdir -p $SCRIPTS_PATH
}
[ ! -f "SCRIPTS_PATH/domain.list" ] && {
cat >$SCRIPTS_PATH/domain.list<
# this script is created by caimengzhi
# e_mail:610658552@qq.com
# qqinfo:610658552
# function:caimengzhi trainning stript check_sevice.
# version:1.1
###################################################
# caimengzhi tranning infor. #
# QQ 610658552 #
# site:www.caimz.cn #
# blog:http://caimengzhi.blog.51cto.com #
###################################################
. /etc/init.d/functions
RETVAL=0
FAILCOUNT=0
SCRIPTS_PATH=/root/shell/20150108
MAIL_GROUP="610658552@qq.com caimengzhi@njleco.com"
#MAIL_GROUP="17714246708 18936049021"
##web detection function
LOG_FILE="/tmp/web_check.log"
function GetUrlStatus()
{
for((i=1;i<=3;i++))#检测网站三次
do
wget -T 3 --tries=1 --spider htt://${1} >/dev/null 2>&1
[ $? -ne 0 ] && let FAILCOUNT+=1
done
if [ $FAILCOUNT -gt 1 ];then
RETVAL=1
NowTime=`date +"%m-%d %H:%M:%S"`
SC="http://${HOST_NAME} service is error ,${NowTime}"
echo"send to :$MAIL_USER,Title:SC">$LOG_FILE
for MAIL_USER in $MAIL_GROUP
do
mail -s "$SC" $MAIL_USER<$LOG_FILE #mial mutt
done
else #web is ok
RETVAL=0
fi
return $RETVAL
}
#func end
[ ! -d "$SCRIPTS_PATH" ] &&{
mkdir -p $SCRIPTS_PATH
}
[ ! -f "SCRIPTS_PATH/domain.list" ] && {
cat >$SCRIPTS_PATH/domain.list<
编辑回复