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