{
    "name"  : "是否使用非锐捷光模块",
    "precondition" : ["name"],
    "problems" : {
        "unKnow" : {
            "desc"      : "【问题】该光模块类型识别为“unknown”，该光模块为非锐捷问题光模块会导致端口丢包。",
            "advice"    : "【建议】建议更换锐捷认证光模块。"
        },
        "unFind" : {
            "desc"      : "【问题】端口${0}未识别到光模块或未插光模块。",
            "advice"    : "【建议】建议插紧或更换光模块。"
        }
    }
}

---------------------------code-------------------------------
intf = precondition('name')
intf_cmd = format('show interface %s status',intf)
intf_sta = cli(intf_cmd)
reg = /[^ ]+Ethernet\s+[^ ]+\s+\w+\s+[^ ]+\s+[^ ]+\s+\d+M\s+fiber/
reg_unKnown = /unknown/
reg_unFind = /the transceiver is absent/
r = intf_sta.match(reg)
if r != null :
    tra_cmd = format('show interface %s transceiver',intf)
    tra_log = cli(tra_cmd)
    if tra_log.indexOf('unknown') > -1:
        change_title('检测端口使用问题光模块')
        add_problem('unKnow',[intf])
        return "warn"
    end
    if tra_log.indexOf('the transceiver is absent') > -1:
        change_title('检查该端口光模块未被识别')
        add_problem('unFind',[intf])
        return "warn"
    end
end
change_title('检查该端口光模无异常')
return 'success'

