{
    "name"  : "下一跳联通性",
    "precondition" : [],
    "problems" : {
        "ping_nexthop" : {
            "desc"      : "【问题】接口 ${0} 到其下一跳 ${1}存在大包丢包,丢包率为 ${2}%",
            "advice"    : [
                "【建议】"                
            ]
        },
		"ping_di_nexthop" : {
            "desc"      : "【问题】接口 ${0} 到其对端地址 ${1}存在大包丢包,丢包率为 ${2}%",
            "advice"    : [
                "【建议】"                
            ]
        },
        "ping_nexthop1" : {
            "desc"      : "【问题】接口 ${0} 到其下一跳 ${1}网络延迟较大,丢包率为 ${2}%,，延迟为${3}",
            "advice"    : [
                "【建议】"                
            ]
        },
		"ping_di_nexthop1" : {
            "desc"      : "【问题】接口 ${0} 到其下一跳 ${1}网络延迟较大,丢包率为 ${2}%,，延迟为${3}",
            "advice"    : [
                "【建议】"                
            ]
        }
    }
}

---------------------------code-------------------------------

isProblemFound = false
wansDetail = get_share_value('wansDetail');

foreach int in wansDetail:
    if int.isUP && int.ip && int.nexthop :
        intf = int.intf
        nexthop = int.nexthop
        cmd = 'ping ' + int.nexthop + ' source ' + int.intf + ' length 1500 ntimes 10 timeout 1'
        res = cli(cmd)
        data = formatPing(res)
        if data.dns == false :
            continue
        end
        failRate = 100 - data.successRate;
        if data.successRate < 90 :
            isProblemFound = true
			if intf.indexOf('Di') != -1:
				add_problem("ping_di_nexthop",[intf, nexthop, failRate])
			else:
				add_problem("ping_nexthop",[intf, nexthop, failRate])
			end
        end
        avg = data.avg
        if data.successRate && data.avg > 50 :
            isProblemFound = true
			if intf.indexOf('Di') != -1:
				add_problem("ping_di_nexthop1",[intf, nexthop, failRate, avg])
			else:
				add_problem("ping_nexthop1",[intf, nexthop, failRate, avg])
			end
        end
    end
end

#获取有效的WAN口，
#满足有下一跳、状态UP，有有效IP


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

