#!/bin/bash
#检查域名解析状态#
###  service crond reload  刷新 crontab 定时任务配置###
### 定时任务每分钟执行一次    */1 * * * * root /opt/ziyuan/Shell/jianchayumingjiexi.sh    #####
sj=`date '+%Y-%m-%d %H:%M:%S'`
sjj=`date '+%Y-%m-%d-%H-%M-%S'`
for yuming in  `cat /opt/ziyuan/Shell/yuming.txt |grep -v "#"`
 do
Ip=`nslookup $yuming 114.114.114.114 |grep -v grep  |grep Address |awk '{print $2}'|sed -n "2,10p"`
IPPP=($Ip)

if [   -z "$Ip"   ]
  then
   curl -X POST "https://api.telegram.org/bot1505451550:AAGveeFQrnGyHPhG4LV7W-ev4uk_BKx0dLQ/sendMessage?chat_id=-573668728&text= 当前时间: $sj %0A 当前解域名: $yuming %0A 当前域名解析为空,需要更换"
  else
   for i in ${IPPP[@]}
   do
   echo "当前时间: $sj %0A 当前解域名: $yuming %0A 当前IP: $i"  >> /opt/ziyuan/Shell/rizhi/rizhi-$sjj
   done
fi
done

