{
    "name"  : "DATA分区空间是否足够",
    "problems" : {
        "noResponse" : {
            "desc"      : "【风险】检查到当前flash空间不足,该问题会导致版本升级失败或新文件无法存储。",
            "advice"    : "【建议】建议删除部分无用问题,存在以下大文件${0}，若点击自动修复可自动删除如下文件或可自行手工删除。自动修复命令：delete flash:xxx.bin" 
        }
    }
}

---------------------------code------------------------------- 
res = cli("show version")
if res.indexOf("11.") == -1:
	return 'success'
end

resTmp = cli("dir flash:")
res = resTmp.split(/\r?\n/ig)
binTmp = []
i = 0
while i < res.length:
	resTmp2 = res[i]
	resTmp2 = resTmp2.trim()
	if resTmp2.indexOf(".bin") != -1:
		bin = resTmp2.split(/\s+/)
		bin = bin[8]
		binTmp.push(bin)
	end
	if resTmp2.indexOf("data total") != -1:
		dataSpace = resTmp2.split(/\s+/)
		dataSpace = dataSpace[0]
		dataSpace = dataSpace.replace(/,/g,'')
        freeSpace = resTmp2.split('(')
		freeSpace = freeSpace[1]
		freeSpace = freeSpace.trim()
		freeSpace = freeSpace.split(' ')
		freeSpace = freeSpace[0]
        freeSpace = freeSpace.replace(/,/g ,"")
		if dataSpace > (20*1024*1024) && freeSpace < (dataSpace * 0.05):
			j = 0
			result = ""
			cmd = ""
			restore_cmd = []
			while j < binTmp.length:
				result = result + "\r\n\t" + binTmp[j]
				cmd = "delete flash:" + binTmp[j]
				restore_cmd.push(cmd)
				j = j + 1
			end
			add_problem('noResponse', [result],restore_cmd, [])
			return 'warn'
		end
	end
	i = i + 1
end
return 'success'