[alerter,manager]fixbug 初次探测后影响配置,采集任务状态处理,插入TdEngine时转义问题,开发环境读取探测配置文件时路径错误
Merge pull request !2 from random-chat/fixed_bug_20220209
This commit is contained in:
@@ -78,7 +78,13 @@ public class CalculateAlarm {
|
|||||||
.priority(CommonConstants.ALERT_PRIORITY_CODE_EMERGENCY)
|
.priority(CommonConstants.ALERT_PRIORITY_CODE_EMERGENCY)
|
||||||
.status(CommonConstants.ALERT_STATUS_CODE_PENDING)
|
.status(CommonConstants.ALERT_STATUS_CODE_PENDING)
|
||||||
.times(1);
|
.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)
|
// UN_REACHABLE 对端不可达(网络层icmp)
|
||||||
alertBuilder.target(CommonConstants.REACHABLE)
|
alertBuilder.target(CommonConstants.REACHABLE)
|
||||||
.content("监控紧急可达性告警: " + metricsData.getCode().name());
|
.content("监控紧急可达性告警: " + metricsData.getCode().name());
|
||||||
@@ -91,8 +97,11 @@ public class CalculateAlarm {
|
|||||||
triggeredMonitorStateAlertMap.put(monitorId, CollectRep.Code.UN_CONNECTABLE);
|
triggeredMonitorStateAlertMap.put(monitorId, CollectRep.Code.UN_CONNECTABLE);
|
||||||
dataQueue.addAlertData(alertBuilder.build());
|
dataQueue.addAlertData(alertBuilder.build());
|
||||||
} else {
|
} else {
|
||||||
// todo 其它规范异常 TIMEOUT ...
|
// 其他异常
|
||||||
return;
|
alertBuilder.target(CommonConstants.AVAILABLE)
|
||||||
|
.content("监控紧急可用性告警: " + metricsData.getCode().name());
|
||||||
|
triggeredMonitorStateAlertMap.put(monitorId, metricsData.getCode());
|
||||||
|
dataQueue.addAlertData(alertBuilder.build());
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.usthe.common.entity.job;
|
|||||||
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.google.gson.Gson;
|
||||||
import com.usthe.common.entity.message.CollectRep;
|
import com.usthe.common.entity.message.CollectRep;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
@@ -180,4 +181,11 @@ public class Job {
|
|||||||
}
|
}
|
||||||
responseDataTemp.add(metricsData);
|
responseDataTemp.add(metricsData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final Gson GSON = new Gson();
|
||||||
|
|
||||||
|
public Job clone(){
|
||||||
|
// 深度克隆
|
||||||
|
return GSON.fromJson(GSON.toJsonTree(this), Job.class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ public class AppServiceImpl implements AppService, CommandLineRunner {
|
|||||||
if (appDefine == null) {
|
if (appDefine == null) {
|
||||||
throw new IllegalArgumentException("The app " + app + " not support.");
|
throw new IllegalArgumentException("The app " + app + " not support.");
|
||||||
}
|
}
|
||||||
return appDefine;
|
return appDefine.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -123,7 +123,7 @@ public class AppServiceImpl implements AppService, CommandLineRunner {
|
|||||||
public void run(String... args) throws Exception {
|
public void run(String... args) throws Exception {
|
||||||
// 读取app定义配置加载到内存中 define/app/*.yml
|
// 读取app定义配置加载到内存中 define/app/*.yml
|
||||||
Yaml yaml = new Yaml();
|
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";
|
String defineAppPath = classpath + File.separator + "define" + File.separator + "app";
|
||||||
File directory = new File(defineAppPath);
|
File directory = new File(defineAppPath);
|
||||||
if (!directory.exists() || directory.listFiles() == null) {
|
if (!directory.exists() || directory.listFiles() == null) {
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ public class TdEngineDataStorage implements DisposableBean {
|
|||||||
if (CommonConstants.NULL_VALUE.equals(value)) {
|
if (CommonConstants.NULL_VALUE.equals(value)) {
|
||||||
sqlRowBuffer.append("NULL");
|
sqlRowBuffer.append("NULL");
|
||||||
} else {
|
} else {
|
||||||
sqlRowBuffer.append("'").append(value).append("'");
|
sqlRowBuffer.append("'").append(formatStringValue(value)).append("'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (index != fields.size() - 1) {
|
if (index != fields.size() - 1) {
|
||||||
@@ -197,7 +197,9 @@ public class TdEngineDataStorage implements DisposableBean {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String formatStringValue(String value){
|
||||||
|
return value.replaceAll("(\\\\)|(')","\\\\$0");
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public void destroy() throws Exception {
|
public void destroy() throws Exception {
|
||||||
if (hikariDataSource != null) {
|
if (hikariDataSource != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user