diff options
| author | shizhendong <[email protected]> | 2023-12-15 10:57:15 +0800 |
|---|---|---|
| committer | shizhendong <[email protected]> | 2023-12-15 10:57:15 +0800 |
| commit | 0c5888914388f80e7252056be51812cc08507215 (patch) | |
| tree | 89eac9987831ffc68d8d8501c95ea891b2d26424 | |
| parent | 07ec2664df9ad5e46c62d8be549743231ca72f10 (diff) | |
fix: 取消 redis key support_alert_agent_idgraalvmdev-graalvm
| -rw-r--r-- | nz-admin/src/main/java/com/nis/modules/agent/job/AgentConfigUtil.java | 10 | ||||
| -rw-r--r-- | nz-admin/src/main/java/com/nis/modules/agent/job/AutoConfigAgentJob.java | 22 |
2 files changed, 12 insertions, 20 deletions
diff --git a/nz-admin/src/main/java/com/nis/modules/agent/job/AgentConfigUtil.java b/nz-admin/src/main/java/com/nis/modules/agent/job/AgentConfigUtil.java index f18975ce..22c02f47 100644 --- a/nz-admin/src/main/java/com/nis/modules/agent/job/AgentConfigUtil.java +++ b/nz-admin/src/main/java/com/nis/modules/agent/job/AgentConfigUtil.java @@ -193,10 +193,9 @@ public class AgentConfigUtil { * * @param agent * @param globalAgentList - * @param isAlert * @return */ - public Map generateCortexYml(Agent agent, List<Agent> globalAgentList, Boolean isAlert) { + public Map generateCortexYml(Agent agent, List<Agent> globalAgentList) { log.debug("cortex.yml 开始生成"); Map params = new LinkedHashMap(8); @@ -228,8 +227,7 @@ public class AgentConfigUtil { TimedCache<String, Object> sysConfiMap = TimedCacheManager.getNeverExpireCache(Constant.SYS_CACHE_PREFIX, Constant.SYS_CONFIG_CACHE_KEY); params.put("systemConfig", sysConfiMap); - - params.put("isAlert", isAlert); + params.put("isAlert", false); Map map = new HashMap(); String content = ""; @@ -304,7 +302,7 @@ public class AgentConfigUtil { * @param healthyAgents * @return */ - public Integer getSupportAlertPromId(List<Agent> healthyAgents) { + /*public Integer getSupportAlertPromId(List<Agent> healthyAgents) { Object supportAlertPromId = redisTemplate.opsForValue().get(Constant.REDIS_KEY_SUPPORT_ALERT_AGENT_ID); supportAlertPromId = ToolUtil.isEmpty(supportAlertPromId) ? "" : supportAlertPromId; @@ -326,7 +324,7 @@ public class AgentConfigUtil { supportAlertPromId.toString()); } return Integer.valueOf(supportAlertPromId.toString()); - } + }*/ /** * 组装 snmp.yml diff --git a/nz-admin/src/main/java/com/nis/modules/agent/job/AutoConfigAgentJob.java b/nz-admin/src/main/java/com/nis/modules/agent/job/AutoConfigAgentJob.java index 05a00245..48181cd2 100644 --- a/nz-admin/src/main/java/com/nis/modules/agent/job/AutoConfigAgentJob.java +++ b/nz-admin/src/main/java/com/nis/modules/agent/job/AutoConfigAgentJob.java @@ -211,11 +211,11 @@ public class AutoConfigAgentJob extends QuartzJobBean { boolean cortexChangeFlag = configUtil.compareDataChanges("cortex"); log.info("[setUpAgentConfig] [conf_event cortex state] [change: {}]", cortexChangeFlag); - boolean ruleChangeFlag = configUtil.compareDataChanges("rule"); - log.info("[setUpAgentConfig] [conf_event rule state] [change: {}]", ruleChangeFlag); +// boolean ruleChangeFlag = configUtil.compareDataChanges("rule"); +// log.info("[setUpAgentConfig] [conf_event rule state] [change: {}]", ruleChangeFlag); // 是否更新 rule.yml 配置 - String alertConfUpdate = sysConfService.getValue("nz_alert_rule_eval_enable"); +// String alertConfUpdate = sysConfService.getValue("nz_alert_rule_eval_enable"); // Map alertYmlMap = configUtil.generateRuleYml(); // if (ruleChangeFlag && StrUtil.equals("0", StrUtil.emptyToDefault(alertConfUpdate, "1"))) { // // 生成 alert.yml @@ -695,7 +695,7 @@ public class AutoConfigAgentJob extends QuartzJobBean { * @param alertYmlMap * @param healthyPromServers */ - private void justUpdateRuleConf(Map alertYmlMap, List<Agent> healthyPromServers) { + /*private void justUpdateRuleConf(Map alertYmlMap, List<Agent> healthyPromServers) { // 先判断 redis 中是否存在 alert 告警标识 Boolean aBoolean = redisTemplate.hasKey(Constant.REDIS_KEY_SUPPORT_ALERT_AGENT_ID); Integer supportAlertPromId = configUtil.getSupportAlertPromId(healthyPromServers); @@ -726,12 +726,11 @@ public class AutoConfigAgentJob extends QuartzJobBean { } else { configUtil.afterRequestApi(path, result, agent); } - } + }*/ /** * cortex 配置下发 * - * @param alertYmlMap * @param healthyAgents */ private void updateCortexConf(List<Agent> healthyAgents) { @@ -747,20 +746,15 @@ public class AutoConfigAgentJob extends QuartzJobBean { // healthy agent config cortex.yml ThreadUtil.execAsync(() -> { - // 获取当前支持 alert 的 agent id - Integer supportAlertPromId = configUtil.getSupportAlertPromId(healthyAgents); - // 调用 agent/cortex 接口 更新 cortex config and rule.yml + // 调用 agent/cortex 接口 更新 cortex config List<Agent> globalAgentList = healthyAgents.stream().filter(pojo -> ObjectUtil.equal(Constant.AgentType.GLOBAL.getValue(), pojo.getType())).collect(Collectors.toList()); for (Agent agent : globalAgentList) { - Boolean isAlert = ObjectUtil.equal(agent.getId(), supportAlertPromId); // generate Cortex Yml - Map cortexYml = configUtil.generateCortexYml(agent, globalAgentList, isAlert); + Map cortexYml = configUtil.generateCortexYml(agent, globalAgentList); Map<String, Object> cortexConfigBody = new HashMap<>(4); cortexConfigBody.put("config", cortexYml); -// if ((supportAlertPromId == null || agent.getId().equals(supportAlertPromId)) && MapUtil.isNotEmpty(alertYmlMap)) { -// cortexConfigBody.put("rule", alertYmlMap); -// } + String result = null; String path = "/cortex/config"; try { |
