[小芮]智能dns,判断脚本【自己线上的】

dns系统用的是第三方的,wddns......


#!/bin/bash 
#set mysql config 
MYSQL_BIN=/www/wdlinux/mysql/bin 
MYSQL_HOST=localhost
MYSQL_USER=root
MYSQL_PWD=8860056
stty erase ^h 
mysql_ip=`$MYSQL_BIN/mysql -h $MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PWD -e "select data from wdcpdb.wd_dns_records where type='A' and zone='nb03.com' or  zone='zsguolv.com' or zone='maidod.com';"|awk '$1!~/[a-zA-Z]/{i[$1]++}END{for(a in i){print a}}'` 
for x in $mysql_ip 
  do 
    ping -c1 -W1 $x 
    result=$? 
    if [[ $result -eq 0 ]] 
      then 
        echo "server $x active!" 
        $MYSQL_BIN/mysql -h $MYSQL_HOST -u $MYSQL_USER -p$MYSQL_PWD -e "UPDATE wdcpdb.wd_dns_records set ups='0',avil='0' where data='$x';" 
    else 
        echo "server $x down!" 
        $MYSQL_BIN/mysql -h $MYSQL_HOST -u $MYSQL_USER -p$MYSQL_PWD -e "UPDATE wdcpdb.wd_dns_records set ups='1',avil='1' where data='$x';" 
    fi 
  done


你可能感兴趣的:(python,脚本,bind,bind,智能dns,view脚本)