1、适配部署环境变量自动注入
2、适配南网达梦数据库安全版SQL语句Group by 不支持自定义函数 3、达梦数据库驱动改为达梦提供的指定版本 4、修改syslog-consumer模块yaml 文件kafka 变量名称 5、修改访问日志告警表新增4个字段,完善异常行为详情页面显示字段
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
package com.haobang.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 应用配置属性 - 替代静态 AppConfig(syslog-serve 模块)
|
||||
* 使用 Spring Boot 标准 @Value 机制,支持 docker-compose 环境变量覆盖
|
||||
*/
|
||||
@Data
|
||||
@Component
|
||||
public class AppProperties {
|
||||
|
||||
// ========== Syslog 配置 ==========
|
||||
@Value("${syslog.tcp.port:514}")
|
||||
private int syslogTcpPort;
|
||||
|
||||
@Value("${syslog.udp.port:515}")
|
||||
private int syslogUdpPort;
|
||||
|
||||
@Value("${syslog.max.frame.length:65536}")
|
||||
private int syslogMaxFrameLength;
|
||||
|
||||
@Value("${syslog.buffer.size:1024}")
|
||||
private int syslogBufferSize;
|
||||
|
||||
@Value("${syslog.charset:GBK}")
|
||||
private String syslogCharset;
|
||||
|
||||
// ========== App Service 配置(探针设备信息)==========
|
||||
@Value("${app.service.device_id:}")
|
||||
private String appServiceDeviceId;
|
||||
|
||||
@Value("${app.service.device_name:}")
|
||||
private String appServiceDeviceName;
|
||||
|
||||
@Value("${app.service.vendor:}")
|
||||
private String appServiceVendor;
|
||||
|
||||
@Value("${app.service.product_name:}")
|
||||
private String appServiceProductName;
|
||||
|
||||
@Value("${app.service.data_type:json}")
|
||||
private String appServiceDataType;
|
||||
|
||||
@Value("${app.service.device_collect_id:1}")
|
||||
private int appServiceDeviceCollectId;
|
||||
|
||||
// ========== Kafka Producer 配置 ==========
|
||||
@Value("${spring.kafka.producer.bootstrap-servers:localhost:9092}")
|
||||
private String kafkaProducerBootstrap;
|
||||
|
||||
@Value("${spring.kafka.producer.topic:agent-syslog-topic}")
|
||||
private String kafkaProducerTopic;
|
||||
|
||||
// ========== SM4 加密配置 ==========
|
||||
@Value("${syslog.sm4.generateKey:}")
|
||||
private String sm4Key;
|
||||
}
|
||||
+18
-10
@@ -3,7 +3,8 @@ package com.haobang.util;
|
||||
|
||||
import com.common.entity.DeviceDevice;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.haobang.config.AppConfig;
|
||||
import com.haobang.config.AppProperties;
|
||||
import com.haobang.util.SpringContextUtil;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
@@ -11,6 +12,10 @@ import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
public class DeviceInfoUtil {
|
||||
|
||||
private static AppProperties getProps() {
|
||||
return SpringContextUtil.getBean(AppProperties.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 补充设备配置信息 key value值
|
||||
* @param strSyslog
|
||||
@@ -18,6 +23,7 @@ public class DeviceInfoUtil {
|
||||
*/
|
||||
public static String getFullLogString(String strSyslog)
|
||||
{
|
||||
AppProperties appProps = getProps();
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
// 创建设备配置信息MAP
|
||||
// 获取当前时间(精度到毫秒)
|
||||
@@ -29,11 +35,11 @@ public class DeviceInfoUtil {
|
||||
|
||||
Map<String, String> map = new LinkedHashMap<>();
|
||||
map.put("receive_time",timeString);
|
||||
map.put("device_id", AppConfig.getAppServieDeviceId());
|
||||
map.put("device_name", AppConfig.getAppServieDeviceName());
|
||||
map.put("vendor", AppConfig.getAppServieVendor());
|
||||
map.put("data_type", AppConfig.getAppServieDataType());
|
||||
map.put("device_collect_id", Long.toString(AppConfig.getDeviceCollectId()));
|
||||
map.put("device_id", appProps.getAppServiceDeviceId());
|
||||
map.put("device_name", appProps.getAppServiceDeviceName());
|
||||
map.put("vendor", appProps.getAppServiceVendor());
|
||||
map.put("data_type", appProps.getAppServiceDataType());
|
||||
map.put("device_collect_id", Long.toString(appProps.getAppServiceDeviceCollectId()));
|
||||
|
||||
String formattedString = formatDeviceInfo(map);
|
||||
//return formattedString + "" + strSyslog.substring(34);
|
||||
@@ -48,6 +54,7 @@ public class DeviceInfoUtil {
|
||||
*/
|
||||
public static String getFullLogString(DeviceDevice deviceDevice,String strSyslog)
|
||||
{
|
||||
AppProperties appProps = getProps();
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
// 创建设备配置信息MAP
|
||||
// 获取当前时间(精度到毫秒)
|
||||
@@ -61,8 +68,8 @@ public class DeviceInfoUtil {
|
||||
map.put("device_id",deviceDevice.getId().toString());
|
||||
map.put("device_name", deviceDevice.getName());
|
||||
map.put("vendor", deviceDevice.getVendor());
|
||||
map.put("data_type", AppConfig.getAppServieDataType());
|
||||
map.put("device_collect_id", Long.toString(AppConfig.getDeviceCollectId()));
|
||||
map.put("data_type", appProps.getAppServiceDataType());
|
||||
map.put("device_collect_id", Long.toString(appProps.getAppServiceDeviceCollectId()));
|
||||
String formattedString = formatDeviceInfo(map);
|
||||
//return formattedString + "" + strSyslog.substring(34);
|
||||
//测试环境截取34位之后字符串
|
||||
@@ -71,6 +78,7 @@ public class DeviceInfoUtil {
|
||||
|
||||
public static String getFullLogString(DeviceDevice deviceDevice,String strSyslog,String receive_time)
|
||||
{
|
||||
AppProperties appProps = getProps();
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
// 创建设备配置信息MAP
|
||||
// 获取当前时间(精度到毫秒)
|
||||
@@ -84,8 +92,8 @@ public class DeviceInfoUtil {
|
||||
map.put("device_id",deviceDevice.getId().toString());
|
||||
map.put("device_name", deviceDevice.getName());
|
||||
map.put("vendor", deviceDevice.getVendor());
|
||||
map.put("data_type", AppConfig.getAppServieDataType());
|
||||
map.put("device_collect_id", Long.toString(AppConfig.getDeviceCollectId()));
|
||||
map.put("data_type", appProps.getAppServiceDataType());
|
||||
map.put("device_collect_id", Long.toString(appProps.getAppServiceDeviceCollectId()));
|
||||
String formattedString = formatDeviceInfo(map);
|
||||
//return formattedString + "" + strSyslog.substring(34);
|
||||
//测试环境截取34位之后字符串
|
||||
|
||||
Reference in New Issue
Block a user