{
    "name"  : "设备DNS解析服务检测",
    "problems" : {
        "dnsDelegate1" : {
            "desc"      : "【问题】设备DNS解决功能关闭,可能导致特征库无法更新，需要使用域名解析的功能不正常",
            "advice"    : "【建议】开启：ip domain-lookup"
        },
	   "dnsDelegate2" : {
            "desc"      : "【问题】提示设备未配置DNS服务器，可能导致特征库无法更新，需要使用域名解析的功能不正常",
            "advice"    : "【建议】建议配置当地运营商的DNS服务器如：ip name-server 114.114.114.114"
        },
		"dnsDelegate3" : {
            "desc"      : "【问题】设备ping百度无法解析",
            "advice"    : "【建议】请确认设备的DNS服务器配置是否正常,如果设备本身是无法上网请忽略"
        }
    }
}
---------------------------code-------------------------------
res = cli("show run | in no ip domain-lookup")
resArr = res.split(/\r?\n/)
if resArr.length != 2 :
    add_problem("dnsDelegate1")
    return "warn"
end

res = cli("show run | in ip name-server")
resAmpt = res.split(/\r?\n/)
i = 1
j = 0
while i < (resAmpt.length - 1) :
    resSignal = resAmpt[i]
	resArr = resSignal.search(/^\s/)
    if resArr == -1 : 
        j = j + 1
	end
	i = i + 1
end
if j == 0 :
		add_problem("dnsDelegate2")
		return "warn"
end

res = cli("show run | in no sys-mode gateway")
resAmpt = res.split(/\r?\n/)
if resAmpt.length == 2 :
	resArr = cli("ping www.baidu.com")
	if resArr.indexOf("Unrecognized") != -1 :
	add_problem("dnsDelegate3")
	return "warn"
	end
else:
	resArr = cli("ping oob www.baidu.com")
	if resArr.indexOf("Unrecognized") != -1 :
	add_problem("dnsDelegate3")
	return "warn"
    end
end

return "success"
