{
    "name"  : "设备dns是否配置",
    "problems" : {
        "dns_unconf" : {
            "desc"      : "【问题】未配置DNS服务器",
            "advice"    : "【建议】请配置DNS服务器，配置方式是全局配置模式下执行ip name-server" 
        },
		"different_operator" : {
            "desc"      : "【问题】设备dns与设备接口为不同运营商时会导致认证失效",
            "advice"    : "【建议】设备dns至少需要与接口外网其中一条线路为同一个运营商" 
        },
		"dns_not_connected" : {
            "desc"      : "【问题】dns不通可导致认证异常",
            "advice"    : "【建议】dns地址需能正常解析" 
        }
    }
}

---------------------------code-------------------------------
response = cli('show run | in ip name-server')
response = response.split(/\r?\n/)
dns = {}
i = 1
j = 0
l = response.length - 1
while i < l :
    res = response[i]
	reg = /^\s/
	if !reg.test(res) :
		res = res.split(/\s+/)
	    dns[j] = res[2]
		j = j + 1
    end
	i = i + 1
end

if response.length == 2 || j == 0 :
    add_problem("dns_unconf")
    return 'warn'
end

response = cli('show html inter info | in WAN')
response = response.split(/\r?\n/)
wan = {}
m = 1
n = 0
while m < response.length :
    res = response[m]
	reg = /UP#UP/
	if reg.test(res) :
		res = res.split(/#/)
	    wan[n] = res[1]
		n = n + 1
    end
	m = m + 1
end
x = 0
while x < j :
    y = 0
    while y < n :
	    d = dns[x]
		w = wan[y]
		print dns[x]
		print d
	    if getOperator(d) == getOperator(w) :
		    break
		else :
		    y = y + 1
		end
	end
	x = x + 1
end
if x == j && y == n :
    add_problem("different_operator")
	return 'warn'
end

k = 0
while k < j :
    cmd = 'ping ' + dns[k]
	response = cli(cmd)
	reg = /!!!!!/
	if reg.test(response) :
	    k = k + 1
	else : 
        add_problem("dns_not_connected")
        return 'warn'
    end
end
return 'success'


	
	
	
	
	
	
	
	