dig 统计域名加速2

#!/bin/bash
#author   yeqing <492980936@qq.com>
#date     2015-07-19 10:26:28
function digThread(){
   yesNum=0
   noNum=0
   i=0
   data=''
   yesList=()
   noList=()
   date=`date +"%Y-%m-%d %H:%M"`
   while read url; do
     dig ${url}|egrep 'cloudglb.net|hacdn.net|hadns.net' > /dev/null 2>&1  
     if [ $? -eq 0 ]; then
        yesList[$i]=${url}
        yesNum=`expr ${yesNum} + 1`
     else
        noList[$i]=${url}
        noNum=`expr ${noNum} + 1`
     fi
     let i++
   done < url.txt 
   for noUrl in ${noList[*]};do
      data="('${date}','${noUrl}',0,${yesNum},${noNum}),${data}" 
   done
   for yesUrl in ${yesList[*]};do
      data="('${date}','${yesUrl}',1,${yesNum},${noNum}),${data}"
   done 
   mysql -h 192.168.1.5 -uroot -p"123456" -s -e "insert into test.fastglb(time,domain,flag,yes,no) values${data%,*}";
}
threadPid=()
for i in `seq 1`; do
   digThread $i &
   threadPid=("${threadPid[@]}" "$!")
done
while [ ${#threadPid[@]} -ne 0 ]; do
   for pidIdx in ${!threadPid[*]}; do
       pidVal=${threadPid[$pidIdx]}
       kill -s 0 $pidVal &>/dev/null || unset threadPid[$pidIdx]
   done
   threadPid=("${threadPid[@]}")
   sleep 1

done

本文转自cloves 51CTO博客,原文链接:http://blog.51cto.com/yeqing/1676120

上一篇:nginx+uWSGI+django+virtualenv+supervisor发布web服务器


下一篇:利用“域名后缀”的漏洞劫持国家*域名(二)