{
    "name"  : "是否存在未解析的ip地址",
    "problems" : {
        "IPScan" : {
            "desc"      : "【问题】检测到设备上存在IP扫描",
            "advice"    : "【建议】打开全局攻击检测,\r\nRuijie#config\r\nRuijie(config)#nfpp ${0}\r\nRuijie(config-nfpp)#end\r\nRuijie#write"
        },
        "exceptionIp" : {
            "desc"      : "【问题】设备上存在异常未解析的IP地址",
            "advice"    : "【建议】建议与客户确认哪些ARP绑定表项可以删除，然后删除这些异常的arp绑定表项。当前未解析的IP地址有:\r\n${0}"
        },
        "RLDP" : {
            "desc"      : "【问题】${0}",
            "advice"    : ["【建议】建议开启RLDP防环功能，或者开启风暴控制功能。"
                          ,"\t开启RLDP防环功能示例："
                          ,"\t\tRuijie#config"
                          ,"\t\tRuijie(config)#rldp enable "
                          ,"\t\tRuijie(config)#interface GigabitEthernet 0/1 "
                          ,"\t\tRuijie(config-if-range)#rldp port loop-detect block "
                          ,"\t\tRuijie(config-if-range)#spanning-tree bpdufilter enable "
                          ,"\t\tRuijie(config-if-range)#en "
                          ,"\t\tRuijie#write "
                          ,"\t开启广播风暴控制示例： "
                          ,"\t\tRuijie#config "
                          ,"\t\tRuijie(config)#interface GigabitEthernet 0/1 "
                          ,"\t\tRuijie(config-if-range)#spanning-tree portfast "
                          ,"\t\tRuijie(config-if-range)#spanning-tree bpduguard enable "
                          ,"\t\tRuijie(config-if-range)#storm-control broadcast "
                          ,"\t\tRuijie(config-if-range)#end"
                          ,"\t\tRuijie#write"]   
        },
        "MAC" : {
            "desc"      : "${0}",
            "advice"    : ["【建议】建议开启RLDP防环功能，或者开启风暴控制功能。"
                          ,"\t开启RLDP防环功能示例："
                          ,"\t\tRuijie#config"
                          ,"\t\tRuijie(config)#rldp enable "
                          ,"\t\tRuijie(config)#interface GigabitEthernet 0/1 "
                          ,"\t\tRuijie(config-if-range)#rldp port loop-detect block "
                          ,"\t\tRuijie(config-if-range)#spanning-tree bpdufilter enable "
                          ,"\t\tRuijie(config-if-range)#en "
                          ,"\t\tRuijie#write "
                          ,"\t开启广播风暴控制示例： "
                          ,"\t\tRuijie#config "
                          ,"\t\tRuijie(config)#interface GigabitEthernet 0/1 "
                          ,"\t\tRuijie(config-if-range)#spanning-tree portfast "
                          ,"\t\tRuijie(config-if-range)#spanning-tree bpduguard enable "
                          ,"\t\tRuijie(config-if-range)#storm-control broadcast "
                          ,"\t\tRuijie(config-if-range)#end"
                          ,"\t\tRuijie#write"] 
        }
    }
}
---------------------------code-------------------------------
#是否存在未解析的ip地址
response = cli('show version')
if response.search('Invalid input | Unknown command.') != -1 :
    add_reason('无效指令：show version')
    return 'skip'    
end

ipRefResolveCmd = ''
unResolveReg = ''
if response.search('System software version : RGOS 10.') != -1 :
    ipRefResolveCmd = 'show ip ref resolve_lst';
    unResolveReg = /[\r\n+]((?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5]))\s+0\s+/g
else :
    ipRefResolveCmd = 'show ip ref resolve-list';
    unResolveReg = /[\r\n+]((?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5]))\s+unres\s+/g
end
response = cli(ipRefResolveCmd)

if response.search('Invalid input | Unknown command.') != -1 :
    reasonStr = '无效指令:' + ipRefResolveCmd
    add_reason(reasonStr)
    return 'skip'    
end
elems = response.match(unResolveReg)
if elems != null && elems.length > 10 :
    ipAds = ''
    i = 0
    while i < elems.length :
        elemTempString = elems[i];
        elemTempArr = elemTempString.split(' ')
        elemTemp = elemTempArr[0]
        
        if ipAds == '' :
           ipAds = ipAds + elemTemp
        else :
            ipAds = ipAds + '\r\n' + elemTemp
        end
        i = i + 1
    end
    add_problem('exceptionIp',[ipAds])
    return 'skip'
else :
    return 'success'
end
