{
    "name"  : "检查流控配置错误",
    "problems" : {
	    "flowError" : {
            "desc"      : "【问题】用户没有开启流控。",
            "advice"    : "【建议】在WAN口开启流控。"
        },
        "shutdownError" : {
            "desc"      : "【问题】无。",
            "advice"    : "【建议】检测到${0}未开启流控，是否开启流控。"
        },
		"noIPError" : {
			"desc"      : "【问题】Ef字段不为 1，则该条流控策略没生效。",
            "advice"    : "【建议】流控策略没生效，请检查流控的配置。"
		},
		"noPARError" : {
			"desc"      : "【问题】没有配置time-range any会导致流控策略没生效。",
            "advice"    : "【建议】请配置time-range  any。"
		},
		"noCHAPUserError" : {
			"desc"      : "【问题】该接口流控配置的带宽与接口带宽不致。",
            "advice"    : "【建议】请确认流控配置 的带宽与接口带宽是否一致。"
		},
		"noCHARPasswordError" : {
			"desc"      : "【问题】拨号口或小于10M的线路，没有开启小报文优先。",
            "advice"    : "【建议】请在channel-tree outbound上配置小报文优先small-packet key tcp。"
		}
    }
}
---------------------------code-------------------------------
num = 0
ifx = ''

res = cli("show flow-control-policy group")
print res
resArr = res.split(/tpl\w+/ig)
groupName = res.split(/tpl\w+/ig)
bandwidth = res.split(/tpl\w+/ig)
print resArr
res = resArr[resArr.length - 1]
print res
resAr = res.match(/\S+\s+\d+\s+[1-9]\d*\s+\d+\s+\d+/ig)
print resAr
if resAr == null :
	print 'warn'
	add_problem("flowError")
	return 'warn'
end
while num < resAr.length :
	resAr1 = resAr[num] 
	ifx1 = resAr1.split(/\s+/)
	print ifx1
	ifx2 = ifx1[2]
	print ifx1[0]+"^^"+ifx1[2]+"^^"+ifx1[3]
	groupName[num] = ifx1[0] 
	print "^^^^^^^"+groupName[num]
	bandwidth[num] = ifx1[4]
	ifx = ifx + ifx2 +' '
	num = num +1
end
print groupName
print bandwidth
print ifx
res = cli("show sys-mode")
print res
resArr = res.split(/wan:\s+/ig)
print resArr
res = resArr[resArr.length - 1]
print res
wanArr = res.match(/\S+\s+\S+/ig)
print wanArr
num = 0
while num < wanArr.length :
	commend = "show interface "+ wanArr[num]
	res = cli(commend)
	print res
	index = res.match(/Index\(dec\):\d+/ig)
	index1 = index[0]
	index2 = index1.match(/\d+/)
	index3 = index2[0]
	flag = ifx.match(index3)
	if flag == null :
		print 'warn'
		wan = wanArr[num]
		add_problem("shutdownError",[wan])
		return 'warn'
	end		
	num = num +1
end
num = 0
print "groupName"+groupName
while num < groupName.length :
	commend = "show flow-control-policy rule group "+ groupName[num]
	res = cli(commend)
	print res
	index = res.match(/up\s+0/ig)
	if index != null :
		print 'warn'
		add_problem("noIPError")
		res = cli("show time-range  any")
		print res
		resAr1 = res.match(/time\Srange/ig)
		print resAr1
		if resAr1[1] == null :
			print 'warn'
			add_problem("noPARError")
			return 'warn'
		end
		return 'warn'
	end		
	num = num +1
end
num = 0
while num < groupName.length :
	commend = "show run interface "+ groupName[num]
	res = cli(commend)
	print res
	index = res.match(/bandwidth\s+\d+/ig)
	if index != null :
		index1 = index[0]
		index2 = index1.match(/\d+/)
		if index2 != bandwidth[num] :
			print 'warn'
			add_problem("noCHAPUserError")
			return 'warn'
		end	
	end
	if index == null :
		add_reason("该接口没有配置")
	end
	num = num +1
end
num = 0
while num < groupName.length :
	isDi = groupName[num]
	ban = bandwidth[num]
	if isDi.match(/di/ig) != null ||  ban<10000 :
		commend = "show flow-control "+ groupName[num]
		res = cli(commend)
		print res
		index5 = res.match(/small\Spacket key tcp/ig)
		if index5 == null :
			print 'warn'
			add_problem("noCHARPasswordError")
			return 'warn'
		end	
	end
	num = num +1
end
print 'success'
return 'success'