
{
    "name"  : "中断异常检测",
    "problems" : {
        "irq" : {
            "desc"      : "【问题】中断异常。",
            "advice"    : "【建议】检查IRQ。"
        }
    }
}

---------------------------code-------------------------------
result = 'pass'
value = 0
i = 5
while i>=1 :
	if i != 5:
		sleep(10000)
	end
	cli('run-system-shell')
	log_irq = cli('cat /proc/stat')
	cli('exit')
	log_irqList = log_irq.split('\r\n')
	#cpu  406766 0 10521974 198019459 9155 9309 5418813 0 0
	#cpu  541893 0 33201937 159230535 33701 3118 5005932 0 0
	reg = /cpu\s+(\d+)\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+/
	foreach data in log_irqList:
		r = data.match(reg)
		if r != null && i != 5:
			value_current = r[1]
			if value != 0:
				if isOver(value,value_current):
					result = 'fail'
				end
			end
			value = value_current
		end
	end
	i = i -1
end
if result == 'fail' :
    add_problem('irq')
    return 'warn'
end

return 'success'

def isOver(value1,value2):
	result = 0
	value = value2/value1
	if value>1.3:
		result = 1
	end
	return result
end

