-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdig.sh
More file actions
executable file
·75 lines (67 loc) · 1.51 KB
/
dig.sh
File metadata and controls
executable file
·75 lines (67 loc) · 1.51 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
#
# Author: Payne Zheng <zzuai520@live.com>
# Date: 2017-07-19 11:53:53
# Location: Shenzhen
# Desc: check cnmae on nameserver reslove
#
cleanUp() {
rm -f $tempfile
}
report() {
local groupName apiUrl msg
groupName="PLCDN-SUPPORT"
#groupName="PLCDN-STATUS"
apiUrl="http://push.plcdn.net:7890/20160128"
msg=$1
#groupName=$2
wget -q --header="To: $groupName" \
--post-data="$msg" "$apiUrl" \
-O /dev/null
}
checkRes() {
local resfile=$1 ns=$2
sta=$(awk '/status/{print $(NF-2)}' $resfile | tr -d ',')
res=$(awk '/IN/{print}' $resfile | tail -1)
nsip=$(awk '/SERVER:/{print $3}' $resfile | sed -r 's/\(.*\)//')
if test ! -z "$sta" -a "$sta" != 'NOERROR'; then
echo "@$ns ==> $dom ==> $sta" | tee -a $notOk
return 1
fi
}
runDig() {
local cname_dom=$1
for i in {1..8}
do
nameServer=ns${i}.speedtopcdn.com
/usr/bin/dig @$nameServer $cname_dom | grep -E "IN|HEADER|SERVER" &> $tempfile
checkRes $tempfile $nameServer
if test $? -ne 0; then
makeMsg
report "$Msg"
fi
done
}
makeMsg() {
Msg=$(echo -e "\
NS-SERVER RESOLVE ERROR\n\
----------------------\n\
NS: $nameServer\n\
NSIP: $nsip\n\
CNAME: $dom\n\
Details:\n ###\
$(cat $tempfile) ###\n\
--------------------\n\
Time: $(date '+%Y-%m-%d %H:%M:%S')")
}
tempfile=$(mktemp)
cname_list=
notOk=/tmp/dns_check/notok.log
errLog=/tmp/dns_check/err.log
test -d /tmp/dns_check || mkdir /tmp/dns_check
getCnameList
while read dom
do
runDig $dom
done < $cname_list
trap cleanUp exit