{
    "name"  : "是否端口违例导致端口无法LINKUP",
    "precondition" : ["name"],
    "problems" : {
        "BPDU_Guard": {
            "desc"      : "【问题】检测到端口${0}违例，原因为BPDU Guard",
            "advice"    : ["【建议】确认是否需要开启BPDU Guard功能，若需要，则排查端口隐患，若不需要，则在该端口上删除BPDU-Guard配置，并恢复违例"
                          ,"配置举例："
                          ,"\tRuijie#config"
                          ,"\tRuijie(config)#interface ${1}"
                          ,"\tRuijie(config-if)#spanning-tree bpduguard disable"
                          ,"\tRuijie(config-if)#exit"
                          ,"\tRuijie(config)#errdisable recovery"
                          ,"\tRuijie(config)#end"]
        },
        "other" : {
            "desc"      : "【问题】检测到端口${0}违例，原因为${1}",
            "advice"    : ["【建议】根据提示恢复网络环境后执行如下命令恢复"
                          ,"\tRuijie(config)# errdisable recovery"]
        }
    }
}
---------------------------code-------------------------------
int = precondition('name')
reg = /--------[\r\n]\s*.+?\s{2,}.+?\s{2,}(.+)/
cmd = 'show interface ' + int + ' status err-disabled'
response = cli(cmd)
reason = response.match(reg)
if !reason :
    return 'success'
else :
    reason = reason[1]
    if reason == 'BPDU Guard' :
        restore_cmd = []
        str = 'interface ' + int
        restore_cmd.push('end')
        restore_cmd.push('config')
        restore_cmd.push(str)
        restore_cmd.push('spanning-tree bpduguard disable')
        restore_cmd.push('exit')
        restore_cmd.push('errdisable recovery')
        restore_cmd.push('end')
        add_problem('BPDU_Guard', [int, int], restore_cmd, [])
        return 'warn'
    else :
        add_problem('other', [int, reason])
        return 'warn'
    end
end