域名解析情况监控

2017/7/30 posted in  运维

新增信息收集脚本

/root/script/dns/checkdns.sh

LOG_FOLDER=/root/script/dns/logs/
LOG_FILE=${LOG_FOLDER}`date "+%Y-%m-%d"`.txt
DOMAIN=www.4yt.cn

echo "`date "+%Y-%m-%d %H:%M:%S"`;   `dig ${DOMAIN}  | grep ${DOMAIN}  | grep -v ';'`;  `ping ${DOMAIN} -c 1 -n | head -2 | grep -v 'PING' `"  >>  ${LOG_FILE}

增加crontab,每分钟收集一次

*/1 * * * * sh /root/script/dns/checkdns.sh

结果日志

root@iZ231r70b7pZ:~/script/dns# more logs/2017-04-21.txt 

2017-04-21 10:59:01;   www.4yt.cn.              3600    IN      A       59.110.19.86;  64 bytes from 59.110.19.86: icmp_seq=1 ttl=58 time=33.9 ms
2017-04-21 11:00:01;   www.4yt.cn.              3420    IN      A       59.110.19.86;  64 bytes from 59.110.19.86: icmp_seq=1 ttl=58 time=33.7 ms
2017-04-21 11:01:01;   www.4yt.cn.              218     IN      A       59.110.19.86;  64 bytes from 59.110.19.86: icmp_seq=1 ttl=58 time=33.7 ms
2017-04-21 11:02:01;   www.4yt.cn.              408     IN      A       59.110.19.86;  64 bytes from 59.110.19.86: icmp_seq=1 ttl=58 time=33.6 ms
2017-04-21 11:03:01;   www.4yt.cn.              348     IN      A       59.110.19.86;  64 bytes from 59.110.19.86: icmp_seq=1 ttl=58 time=33.6 ms