
{
    "name"  : "消息通路异常",
    "problems" : {
        "dcm" : {
            "desc"      : "【问题】进程${0}出现DCM消息通路异常。",
            "advice"    : "【建议】检查DCM消息通路。"
        }
    }
}

---------------------------code-------------------------------
result = 'pass'
port = ''
log_cpu = cli('show cpu')
log_cpuList = log_cpu.split('\r\n')
reg = /(\d+)\s+[^ ]+%\s+[^ ]+%\s+([^ ]+)%\s+([^ ]+)/
foreach data in log_cpuList:
	r = data.match(reg)
	if r != null:
		id = r[1]
		value = r[2]
		proc_name = r[3]
		if value >= 30:
			if isFail(id):
				port = port + proc_name + '、'
				result = 'fail'
			end
		end
	end
end

if result == 'fail' :
    add_problem('dcm',[port])
    return 'warn'
end

return 'success'

def isFail(id):
	result = 0
	cli('run-system-shell')
	cmd_proc = format('cd proc/%s/fd',id)
	cli(cmd_proc)
	log_ls = cli('ls')
	cli('exit')
	count = GetNum(log_ls)
	if count > 300:
		result = 1
	end
	return result
end

def GetNum(str):
	count = 0
	lineList = str.split(';')
	foreach num in lineList:
		count = count + 1
	end
	return count
end

