{
    "name"  : "镜像端口是否正常",
    "problems" : {
        "noConError" : {
            "desc"      : "【问题】检测到镜像目的端口配置未配。",
            "advice"    : "【建议】配置镜像目的端口命令为：monitor session ${0} destination interface 镜像目的端口号。"
        },
		"tarBlockError" : {
            "desc"      : "【问题】检测到镜像目的端口被STP BLOCK。",
            "advice"    : "【建议】检测环境是否有环路，更换目的端口或者将STP功能关闭。"
        },
        "tarDownError" : {
            "desc"      : "【问题】检测到镜像目的端口状态为DOWN。",
            "advice"    : "【建议】请排查${0}端口DOWN原因，或更换其它端口。"
        },
		"srcNoConError" : {
            "desc"      : "【问题】检测到镜像源端口配置未配。",
            "advice"    : "【建议】配置镜像目的端口命令为：monitor session ${0} source interface 镜像目的端口号。"
        },
        "srcBlockError" : {
            "desc"      : "【问题】检测到镜像源端口被STP BLOCK。",
            "advice"    : "【建议】检测环境是否有环路，更换目的端口或者将STP功能关闭。"
        },
		"srcDownError" : {
            "desc"      : "【问题】检测到镜像源端口状态为DOWN。",
            "advice"    : "【建议】请排查${0}端口DOWN原因，或更换其它端口。"
        },
		"connectGround" : {
            "desc"      : "当前获取到镜像目的端口为${0}，镜像源端口为${1}，请确认端口是否为所需镜像端口。",
            "advice"    : ""
        }
    }
}
---------------------------code-------------------------------
dailPort= precondition('dailPort')
num = 0
dest2 = ""
commend = "show monitor session "+dailPort
res = cli(commend)
print res
resArr = res.match(/dest-intf:\s+\S+\s\S+/ig)
if resArr==null :
	print 'warn'
	add_problem('noConError',[dailPort])
	return 'warn'
end
res = resArr[0]
resAr = res.split(/\n/)
print resAr
dest = resAr[1]
commend = "show spanning-tree interface "+dest+" | include PortRole"
res = cli(commend)
print res
resAr = res.match(/backupPort/ig)
print resAr
if resAr != null :		
	print 'warn'
	add_problem("tarBlockError")
	return 'warn'
end
commend = "show interface "+dest +" status"
res = cli(commend)
print res
resAr = res.match(/down/ig)
print resAr
if resAr != null :		
	print 'warn'
	add_problem('tarDownError',[dest])
	return 'warn'
end
commend = "show monitor session "+dailPort
res = cli(commend)
print res
resArr = res.match(/src-intf:\s+\S+\s\S+/ig)
resArr1= res.match(/Source vlans\s+:\s+\S+\s\S+/)
print resArr+" "+resArr1
if resArr==null && resArr1 == null:
	print 'warn'
	add_problem('srcNoConError',[dailPort])
	return 'warn'
end
if resArr != null :
	while num < resArr.length :
		res = resArr[num]
		resAr = res.split(/\n/)
		print resAr
		dest1 = resAr[1]
		commend = "show spanning-tree interface "+dest1+" | include PortRole"
		res = cli(commend)
		print res
		resAr = res.match(/backupPort/ig)
		print resAr
		if resAr != null :		
			print 'warn'
			add_problem("srcBlockError")
			return 'warn'
		end
		commend = "show interface "+dest1 +" status"
		res = cli(commend)
		print res
		resAr = res.match(/down/ig)
		print resAr
		if resAr != null :		
			print 'warn'
			add_problem('tarDownError',[dest1])
			return 'warn'
		end
		dest2 = dest2+","+dest1
		num = num+1
	end
end
add_problem("connectGround", [dest,dest2], [], [], [])
return 'warn'
print 'success'
return 'success'