1 Star 0 Fork 78

huzorro / monitor-http-server

forked from kongkong / monitor-http-server 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
monitor-servers.sh 1.45 KB
一键复制 编辑 原始数据 按行查看 历史
2011-181 提交于 2015-03-27 16:14 . first commit
#!/usr/bin/env bash
# DESCRIPTION
# Check all website given in the list file
#
# USAGE
# ./monitor-servers.sh me@host.com ./custom-list.txt
#
currentDir=$(cd "$(dirname "$0")"; pwd)
chmod +x ${currentDir}/*.sh
scriptDir="$(dirname "$0")" # emplacement du script
# . "$scriptDir"/toolboxrc # charge quelques function utiles (today, etc.). Le
. "$scriptDir"/stylerc # include some style
#clear
emailTo="${1:-me@host.com}"
srvList="${2:-"$scriptDir"/monitor-list-default.txt}" # URL to server
# @description check if requirement are met and display message
# @return void
function checkRequirement() {
if ! type mail 2> /dev/null; then
printf " \b--\n\t%s Requirement %s %s\t %s\n--\n\n" \
"$_w" \
"$(_warning "missing")" \
"$(_valid "->")" \
"$(_warning "Install and configure a 'mail' server")"
fi
}
# @description monitor the list of provider server, send mail to given adress
# @param $1|$srvList list of server to monitor
# @param $2|$emailTo target email adress
# @return void
function monitor()
{
local srvList="$1"
local emailTo="$2"
while read -r line
do
[[ "$line" = \#* ]] && continue # ignore lines starting by '#'
site="${line#*//}" # remove the protocole
site="${site%/*}" # remove trailing slash
#printf "Checking %s...\n\t" "$(_value ${site})"
"$scriptDir"/monitor-app.sh "$emailTo" "$line"
done < "$srvList"
}
# start
checkRequirement
monitor "$srvList" "$emailTo"
1
https://gitee.com/huzorro/monitor-http-server.git
git@gitee.com:huzorro/monitor-http-server.git
huzorro
monitor-http-server
monitor-http-server
master

搜索帮助