{
    "name"  : "带宽利用率",
    "precondition" : [],
    "problems" : {
        "bw" : {
            "desc"      : "【问题】接口${0}带宽使用率超过90%",
            "advice"    : [
                "【建议】"                
            ]
        }
    }
}

---------------------------code-------------------------------
isProblemFound = false

wansDetail = get_share_value('wansDetail');
#set_share_value('wansDetail', wansDetail)
#set_share_value('global_wan_up_int_arr', wan_up_int_arr)

#  这里获取了所有WAN口并UP的口后 获取带宽以及流量
foreach int in wansDetail:
    intf = int.intf
    cmd = "show flowrate interface " + int.intf
    #print cmd
    res = cli(cmd);
    reg = /Pass Input rate:\s+(\d+) bits\/sec/im
    matchStr = reg.exec(res)
    if matchStr != null:
        passInput = matchStr[1]
        reg1 = /Pass Output rate:\s+(\d+) bits\/sec/im
        matchStr1 = reg1.exec(res)
        if matchStr1 != null:
            passOutput = matchStr1[1]
            cmd1 = "show interface " + int.intf
            res1 = cli(cmd1)
            reg_bw = /BW (\d+) Kbit/im
            match_bw = reg_bw.exec(res1)
            if match_bw != null :
                int_bw = match_bw[1]
                passInputBwRate = passInput / (int_bw * 1000) * 100
                passOutputBwRate = passOutput / (int_bw * 1000) * 100
                if passInputBwRate >=90 || passOutputBwRate >=90 :
                    isProblemFound = true
                    add_problem("bw",[int])
                end
            end
        end
    end
    #print matchStr
end



if isProblemFound == true :
    return 'warn'
else:
    return 'success'
end