{
    "name"  : "接口负载情况",
    "problems" : {
        "singleError" : {
            "desc"      : "【问题】${0}当前的带宽使用率[${1}]%比较高",
            "advice"    : "【建议】继续检查"
        },
        "allError" : {
            "desc"      : "【问题】当前各个接口的使用率均很高，带宽存在不足",
            "advice"    : "【建议】请配置流控或者更改流控的配置"
        },
        "lepError" : {
            "desc"      : "【问题】${0}与${2}带宽使用不均，接口1的使用率为[${1}]%，接口2的使用率为[${3}]%",
            "advice"    : "【建议】继续检查"
        },
		"noOut" : {
            "desc"      : "【问题】当前无活动的出口线路",
            "advice"    : "【建议】请检查线路是否松动"
        }
    }
}

---------------------------code-------------------------------
#wan_int_info = precondition('wan_int_info')
#if !wan_int_info :
    res = cli('show html interface info')
    interface_info = formatInterfaceInfo(res)
    wan_int_info = []
    foreach int in interface_info :
        if int == undefined :
            continue
        end
        if int.type == 'WAN' && int.ip !='' && int.status == 'UP' :
            int_name = int.intf
            int_name = int_name.replace(/\(.+?\)/i, '');
            int_name = int_name.replace(/di/i, 'dialer ');
            int_name = int_name.replace(/gi/i, 'GigabitEthernet ');
            int['intf'] = int_name
            wan_int_info.push(int)
        end
    end
    set_share_value('wan_int_info', wan_int_info)
    length = wan_int_info.length
    if length == 0 :
        set_share_value('result', 'break')
        add_problem('noOut')
        return 'warn'
    else if length == 1:
        set_share_value('result', 'needless')
        change_title('当前为单出口环境，不需要进行负载均衡')
        return 'success'
    end
#end

isProblemFound = true
max_int_name = null
min_int_name = null
max_int_useage = 0
min_int_useage = 100
foreach int in wan_int_info :
    int_name = int.intf
    cmd = "show interface " + int_name + " | include rate"
    response = cli(cmd)
    data = response.match(/input\srate\s(\d+)\sbits\/sec/i)
    if !data :
        add_reason('无法获取接口带宽情况')
        set_share_value('result', 'break')
        return 'skip'
    end
    data = data[1] / int.bandWidth * 10
    data = parse_int(data)
    data = data / 100
    if data >= 92 :
        add_problem('singleError', [int_name, data])
        return 'warn'
    else if data < 90 :
        isProblemFound = false
    end
    if data > max_int_useage :
        max_int_name = int_name
        max_int_useage = data
    end
    if data < min_int_useage :
        min_int_name = int_name
        min_int_useage = data
    end
end

if isProblemFound :
    add_problem('allError')
    return 'warn'
end

lep = max_int_useage - min_int_useage
if lep > 30 :
    add_problem('lepError', [max_int_name,max_int_useage,min_int_name,min_int_useage])
    return 'warn'
end

set_share_value('result', 'needless')
isLoadFail = precondition('isLoadFail')
#if isLoadFail == true :
#    add_reason('当前负载均衡的效果良好，还存在延迟大或者网页打不开的问题，使用上网慢的规则进行检查)
#else :
#    add_reason('为了更快的上网体验，当前设备接口负载均衡效果良好，建议维持现状')
#end
return 'success'

