[alerter,manager]fixbug 初次探测后影响配置,采集任务状态处理,插入TdEngine时转义问题,开发环境读取探测配置文件时路径错误

Merge pull request !2 from random-chat/fixed_bug_20220209
This commit is contained in:
tomsun28
2022-02-09 09:09:07 +00:00
committed by Gitee
4 changed files with 26 additions and 7 deletions

View File

@@ -78,7 +78,13 @@ public class CalculateAlarm {
.priority(CommonConstants.ALERT_PRIORITY_CODE_EMERGENCY)
.status(CommonConstants.ALERT_STATUS_CODE_PENDING)
.times(1);
if (metricsData.getCode() == CollectRep.Code.UN_REACHABLE) {
if (metricsData.getCode() == CollectRep.Code.UN_AVAILABLE) {
// 采集器不可用
alertBuilder.target(CommonConstants.AVAILABLE)
.content("监控紧急可用性告警: " + metricsData.getCode().name());
triggeredMonitorStateAlertMap.put(monitorId, CollectRep.Code.UN_AVAILABLE);
dataQueue.addAlertData(alertBuilder.build());
} else if (metricsData.getCode() == CollectRep.Code.UN_REACHABLE) {
// UN_REACHABLE 对端不可达(网络层icmp)
alertBuilder.target(CommonConstants.REACHABLE)
.content("监控紧急可达性告警: " + metricsData.getCode().name());
@@ -91,8 +97,11 @@ public class CalculateAlarm {
triggeredMonitorStateAlertMap.put(monitorId, CollectRep.Code.UN_CONNECTABLE);
dataQueue.addAlertData(alertBuilder.build());
} else {
// todo 其它规范异常 TIMEOUT ...
return;
// 其他异常
alertBuilder.target(CommonConstants.AVAILABLE)
.content("监控紧急可用性告警: " + metricsData.getCode().name());
triggeredMonitorStateAlertMap.put(monitorId, metricsData.getCode());
dataQueue.addAlertData(alertBuilder.build());
}
return;
} else {

View File

@@ -2,6 +2,7 @@ package com.usthe.common.entity.job;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.gson.Gson;
import com.usthe.common.entity.message.CollectRep;
import lombok.AllArgsConstructor;
import lombok.Builder;
@@ -180,4 +181,11 @@ public class Job {
}
responseDataTemp.add(metricsData);
}
private static final Gson GSON = new Gson();
public Job clone(){
// 深度克隆
return GSON.fromJson(GSON.toJsonTree(this), Job.class);
}
}

View File

@@ -59,7 +59,7 @@ public class AppServiceImpl implements AppService, CommandLineRunner {
if (appDefine == null) {
throw new IllegalArgumentException("The app " + app + " not support.");
}
return appDefine;
return appDefine.clone();
}
@Override
@@ -123,7 +123,7 @@ public class AppServiceImpl implements AppService, CommandLineRunner {
public void run(String... args) throws Exception {
// 读取app定义配置加载到内存中 define/app/*.yml
Yaml yaml = new Yaml();
String classpath = this.getClass().getResource(File.separator).getPath();
String classpath = this.getClass().getClassLoader().getResource("").getPath();
String defineAppPath = classpath + File.separator + "define" + File.separator + "app";
File directory = new File(defineAppPath);
if (!directory.exists() || directory.listFiles() == null) {

View File

@@ -138,7 +138,7 @@ public class TdEngineDataStorage implements DisposableBean {
if (CommonConstants.NULL_VALUE.equals(value)) {
sqlRowBuffer.append("NULL");
} else {
sqlRowBuffer.append("'").append(value).append("'");
sqlRowBuffer.append("'").append(formatStringValue(value)).append("'");
}
}
if (index != fields.size() - 1) {
@@ -197,7 +197,9 @@ public class TdEngineDataStorage implements DisposableBean {
}
}
private String formatStringValue(String value){
return value.replaceAll("(\\\\)|(')","\\\\$0");
}
@Override
public void destroy() throws Exception {
if (hikariDataSource != null) {