优化mtr探测策略、增加ipv6相关字段
This commit is contained in:
+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