{
    "name"  : "DNS服务器",
    "precondition" : [],
    "problems" : {
        "dns" : {
            "desc"      : "【问题】当前未配置DNS服务器",
            "advice"    : [
                "【建议】可以允许以下配置，配置DNS服务器" ,
                "配置示例：",
                "Ruijie#config",
                "Ruijie(config)#ip name-server 114.114.114.114",
                "Ruijie(config)#end",
                "Ruijie#write"          
            ]
        },
        "dns1" : {
            "desc"      : "【问题】当前配置的DNS服务器8.8.8.8，访问较慢，建议换成国内的DNS服务器",
            "advice"    : [
                "【建议】可以允许以下配置，配置DNS服务器" ,
                "配置示例：",
                "Ruijie#config",
                "Ruijie(config)#ip name-server 114.114.114.114",
                "Ruijie(config)#no ip name-server 8.8.8.8",
                "Ruijie(config)#end",
                "Ruijie#write"        
            ]
        },
        "dns2" : {
            "desc"      : "【问题】当前配置的DNS服务器ping不通，可能访问异常",
            "advice"    : [
                "【建议】检测网络"         
            ]
        }
    }
}
---------------------------code-------------------------------
isProblemFound = false

cmd = "show hosts | include static"
res = cli(cmd)
res1 = formatStaticHosts(res)

staticHostsLength = res1.length

if staticHostsLength == 0:
    isProblemFound = true
    add_problem("dns")
    return 'warn'
end
temp = res1[0]
if staticHostsLength == 1 &&  temp.hosts == '8.8.8.8' :
    isProblemFound = true
    add_problem("dns1")
    return 'warn'
end

unobstructed = false
foreach data in res1 :
    cmd = "ping " + data.hosts
    res2 = cli(cmd)
    res3 = formatPing(res2)
    #res3.ip = data.hosts
    if res3.successRate :
        unobstructed = true;
        break
    end
end

if !unobstructed :
    isProblemFound = true
    add_problem("dns2")
end

if isProblemFound == true :
    return 'warn'
else:
    return 'success'
end