-
Notifications
You must be signed in to change notification settings - Fork 14
/
check_web.sh
executable file
·49 lines (44 loc) · 1018 Bytes
/
check_web.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
#
# Author: Guanghongwei
# Mail: [email protected]
cwdir=`dirname $0`
. $cwdir/function.sh
url=${2:-www.baidu.com}
tmpfile=$tmp_dir/.$(str_md5 $url).zbx
website_discovery () {
urls=($(grep -v "^#" $check_list | grep '^web:' | awk '{ print $2 }' ))
discovery ${urls[@]}
}
web_code() {
echo `/usr/bin/curl -m 10 -o /dev/null -s -w %{http_code}::%{time_namelookup}::%{time_connect}::%{time_starttransfer}::%{time_total}::%{speed_download} $1` | tee $tmpfile | awk -F'::' '{ print $1 }'
}
case "$1" in
discovery)
website_discovery
;;
code)
web_code $url
;;
dns)
awk -F'::' '{ print $2 }' $tmpfile
;;
connect)
awk -F'::' '{ print $3 }' $tmpfile
;;
start)
awk -F'::' '{ print $4 }' $tmpfile
;;
total)
awk -F'::' '{ print $5 }' $tmpfile
;;
speed)
awk -F'::' '{ print $6 }' $tmpfile
;;
tmpfile_md5)
tmpfile_md5
;;
*)
echo "Usage:$0 {discovery | code | dns | connect | start | total | speed | tmpfile_md5 [URL]}"
;;
esac