{
    "name"  : "vty资源是否被占满",
    "problems" : {
        "fullVty" : {
            "desc"      : "【问题】vty资源被占满",
            "advice"    : ["【建议】修改vty配置或清除已经登陆的用户"
                          ,"配置示例："
                          ,"\tRuijie# clear line vty X"]
        }
    }
}
---------------------------code-------------------------------
#vty资源是否被占满

STARTNUM = 1

response = cli('show run | in line vty')
results = response.split(/\r?\n/ig)
exist = false
vty_num = 0
i = STARTNUM
while i < results.length :
    resultsTemp = results[i]
    if resultsTemp.search('line vty') != -1 :
        arr = resultsTemp.trim()
        arr = arr.split(' ')
        num1 = arr[2]
        num2 = arr[3]
        if num2 == undefined :
            vty_num = vty_num + 1
        else : 
            vty_num = vty_num + num2 - num1 + 1
        end
    end
    i = i + 1
end
response = cli('show users | in vty') 
results = response.split(/\r?\n/ig)
exist = false
user_num = results.length - STARTNUM - 1
if user_num >= vty_num :
    add_problem('fullVty')
    return 'warn'
end
return 'success'







