优化mtr探测策略、增加ipv6相关字段

This commit is contained in:
gaoyutao
2025-12-01 18:15:46 +08:00
parent ed6c0a4c80
commit 7d26d2fb3b
10 changed files with 150 additions and 212 deletions
@@ -44,6 +44,8 @@ public class RmMtrProbeResult extends BaseEntity
private String startTime;
/** 结束时间 */
private String endTime;
/** 每跳分析结果 */
private String hopResult;
@@ -105,6 +105,7 @@ public class MessageHandler {
rmMtrProbeResult.setMtrClientId(mtrClientId);
rmMtrProbeResult.setPublicIp(mtrResultVo.getTargetIp());
rmMtrProbeResult.setPacketLossRate(new BigDecimal(mtrResultVo.getFinalLossPercent()));
rmMtrProbeResult.setHopResult(JSONObject.toJSONString(mtrResultVo.getHopInfos()));
rmMtrProbeResultList.add(rmMtrProbeResult);
AllMtrClient allMtrClient = new AllMtrClient();
BeanUtils.copyProperties(rmMtrProbeResult, allMtrClient);
@@ -207,6 +207,11 @@ public class RmMtrProbeResultServiceImpl implements IRmMtrProbeResultService
info != null && info.getPacketLossRate() != null ?
info.getPacketLossRate() :
0);
// 每一跳的分析结果
extractors.put("deployDevice", info ->
info != null && info.getHopResult() != null ?
info.getHopResult() :
null);
Map<String, Object> resultMap = EchartsDataUtils.buildEchartsDataAutoPadding(
list, RmMtrProbeResult::getCreateTime, extractors, rmMtrProbeResult.getStartTime(), rmMtrProbeResult.getEndTime()
);
@@ -3,7 +3,7 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tongran.mtragent.mapper.RmMtrProbeResultMapper">
<resultMap type="RmMtrProbeResult" id="RmMtrProbeResultResult">
<result property="id" column="id" />
<result property="mtrClientId" column="mtr_client_id" />
@@ -14,22 +14,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateTime" column="update_time" />
<result property="createBy" column="create_by" />
<result property="updateBy" column="update_by" />
<result property="hopResult" column="hop_result" />
</resultMap>
<sql id="selectRmMtrProbeResultVo">
select id, mtr_client_id, client_id, public_ip, packet_loss_rate, create_time, update_time, create_by, update_by from rm_mtr_probe_result
select id, mtr_client_id, client_id, public_ip, packet_loss_rate, create_time, update_time, create_by, update_by, hop_result from rm_mtr_probe_result
</sql>
<select id="selectRmMtrProbeResultList" parameterType="RmMtrProbeResult" resultMap="RmMtrProbeResultResult">
<include refid="selectRmMtrProbeResultVo"/>
<where>
<where>
<if test="mtrClientId != null and mtrClientId != ''"> and mtr_client_id = #{mtrClientId}</if>
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
<if test="publicIp != null and publicIp != ''"> and public_ip = #{publicIp}</if>
<if test="packetLossRate != null "> and packet_loss_rate = #{packetLossRate}</if>
<if test="hopResult != null and hopResult != ''"> and hop_result = #{hopResult}</if>
</where>
</select>
<select id="selectRmMtrProbeResultById" parameterType="Long" resultMap="RmMtrProbeResultResult">
<include refid="selectRmMtrProbeResultVo"/>
where id = #{id}
@@ -38,38 +40,41 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="insertRmMtrProbeResult" parameterType="RmMtrProbeResult" useGeneratedKeys="true" keyProperty="id">
insert into rm_mtr_probe_result
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="mtrClientId != null and mtrClientId != ''">mtr_client_id,</if>
<if test="clientId != null and clientId != ''">client_id,</if>
<if test="publicIp != null and publicIp != ''">public_ip,</if>
<if test="mtrClientId != null">mtr_client_id,</if>
<if test="clientId != null">client_id,</if>
<if test="publicIp != null">public_ip,</if>
<if test="packetLossRate != null">packet_loss_rate,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="createBy != null">create_by,</if>
<if test="updateBy != null">update_by,</if>
</trim>
<if test="hopResult != null">hop_result,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="mtrClientId != null and mtrClientId != ''">#{mtrClientId},</if>
<if test="clientId != null and clientId != ''">#{clientId},</if>
<if test="publicIp != null and publicIp != ''">#{publicIp},</if>
<if test="mtrClientId != null">#{mtrClientId},</if>
<if test="clientId != null">#{clientId},</if>
<if test="publicIp != null">#{publicIp},</if>
<if test="packetLossRate != null">#{packetLossRate},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateBy != null">#{updateBy},</if>
</trim>
<if test="hopResult != null">#{hopResult},</if>
</trim>
</insert>
<update id="updateRmMtrProbeResult" parameterType="RmMtrProbeResult">
update rm_mtr_probe_result
<trim prefix="SET" suffixOverrides=",">
<if test="mtrClientId != null and mtrClientId != ''">mtr_client_id = #{mtrClientId},</if>
<if test="clientId != null and clientId != ''">client_id = #{clientId},</if>
<if test="publicIp != null and publicIp != ''">public_ip = #{publicIp},</if>
<if test="mtrClientId != null">mtr_client_id = #{mtrClientId},</if>
<if test="clientId != null">client_id = #{clientId},</if>
<if test="publicIp != null">public_ip = #{publicIp},</if>
<if test="packetLossRate != null">packet_loss_rate = #{packetLossRate},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="hopResult != null">hop_result = #{hopResult},</if>
</trim>
where id = #{id}
</update>
@@ -79,7 +84,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<delete id="deleteRmMtrProbeResultByIds" parameterType="String">
delete from rm_mtr_probe_result where id in
delete from rm_mtr_probe_result where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
@@ -92,7 +97,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
public_ip,
packet_loss_rate,
create_time,
update_time
update_time,
hop_result
) VALUES
<foreach collection="list" item="item" separator=",">
(
@@ -101,7 +107,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{item.publicIp},
#{item.packetLossRate},
#{item.createTime},
#{item.updateTime}
#{item.updateTime},
#{item.hopResult}
)
</foreach>
</insert>
@@ -109,7 +116,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectByCondition" parameterType="RmMtrProbeResult" resultMap="RmMtrProbeResultResult">
SELECT
id, mtr_client_id, client_id, public_ip, packet_loss_rate,
create_time, update_time, create_by, update_by
create_time, update_time, create_by, update_by, hop_result
FROM ${tableName}
<where>
<if test="mtrClientId != null and mtrClientId != ''">