95 Star 186 Fork 67

kongkong / monitor-http-server

Create your Gitee Account
Explore and code with more than 6 million developers,Free private repositories !:)
Sign up
Clone or download
monitor-servers.sh 1.45 KB
Copy Edit Web IDE Raw Blame History
2011-181 authored 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"

Comment ( 0 )

Sign in for post a comment

Java
1
https://gitee.com/yeetrack/monitor-http-server.git
git@gitee.com:yeetrack/monitor-http-server.git
yeetrack
monitor-http-server
monitor-http-server
master

Search

153430 a91d09cc 1899542 180418 42a90fc8 1899542