private void processRule(Rule rule) { String id = rule.getId(); int index1 = id.indexOf(":"); int index2 = id.indexOf(":", index1 + 1); String conditions = id.substring(0, index1); String type = id.substring(index1 + 1, index2); String name = id.substring(index2 + 1); int command = Integer.valueOf(conditions.split(";")[0]); Pair<Integer, List<Condition>> pair = queryCheckMinuteAndConditions(rule.getConfigs()); double[] datas = fetchDatas(conditions, type, pair.getKey()); if (datas != null && datas.length > 0) { List<Condition> checkedConditions = pair.getValue(); List<AlertResultEntity> alertResults = m_dataChecker.checkDataForApp(datas, checkedConditions); for (AlertResultEntity alertResult : alertResults) { Map<String, Object> par = new HashMap<String, Object>(); par.put("name", name); AlertEntity entity = new AlertEntity(); entity .setDate(alertResult.getAlertTime()) .setContent(alertResult.getContent()) .setLevel(alertResult.getAlertLevel()); entity .setMetric(queryType(type)) .setType(getName()) .setGroup(queryCommand(command)) .setParas(par); m_sendManager.addAlert(entity); } } }
public void generateRuleConfigContent(String key, BaseRuleConfigManager manager, Model model) { String configsStr = ""; String ruleId = ""; if (!StringUtils.isEmpty(key)) { Rule rule = manager.queryRule(key); if (rule != null) { ruleId = rule.getId(); configsStr = new DefaultJsonBuilder(true).buildArray(rule.getConfigs()); String configHeader = new DefaultJsonBuilder(true).buildArray(rule.getMetricItems()); model.setConfigHeader(configHeader); } } String content = m_ruleDecorator.generateConfigsHtml(configsStr); model.setContent(content); model.setId(ruleId); }