DNS域名轮循业务监控

Posted jklp-1234

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了DNS域名轮循业务监控相关的知识,希望对你有一定的参考价值。

import dns.resolver
import os
import http.client
iplist = []
appdomain = ‘www.baidu.com‘
def get_iplist(domain=‘‘):
try:
A = dns.resolver.query(domain,‘A‘)
except Exception as e:
print ("dns resolver error:"+str(e))
return
for i in A.response.answer:
for j in i.items:
iplist.append(j)
return True
def checkip(ip):
checkurl = str(ip) + ‘:80‘
getcontent=‘‘
http.client.socket.setdefaulttimeout(20)
#创建连接对象
conn = http.client.HTTPConnection(checkurl)
try:
conn.request(‘GET‘,‘/‘,headers = ‘Host‘: appdomain)
r = conn.getresponse()
getcontent = r.read(15)
finally:
if getcontent == b‘<!DOCTYPE html>‘:
print (str(ip)+‘ [ok]‘)
else:
print (str(ip)+‘ [Error]‘)
if __name__ == "__main__":
if get_iplist(appdomain) and len(iplist) > 0:
for ip in iplist:
checkip(ip)
else:
print(‘dns resolver error.‘)

以上是关于DNS域名轮循业务监控的主要内容,如果未能解决你的问题,请参考以下文章

DNS域名轮循业务监控

DNS域名轮循业务监控

Python自动化运维:DNS域名轮循业务监控(IP地址处理模块IPy和DNS处理模块dnspython)

Python之DNS域名轮询业务监控

zabbix监控DNS服务

为什么需要网站监控来管理网站?