交换机管理图形监控只展示端口为up的。
优化frp信息上报
This commit is contained in:
@@ -36,6 +36,9 @@ public class RmFrpcConfigManage extends BaseEntity
|
||||
/** FRPC远程端口 */
|
||||
@Excel(name = "FRPC远程端口")
|
||||
private String frpcRemotePort;
|
||||
/** FRPC远程端口 */
|
||||
@Excel(name = "FRPC远程端口")
|
||||
private String frpcType;
|
||||
|
||||
/** FRPC本地端口 */
|
||||
@Excel(name = "FRPC本地端口")
|
||||
|
||||
@@ -143,8 +143,10 @@ public class MessageHandler {
|
||||
frpcData.setFrpcLocalPort(rsp.getLocalPort());
|
||||
frpcData.setFrpcLocalIp(rsp.getLocalIP());
|
||||
frpcData.setFrpcCreateTime(createTime);
|
||||
frpcData.setCreateTime(DateUtils.getNowDate());
|
||||
frpcData.setFrpcConnectionStatus(2L);
|
||||
frpcData.setFrpcRemotePort(rsp.getRemotePort());
|
||||
frpcData.setFrpcType(rsp.getType());
|
||||
frpcData.setFrpcServerAddr(rsp.getServerAddr());
|
||||
frpcData.setFrpcServerPort(rsp.getServerPort());
|
||||
rmFrpcConfigManageService.insertRmFrpcConfigManage(frpcData);
|
||||
@@ -157,13 +159,14 @@ public class MessageHandler {
|
||||
RmFrpcConfigManage frpcData = new RmFrpcConfigManage();
|
||||
frpcData.setClientId(message.getClientId());
|
||||
frpcData.setFrpcName(rsp.getName());
|
||||
frpcData.setFrpcType(rsp.getType());
|
||||
frpcData.setFrpcStatus(rsp.getIsRunning());
|
||||
frpcData.setFrpcLocalPort(rsp.getLocalPort());
|
||||
frpcData.setFrpcLocalIp(rsp.getLocalIP());
|
||||
frpcData.setFrpcCreateTime(createTime);
|
||||
frpcData.setFrpcRemotePort(rsp.getRemotePort());
|
||||
frpcData.setFrpcServerAddr(rsp.getServerAddr());
|
||||
frpcData.setFrpcServerPort(rsp.getServerPort());
|
||||
frpcData.setUpdateTime(DateUtils.getNowDate());
|
||||
rmFrpcConfigManageService.insertRmFrpcConfigManage(frpcData);
|
||||
} else{
|
||||
if(rsp.getRemotePort() != null){
|
||||
|
||||
+2
@@ -67,4 +67,6 @@ public interface InitialSwitchOtherCollectDataMapper
|
||||
* @return
|
||||
*/
|
||||
Map getSwitchMonitorMsg(InitialSwitchOtherCollectData initialSwitchOtherCollectData);
|
||||
|
||||
void deleteInitialSwitchOtherCollectData(InitialSwitchOtherCollectData deleteData);
|
||||
}
|
||||
|
||||
+2
@@ -88,4 +88,6 @@ public interface IInitialSwitchOtherCollectDataService
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> getSwitchMemUseMsg(InitialSwitchOtherCollectData initialSwitchOtherCollectData);
|
||||
|
||||
void deleteInitialSwitchOtherCollectData(InitialSwitchOtherCollectData deleteData);
|
||||
}
|
||||
|
||||
+5
@@ -196,4 +196,9 @@ public class InitialSwitchOtherCollectDataServiceImpl implements IInitialSwitchO
|
||||
|
||||
return EchartsDataUtils.buildEchartsData(list,InitialSwitchOtherCollectData::getCreateTime, extractors);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteInitialSwitchOtherCollectData(InitialSwitchOtherCollectData deleteData) {
|
||||
initialSwitchOtherCollectDataMapper.deleteInitialSwitchOtherCollectData(deleteData);
|
||||
}
|
||||
}
|
||||
|
||||
-1
@@ -115,7 +115,6 @@ public class RmFrpcConfigManageServiceImpl implements IRmFrpcConfigManageService
|
||||
@Override
|
||||
public int insertRmFrpcConfigManage(RmFrpcConfigManage rmFrpcConfigManage)
|
||||
{
|
||||
rmFrpcConfigManage.setCreateTime(DateUtils.getNowDate());
|
||||
int rows = rmFrpcConfigManageMapper.insertRmFrpcConfigManage(rmFrpcConfigManage);
|
||||
return 1;
|
||||
}
|
||||
|
||||
+46
-27
@@ -18,10 +18,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -93,7 +90,7 @@ public class ProcessSwitchCollectDataService {
|
||||
|
||||
// 设置基本信息
|
||||
long timestamp = switchDataVo.getTimestamp();
|
||||
Date createTime = new Date(timestamp * 1000 / 1000 * 1000);
|
||||
Date createTime = new Date(timestamp * 1000);
|
||||
insertData.setClientId(clientId);
|
||||
insertData.setCreateTime(createTime);
|
||||
|
||||
@@ -104,6 +101,9 @@ public class ProcessSwitchCollectDataService {
|
||||
if (jsonNode.isArray() && jsonNode.size() > 0) {
|
||||
JsonNode firstElement = jsonNode.get(0);
|
||||
|
||||
String collectType = null;
|
||||
String collectValue = null;
|
||||
|
||||
if (firstElement.isTextual()) {
|
||||
// 二次解析JSON字符串
|
||||
JsonNode innerJsonNode = objectMapper.readTree(firstElement.asText());
|
||||
@@ -112,32 +112,51 @@ public class ProcessSwitchCollectDataService {
|
||||
Iterator<Map.Entry<String, JsonNode>> fields = innerJsonNode.fields();
|
||||
if (fields.hasNext()) {
|
||||
Map.Entry<String, JsonNode> entry = fields.next();
|
||||
String fieldName = entry.getKey();
|
||||
String fieldValue = entry.getValue().asText();
|
||||
|
||||
insertData.setCollectType(fieldName);
|
||||
if (!"null".equals(fieldValue)) {
|
||||
insertData.setCollectValue(fieldValue);
|
||||
insertInitialSwitchOtherInfo.insertInitialSwitchOtherCollectData(insertData);
|
||||
}
|
||||
collectType = entry.getKey();
|
||||
collectValue = entry.getValue().asText();
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if (firstElement.isObject()) {
|
||||
Iterator<Map.Entry<String, JsonNode>> fields = firstElement.fields();
|
||||
if (fields.hasNext()) {
|
||||
Map.Entry<String, JsonNode> entry = fields.next();
|
||||
String fieldName = entry.getKey();
|
||||
String fieldValue = entry.getValue().asText();
|
||||
|
||||
insertData.setCollectType(fieldName);
|
||||
if (!"null".equals(fieldValue)) {
|
||||
insertData.setCollectValue(fieldValue);
|
||||
insertInitialSwitchOtherInfo.insertInitialSwitchOtherCollectData(insertData);
|
||||
}
|
||||
}
|
||||
} else if (firstElement.isObject()) {
|
||||
Iterator<Map.Entry<String, JsonNode>> fields = firstElement.fields();
|
||||
if (fields.hasNext()) {
|
||||
Map.Entry<String, JsonNode> entry = fields.next();
|
||||
collectType = entry.getKey();
|
||||
collectValue = entry.getValue().asText();
|
||||
}
|
||||
}
|
||||
|
||||
if (collectType != null && !"null".equals(collectValue)) {
|
||||
// 定义需要先删后插的collectType列表
|
||||
List<String> specialCollectTypes = Arrays.asList(
|
||||
"sysDescr",
|
||||
"sysObjectID",
|
||||
"sysUpTime",
|
||||
"sysContact",
|
||||
"sysName",
|
||||
"sysLocation",
|
||||
"hwStackSystemMac",
|
||||
"entIndex",
|
||||
"entPhysicalName",
|
||||
"entPhysicalSoftwareRev"
|
||||
);
|
||||
|
||||
// 如果collectType在特殊列表中,先删除相同clientId和时间范围内的记录
|
||||
if (specialCollectTypes.contains(collectType)) {
|
||||
// 创建删除条件对象
|
||||
InitialSwitchOtherCollectData deleteData = new InitialSwitchOtherCollectData();
|
||||
deleteData.setClientId(clientId);
|
||||
deleteData.setCollectType(collectType);
|
||||
deleteData.setCreateTime(createTime);
|
||||
|
||||
// 调用删除方法
|
||||
insertInitialSwitchOtherInfo.deleteInitialSwitchOtherCollectData(deleteData);
|
||||
}
|
||||
|
||||
// 插入新数据
|
||||
insertData.setCollectType(collectType);
|
||||
insertData.setCollectValue(collectValue);
|
||||
insertInitialSwitchOtherInfo.insertInitialSwitchOtherCollectData(insertData);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
+15
@@ -102,4 +102,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
) latest ON t.collect_type = latest.collect_type AND t.create_time = latest.max_time
|
||||
WHERE t.client_id = #{clientId}
|
||||
</select>
|
||||
<delete id="deleteInitialSwitchOtherCollectData" parameterType="Long">
|
||||
delete from initial_switch_other_collect_data
|
||||
<where>
|
||||
<choose>
|
||||
<when test="clientId != null and collectType != null and createTime != null">
|
||||
AND client_id = #{clientId}
|
||||
AND collect_type = #{collectType}
|
||||
AND create_time < #{createTime}
|
||||
</when>
|
||||
<otherwise>
|
||||
and 1=0
|
||||
</otherwise>
|
||||
</choose>
|
||||
</where>
|
||||
</delete>
|
||||
</mapper>
|
||||
@@ -11,6 +11,7 @@
|
||||
<result property="frpcServerPort" column="frpc_server_port" />
|
||||
<result property="frpcRemotePort" column="frpc_remote_port" />
|
||||
<result property="frpcLocalPort" column="frpc_local_port" />
|
||||
<result property="frpcType" column="frpc_type" />
|
||||
<result property="frpcName" column="frpc_name" />
|
||||
<result property="frpcConnectionStatus" column="frpc_connection_status" />
|
||||
<result property="frpcCreateTime" column="frpc_create_time" />
|
||||
@@ -23,7 +24,7 @@
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectRmFrpcConfigManageVo">
|
||||
select id, client_id, frpc_server_addr, frpc_server_port, frpc_remote_port, frpc_local_port, frpc_name, frpc_connection_status, frpc_create_time, create_time, update_time, create_by, update_by, frpc_local_ip, frpc_status from rm_frpc_config_manage
|
||||
select id, client_id, frpc_server_addr, frpc_server_port, frpc_remote_port, frpc_local_port, frpc_type, frpc_name, frpc_connection_status, frpc_create_time, create_time, update_time, create_by, update_by, frpc_local_ip, frpc_status from rm_frpc_config_manage
|
||||
</sql>
|
||||
|
||||
<select id="selectRmFrpcConfigManageList" parameterType="RmFrpcConfigManage" resultMap="RmFrpcConfigManageResult">
|
||||
@@ -64,6 +65,7 @@
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="frpcLocalIp != null">frpc_local_ip,</if>
|
||||
<if test="frpcStatus != null">frpc_status,</if>
|
||||
<if test="frpcType != null">frpc_type,</if>
|
||||
</trim>
|
||||
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
|
||||
<if test="clientId != null">#{clientId},</if>
|
||||
@@ -80,10 +82,10 @@
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="frpcLocalIp != null">#{frpcLocalIp},</if>
|
||||
<if test="frpcStatus != null">#{frpcStatus},</if>
|
||||
<if test="frpcType != null">#{frpcType},</if>
|
||||
</trim>
|
||||
ON DUPLICATE KEY UPDATE
|
||||
<trim suffixOverrides=",">
|
||||
<if test="clientId != null">client_id = VALUES(client_id),</if>
|
||||
<if test="frpcServerAddr != null">frpc_server_addr = VALUES(frpc_server_addr),</if>
|
||||
<if test="frpcServerPort != null">frpc_server_port = VALUES(frpc_server_port),</if>
|
||||
<if test="frpcRemotePort != null">frpc_remote_port = VALUES(frpc_remote_port),</if>
|
||||
@@ -91,11 +93,11 @@
|
||||
<if test="frpcName != null">frpc_name = VALUES(frpc_name),</if>
|
||||
<if test="frpcConnectionStatus != null">frpc_connection_status = VALUES(frpc_connection_status),</if>
|
||||
<if test="frpcCreateTime != null">frpc_create_time = VALUES(frpc_create_time),</if>
|
||||
<!-- 通常更新时间字段在更新时会设置为当前时间 -->
|
||||
update_time = NOW(),
|
||||
<if test="updateTime != null">update_time = VALUES(update_time),</if>
|
||||
<if test="updateBy != null">update_by = VALUES(update_by),</if>
|
||||
<if test="frpcLocalIp != null">frpc_local_ip = VALUES(frpc_local_ip),</if>
|
||||
<if test="frpcStatus != null">frpc_status = VALUES(frpc_status),</if>
|
||||
<if test="frpcType != null">frpc_type = VALUES(frpc_type),</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
@@ -116,6 +118,7 @@
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="frpcLocalIp != null">frpc_local_ip = #{frpcLocalIp},</if>
|
||||
<if test="frpcStatus != null">frpc_status = #{frpcStatus},</if>
|
||||
<if test="frpcType != null">frpc_type = #{frpcType},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
Reference in New Issue
Block a user