优化mtr探测策略、增加ipv6相关字段
This commit is contained in:
+1
-6
@@ -206,12 +206,7 @@ public class EchartsDataUtils {
|
||||
return "";
|
||||
}
|
||||
|
||||
// 其他字段:第一个点补0,其他点补null
|
||||
if (timeIndex == 0) {
|
||||
return 0;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+2
@@ -44,6 +44,8 @@ public class RmMtrProbeResult extends BaseEntity
|
||||
private String startTime;
|
||||
/** 结束时间 */
|
||||
private String endTime;
|
||||
/** 每跳分析结果 */
|
||||
private String hopResult;
|
||||
|
||||
|
||||
|
||||
|
||||
+1
@@ -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);
|
||||
|
||||
+5
@@ -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()
|
||||
);
|
||||
|
||||
+26
-19
@@ -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 != ''">
|
||||
|
||||
+6
@@ -687,6 +687,12 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
|
||||
updateData.setAgentVersion(rmResourceRegistration.getAgentVersion());
|
||||
needUpdate = true;
|
||||
}
|
||||
if(exits.getHardwareSn() == null ||
|
||||
!StringUtils.equals(rmResourceRegistration.getHardwareSn(),exits.getHardwareSn())){
|
||||
// 如果服务器已注册 增加SN信息
|
||||
updateData.setHardwareSn(rmResourceRegistration.getHardwareSn());
|
||||
needUpdate = true;
|
||||
}
|
||||
if(needUpdate){
|
||||
updateData.setId(exits.getId());
|
||||
rmResourceRegistrationMapper.updateRmResourceRegistration(updateData);
|
||||
|
||||
+1
@@ -73,6 +73,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
client_id VARCHAR(200) COMMENT '客户端ID',
|
||||
public_ip VARCHAR(45) COMMENT '公网IP地址',
|
||||
packet_loss_rate DECIMAL(5,2) COMMENT '丢包率(%)',
|
||||
hop_result LONGTEXT COMMENT '每一跳解析结果(JSON形式)',
|
||||
create_time DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
create_by VARCHAR(64) COMMENT '创建人',
|
||||
|
||||
+20
@@ -42,6 +42,8 @@ public class InitialBandwidthTraffic extends BaseEntity
|
||||
/** IPv4地址 */
|
||||
@Excel(name = "IPv4地址")
|
||||
private String ipV4;
|
||||
/** Ipv6 */
|
||||
private String ipV6;
|
||||
|
||||
/** 入站丢包率(%) */
|
||||
@Excel(name = "入站丢包率(%)")
|
||||
@@ -81,5 +83,23 @@ public class InitialBandwidthTraffic extends BaseEntity
|
||||
/** 总发送带宽 */
|
||||
@Excel(name = "总发送带宽")
|
||||
private String totalOutSpeed;
|
||||
/** IPv4接收流量 */
|
||||
private String ipv4InSpeed;
|
||||
|
||||
/** IPv4发送流量 */
|
||||
private String ipv4OutSpeed;
|
||||
|
||||
/** IPv6接收流量 */
|
||||
private String ipv6InSpeed;
|
||||
|
||||
/** IPv6发送流量 */
|
||||
private String ipv6OutSpeed;
|
||||
/** IPv4接收总流量 */
|
||||
private String totalIpv4InSpeed;
|
||||
/** IPv4发送总流量 */
|
||||
private String totalIpv4OutSpeed;
|
||||
/** IPv6接收总流量 */
|
||||
private String totalIpv6InSpeed;
|
||||
/** IPv6发送总流量 */
|
||||
private String totalIpv6OutSpeed;
|
||||
}
|
||||
|
||||
+20
-174
@@ -1,10 +1,10 @@
|
||||
package com.tongran.rocketmq.domain;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.tongran.common.core.annotation.Excel;
|
||||
import com.tongran.common.core.web.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 初始带宽流量临时表对象 initial_bandwidth_traffic_temp
|
||||
@@ -12,6 +12,7 @@ import com.tongran.common.core.web.domain.BaseEntity;
|
||||
* @author gyt
|
||||
* @date 2025-11-05
|
||||
*/
|
||||
@Data
|
||||
public class InitialBandwidthTrafficTemp extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -74,179 +75,24 @@ public class InitialBandwidthTrafficTemp extends BaseEntity
|
||||
/** 总发送带宽(bit) */
|
||||
@Excel(name = "总发送带宽(bit)")
|
||||
private String totalOutSpeed;
|
||||
/** IPv4接收流量 */
|
||||
private String ipv4InSpeed;
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
/** IPv4发送流量 */
|
||||
private String ipv4OutSpeed;
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
/** IPv6接收流量 */
|
||||
private String ipv6InSpeed;
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
/** IPv6发送流量 */
|
||||
private String ipv6OutSpeed;
|
||||
/** IPv4接收总流量 */
|
||||
private String totalIpv4InSpeed;
|
||||
/** IPv4发送总流量 */
|
||||
private String totalIpv4OutSpeed;
|
||||
/** IPv6接收总流量 */
|
||||
private String totalIpv6InSpeed;
|
||||
/** IPv6发送总流量 */
|
||||
private String totalIpv6OutSpeed;
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setMac(String mac)
|
||||
{
|
||||
this.mac = mac;
|
||||
}
|
||||
|
||||
public String getMac()
|
||||
{
|
||||
return mac;
|
||||
}
|
||||
|
||||
public void setStatus(String status)
|
||||
{
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getStatus()
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setType(String type)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setIpV4(String ipV4)
|
||||
{
|
||||
this.ipV4 = ipV4;
|
||||
}
|
||||
|
||||
public String getIpV4()
|
||||
{
|
||||
return ipV4;
|
||||
}
|
||||
|
||||
public void setInDropped(BigDecimal inDropped)
|
||||
{
|
||||
this.inDropped = inDropped;
|
||||
}
|
||||
|
||||
public BigDecimal getInDropped()
|
||||
{
|
||||
return inDropped;
|
||||
}
|
||||
|
||||
public void setOutDropped(BigDecimal outDropped)
|
||||
{
|
||||
this.outDropped = outDropped;
|
||||
}
|
||||
|
||||
public BigDecimal getOutDropped()
|
||||
{
|
||||
return outDropped;
|
||||
}
|
||||
|
||||
public void setInSpeed(String inSpeed)
|
||||
{
|
||||
this.inSpeed = inSpeed;
|
||||
}
|
||||
|
||||
public String getInSpeed()
|
||||
{
|
||||
return inSpeed;
|
||||
}
|
||||
|
||||
public void setOutSpeed(String outSpeed)
|
||||
{
|
||||
this.outSpeed = outSpeed;
|
||||
}
|
||||
|
||||
public String getOutSpeed()
|
||||
{
|
||||
return outSpeed;
|
||||
}
|
||||
|
||||
public void setSpeed(String speed)
|
||||
{
|
||||
this.speed = speed;
|
||||
}
|
||||
|
||||
public String getSpeed()
|
||||
{
|
||||
return speed;
|
||||
}
|
||||
|
||||
public void setDuplex(String duplex)
|
||||
{
|
||||
this.duplex = duplex;
|
||||
}
|
||||
|
||||
public String getDuplex()
|
||||
{
|
||||
return duplex;
|
||||
}
|
||||
|
||||
public void setClientId(String clientId)
|
||||
{
|
||||
this.clientId = clientId;
|
||||
}
|
||||
|
||||
public String getClientId()
|
||||
{
|
||||
return clientId;
|
||||
}
|
||||
|
||||
public void setTotalInSpeed(String totalInSpeed)
|
||||
{
|
||||
this.totalInSpeed = totalInSpeed;
|
||||
}
|
||||
|
||||
public String getTotalInSpeed()
|
||||
{
|
||||
return totalInSpeed;
|
||||
}
|
||||
|
||||
public void setTotalOutSpeed(String totalOutSpeed)
|
||||
{
|
||||
this.totalOutSpeed = totalOutSpeed;
|
||||
}
|
||||
|
||||
public String getTotalOutSpeed()
|
||||
{
|
||||
return totalOutSpeed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("name", getName())
|
||||
.append("mac", getMac())
|
||||
.append("status", getStatus())
|
||||
.append("type", getType())
|
||||
.append("ipV4", getIpV4())
|
||||
.append("inDropped", getInDropped())
|
||||
.append("outDropped", getOutDropped())
|
||||
.append("inSpeed", getInSpeed())
|
||||
.append("outSpeed", getOutSpeed())
|
||||
.append("speed", getSpeed())
|
||||
.append("duplex", getDuplex())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("clientId", getClientId())
|
||||
.append("totalInSpeed", getTotalInSpeed())
|
||||
.append("totalOutSpeed", getTotalOutSpeed())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -676,38 +676,83 @@ public class MessageHandler {
|
||||
interfaces.forEach(iface -> {
|
||||
iface.setClientId(clientId);
|
||||
iface.setCreateTime(createTime);
|
||||
// 发送流量
|
||||
|
||||
// 设置总流量(转换为比特)
|
||||
iface.setTotalOutSpeed(dataProcessUtil.bytesToBits(iface.getOutSpeed()));
|
||||
// 接收流量
|
||||
iface.setTotalInSpeed(dataProcessUtil.bytesToBits(iface.getInSpeed()));
|
||||
iface.setTotalIpv4OutSpeed(dataProcessUtil.bytesToBits(iface.getIpv4OutSpeed()));
|
||||
iface.setTotalIpv4InSpeed(dataProcessUtil.bytesToBits(iface.getIpv4InSpeed()));
|
||||
iface.setTotalIpv6OutSpeed(dataProcessUtil.bytesToBits(iface.getIpv6OutSpeed()));
|
||||
iface.setTotalIpv6InSpeed(dataProcessUtil.bytesToBits(iface.getIpv6InSpeed()));
|
||||
|
||||
InitialBandwidthTrafficTemp tempInfo = tempMap.get(iface.getMac());
|
||||
if (tempInfo != null) {
|
||||
// 计算inSpeed
|
||||
// 计算总流入速率
|
||||
if (iface.getTotalInSpeed() != null && tempInfo.getTotalInSpeed() != null) {
|
||||
BigDecimal nowInSpeed = new BigDecimal(iface.getTotalInSpeed());
|
||||
BigDecimal tempInSpeed = new BigDecimal(tempInfo.getTotalInSpeed());
|
||||
BigDecimal inDiff = nowInSpeed.subtract(tempInSpeed);
|
||||
|
||||
// 检查相减结果是否为非负数
|
||||
if (inDiff.compareTo(BigDecimal.ZERO) >= 0) {
|
||||
iface.setInSpeed(inDiff.divide(divisor, 0, RoundingMode.HALF_UP).toString());
|
||||
}else{
|
||||
} else {
|
||||
iface.setInSpeed(null);
|
||||
}
|
||||
}
|
||||
// 计算outSpeed
|
||||
// 计算总流出速率
|
||||
if (iface.getTotalOutSpeed() != null && tempInfo.getTotalOutSpeed() != null) {
|
||||
BigDecimal nowOutSpeed = new BigDecimal(iface.getTotalOutSpeed());
|
||||
BigDecimal tempOutSpeed = new BigDecimal(tempInfo.getTotalOutSpeed());
|
||||
BigDecimal outDiff = nowOutSpeed.subtract(tempOutSpeed);
|
||||
|
||||
// 检查相减结果是否为非负数
|
||||
if (outDiff.compareTo(BigDecimal.ZERO) >= 0) {
|
||||
iface.setOutSpeed(outDiff.divide(divisor, 0, RoundingMode.HALF_UP).toString());
|
||||
}else{
|
||||
} else {
|
||||
iface.setOutSpeed(null);
|
||||
}
|
||||
}
|
||||
// 计算IPv4流入速率
|
||||
if (iface.getTotalIpv4InSpeed() != null && tempInfo.getTotalIpv4InSpeed() != null) {
|
||||
BigDecimal nowIpv4In = new BigDecimal(iface.getTotalIpv4InSpeed());
|
||||
BigDecimal tempIpv4In = new BigDecimal(tempInfo.getTotalIpv4InSpeed());
|
||||
BigDecimal ipv4InDiff = nowIpv4In.subtract(tempIpv4In);
|
||||
if (ipv4InDiff.compareTo(BigDecimal.ZERO) >= 0) {
|
||||
iface.setIpv4InSpeed(ipv4InDiff.divide(divisor, 0, RoundingMode.HALF_UP).toString());
|
||||
} else {
|
||||
iface.setIpv4InSpeed(null);
|
||||
}
|
||||
}
|
||||
// 计算IPv4流出速率
|
||||
if (iface.getTotalIpv4OutSpeed() != null && tempInfo.getTotalIpv4OutSpeed() != null) {
|
||||
BigDecimal nowIpv4Out = new BigDecimal(iface.getTotalIpv4OutSpeed());
|
||||
BigDecimal tempIpv4Out = new BigDecimal(tempInfo.getTotalIpv4OutSpeed());
|
||||
BigDecimal ipv4OutDiff = nowIpv4Out.subtract(tempIpv4Out);
|
||||
if (ipv4OutDiff.compareTo(BigDecimal.ZERO) >= 0) {
|
||||
iface.setIpv4OutSpeed(ipv4OutDiff.divide(divisor, 0, RoundingMode.HALF_UP).toString());
|
||||
} else {
|
||||
iface.setIpv4OutSpeed(null);
|
||||
}
|
||||
}
|
||||
// 计算IPv6流入速率
|
||||
if (iface.getTotalIpv6InSpeed() != null && tempInfo.getTotalIpv6InSpeed() != null) {
|
||||
BigDecimal nowIpv6In = new BigDecimal(iface.getTotalIpv6InSpeed());
|
||||
BigDecimal tempIpv6In = new BigDecimal(tempInfo.getTotalIpv6InSpeed());
|
||||
BigDecimal ipv6InDiff = nowIpv6In.subtract(tempIpv6In);
|
||||
if (ipv6InDiff.compareTo(BigDecimal.ZERO) >= 0) {
|
||||
iface.setIpv6InSpeed(ipv6InDiff.divide(divisor, 0, RoundingMode.HALF_UP).toString());
|
||||
} else {
|
||||
iface.setIpv6InSpeed(null);
|
||||
}
|
||||
}
|
||||
// 计算IPv6流出速率
|
||||
if (iface.getTotalIpv6OutSpeed() != null && tempInfo.getTotalIpv6OutSpeed() != null) {
|
||||
BigDecimal nowIpv6Out = new BigDecimal(iface.getTotalIpv6OutSpeed());
|
||||
BigDecimal tempIpv6Out = new BigDecimal(tempInfo.getTotalIpv6OutSpeed());
|
||||
BigDecimal ipv6OutDiff = nowIpv6Out.subtract(tempIpv6Out);
|
||||
if (ipv6OutDiff.compareTo(BigDecimal.ZERO) >= 0) {
|
||||
iface.setIpv6OutSpeed(ipv6OutDiff.divide(divisor, 0, RoundingMode.HALF_UP).toString());
|
||||
} else {
|
||||
iface.setIpv6OutSpeed(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
// 清空临时表对应server信息
|
||||
@@ -716,18 +761,27 @@ public class MessageHandler {
|
||||
interfaces.forEach(iface -> {
|
||||
iface.setClientId(clientId);
|
||||
iface.setCreateTime(createTime);
|
||||
// 总发送流量
|
||||
// 设置总流量(转换为比特)
|
||||
iface.setTotalOutSpeed(dataProcessUtil.bytesToBits(iface.getOutSpeed()));
|
||||
// 总接收流量
|
||||
iface.setTotalInSpeed(dataProcessUtil.bytesToBits(iface.getInSpeed()));
|
||||
iface.setTotalIpv4OutSpeed(dataProcessUtil.bytesToBits(iface.getIpv4OutSpeed()));
|
||||
iface.setTotalIpv4InSpeed(dataProcessUtil.bytesToBits(iface.getIpv4InSpeed()));
|
||||
iface.setTotalIpv6OutSpeed(dataProcessUtil.bytesToBits(iface.getIpv6OutSpeed()));
|
||||
iface.setTotalIpv6InSpeed(dataProcessUtil.bytesToBits(iface.getIpv6InSpeed()));
|
||||
|
||||
// 首次采集,速率设为null
|
||||
iface.setInSpeed(null);
|
||||
iface.setOutSpeed(null);
|
||||
iface.setIpv4InSpeed(null);
|
||||
iface.setIpv4OutSpeed(null);
|
||||
iface.setIpv6InSpeed(null);
|
||||
iface.setIpv6OutSpeed(null);
|
||||
});
|
||||
}
|
||||
InitialBandwidthTraffic data = new InitialBandwidthTraffic();
|
||||
// 批量入库集合
|
||||
data.setList(interfaces);
|
||||
// 临时表 用来计算inSpeed outSeppd
|
||||
// 临时表 用来计算流量速率
|
||||
initialBandwidthTrafficTempService.batchInsertServerTemp(interfaces);
|
||||
// 初始流量数据入库
|
||||
initialBandwidthTrafficService.batchInsert(data);
|
||||
@@ -963,6 +1017,7 @@ public class MessageHandler {
|
||||
RmResourceRegistrationRemote updateData = new RmResourceRegistrationRemote();
|
||||
updateData.setClientId(message.getClientId());
|
||||
updateData.setLogicalNodeId(heartbeat.getLogicalNode());
|
||||
updateData.setHardwareSn(heartbeat.getSn());
|
||||
updateData.setOnlineStatus("1");
|
||||
updateData.setAgentVersion(version);
|
||||
updateData.setOnboardTime(DateUtils.getNowDate());
|
||||
|
||||
Reference in New Issue
Block a user