{
    "name"  : "诊断系统启动异常",
    "problems" : {
        "IPSec_status" : {
            "desc"      : "[问题] 硬件故障",
            "advice"    : "[建议] ${0}"
        }
    },
    "matchString" :["ERROR:PHY reset time out!","phyresetfailed",],
    "suggest" : {
        "ERROR:PHY reset time out!"      : "50MHz晶振（OSC4)",
        "phyresetfailed"                 : "逻辑芯片",
        "nand scan failed."              : "FLASH",
        "FPGA oprate spi fail"           : "FPGA",
        "Memory self check failed."      : "CPU/内存条/电阻",
        "pci_bios.c:190:[init]"          : "PCI2050",
        "ROMUARTOK!"                     : "内存",
        "flash error!"                   : "FLASH或内存",
        "The wired nand flash checking!" : "重新格式化加载主程序",
        "CPU Error Report Registers:"    : "CPU/内存",
        "System Exception Occured: Watchdog Timer exception (0x00B00)": "PCI 总线异常",
        "pcihp: pci_hpctrl_add_slot: Can't find"   : "PCI 总线异常",
        "phy match  failed!!!"                     : "PHY（88E6097（U1)",
        "“PCI device”,“handoff failed”"            : "PCI 总线异常",
        "find_fpga_sic3gm_device(977)"             : "FPGA",
        "PCI Addr get failed"                      : "PCI 总线异常",
        "function button."                         : "复位电路异常"         
    }
}
---------------------------code-------------------------------
res = precondition('srcConf')
resArr = res.split(/\r?\n/ig)

print '-------------'
res = cli("show cry st")
print res
res = cli("show cry st")
print res
res = cli("show cry st")
print res
print '==============='

i = 2
IPSecFailedJson = {}
status = get_configure_value('status')

while i < (resArr.length - 1):

    singleRes = resArr[i]
    #含有异常隧道
    if singleRes.indexOf('IKE_IDLE') == -1 && singleRes.indexOf('QM_IDLE') == -1 :
        singles = singleRes.trim()
        singles = singles.replace(/, /,',')
        singleArr = singles.split(/\s+/)
        singleKey = singleArr[0]
        singleStatus = singleArr[4]
        #已经保存过该异常隧道
        if IPSecFailedJson.hasOwnProperty(singleKey) :
            oldStatus = IPSecFailedJson[singleKey]
            oldStatusLevel = status[oldStatus]
            currentStatusLevel = status[singleStatus]
            if oldStatusLevel < currentStatusLevel :
                IPSecFailedJson[singleKey] =  singleStatus
            end
        else :
            IPSecFailedJson[singleKey] =  singleStatus
        end
    end 
    
    i = i + 1
end

suggest = get_configure_value('suggest')

hasProp = false
foreach IP in IPSecFailedJson :
    hasProp = true;  
    break;  
end
    
statusString = ''
suggestString = ''
    
if !hasProp :
    return 'success'
else :
    foreach IP in IPSecFailedJson :
    
        currentStatus = IPSecFailedJson[IP]
        currentSuggest = suggest[currentStatus]
        
        if statusString == '' :
            statusString = currentStatus
        else :
            statusString = statusString + ';' + currentStatus
        end
        
        if suggestString == '' :
            suggestString = currentSuggest
        else :
            suggestString = suggestString + ';' + currentSuggest
        end
    end
    
    add_problem('IPSec_status', [statusString, suggestString])
    return 'warn'
    
end

    