
{
    "name"  : "终端重定向异常",
    "problems" : {
        "step_1" : {
            "desc"      : "【问题】设备CPP限速导致丢包",
            "advice"    : "【建议】排查CPP限速设置如果出现丢包，则根据cpu使用情况和用户规模，调整cpp限速。"
        },
		"step_2" : {
            "desc"      : "【问题】设备开启https重定向，性能不足",
            "advice"    : "【建议】关闭https重定向功能show run | i port 443若不需要https重定向业务，需要删除该配置"
        },
		"step_3" : {
            "desc"      : "【问题】认证环境不稳定",
            "advice"    : "【建议】检查通路丢包/延迟情况,开启web认证的情况下，比例低于99%，需要排查环境问题。number of less than half one second:...................0(0.000%)."
        }
    }
}

---------------------------code-------------------------------
res = cli("show cpu-protect type web-auth")
res = res.split(/\r?\n/)
i = 3
while i < (res.length - 1):
	resTmp = res[i]
	resTmp = resTmp.trim()
	resTmp = resTmp.split(/\s+/)
	Total_Drop = resTmp[6]
	print Total_Drop
	if Total_Drop != 0:
		add_problem("step_1")
		return 'warn'
		break
	end
	i = i + 1
end

res = cli("show run")
if res.indexOf("http redirect port 443") != -1:
	add_problem("step_2")
	return 'warn'
end

res = cli("show web-auth authmng stat")
res = res.split(/\r?\n/)
i = 0
while i < res.length:
	resTmp = res[i]
	if resTmp.indexOf("number of less than half one second:") != -1:
		print resTmp
		#start = resTmp.indexof("(")
		#end = resTmp.indexof("%")
		#result = resTmp.substring(start, end)
		#print result
		#if resTmp < 99:
		#	add_problem("step_3")
		#	return 'warn'
		#end
	end
	i = i + 1
end
return 'success'

