出省流量统计增加立即执行、增加占比总计、不同运营商也统计.
磁盘统计HDD改为所有磁盘、速率单位改为 MB/s、流量图开始时间修正。 流量95值收益优化
This commit is contained in:
+9
-2
@@ -183,8 +183,15 @@ public class EchartsDataUtils {
|
||||
|
||||
// 1. 查询开始时间到数据开始时间(稀疏间隔)
|
||||
if (queryStart.before(dataStart)) {
|
||||
List<Date> beforeSeries = generateTimeSeries(queryStart, dataStart, sparseInterval, false);
|
||||
timeSeries.addAll(beforeSeries);
|
||||
long timeDiff = dataStart.getTime() - queryStart.getTime();
|
||||
long thresholdMinutes = 5; // 定义阈值(分钟)
|
||||
long thresholdMs = thresholdMinutes * 60 * 1000;
|
||||
|
||||
// 只有当时间差超过5分钟时才补充时间序列
|
||||
if (timeDiff > thresholdMs) {
|
||||
List<Date> beforeSeries = generateTimeSeries(queryStart, dataStart, sparseInterval, false);
|
||||
timeSeries.addAll(beforeSeries);
|
||||
}
|
||||
}
|
||||
|
||||
// 2. 数据时间范围内的处理
|
||||
|
||||
+9
-2
@@ -193,8 +193,15 @@ public class EchartsMoreDataUtils {
|
||||
|
||||
// 1. 开始时间到数据开始时间(稀疏间隔)
|
||||
if (startDate.before(actualStartTime)) {
|
||||
List<Date> beforeSeries = generateTimeSeries(startDate, actualStartTime, sparseInterval);
|
||||
fullTimeSeries.addAll(beforeSeries);
|
||||
long timeDiff = actualStartTime.getTime() - startDate.getTime();
|
||||
long thresholdMinutes = 5; // 定义阈值(分钟)
|
||||
long thresholdMs = thresholdMinutes * 60 * 1000;
|
||||
|
||||
// 只有当时间差超过5分钟时才补充时间序列
|
||||
if (timeDiff > thresholdMs) {
|
||||
List<Date> beforeSeries = generateTimeSeries(startDate, actualStartTime, sparseInterval);
|
||||
fullTimeSeries.addAll(beforeSeries);
|
||||
}
|
||||
}
|
||||
|
||||
// 2. 数据开始时间到数据结束时间(正常间隔)
|
||||
|
||||
+7
-4
@@ -385,25 +385,28 @@ public class SpeedUtils {
|
||||
}
|
||||
public static String determineUnitByValue(Long value) {
|
||||
if (value == null || value == 0) {
|
||||
return "Kb";
|
||||
return "KB";
|
||||
}
|
||||
|
||||
// 注意:这里使用二进制单位(1024)
|
||||
if (value >= 1024L * 1024 * 1024) { // >= 1GB
|
||||
return "Gb";
|
||||
return "GB";
|
||||
} else if (value >= 1024L * 1024) { // >= 1MB
|
||||
return "Mb";
|
||||
return "MB";
|
||||
} else {
|
||||
return "Kb";
|
||||
return "KB";
|
||||
}
|
||||
}
|
||||
// 工具方法:获取单位换算除数
|
||||
public static BigDecimal get1024Divisor(String unit) {
|
||||
switch (unit) {
|
||||
case "GB":
|
||||
case "Gb":
|
||||
return new BigDecimal(1024L * 1024 * 1024); // 1GB = 1024^3
|
||||
case "MB":
|
||||
case "Mb":
|
||||
return new BigDecimal(1024L * 1024); // 1MB = 1024^2
|
||||
case "KB":
|
||||
case "Kb":
|
||||
return new BigDecimal(1024); // 1KB = 1024
|
||||
default:
|
||||
|
||||
+5
-5
@@ -170,22 +170,22 @@ public class UnitChangeUtil {
|
||||
}
|
||||
public static String convertUnitByValue(Long value) {
|
||||
if (value == null || value == 0) {
|
||||
return "0 Kb";
|
||||
return "0 KB";
|
||||
}
|
||||
|
||||
// 注意:这里使用二进制单位(1024)
|
||||
if (value >= 1024L * 1024 * 1024 * 1024) {
|
||||
double result = value / (1024.0 * 1024 * 1024 * 1024);
|
||||
return String.format("%.2f Tb", result);
|
||||
return String.format("%.2f TB", result);
|
||||
} else if (value >= 1024L * 1024 * 1024) { // >= 1GB
|
||||
double result = value / (1024.0 * 1024 * 1024);
|
||||
return String.format("%.2f Gb", result);
|
||||
return String.format("%.2f GB", result);
|
||||
} else if (value >= 1024L * 1024) { // >= 1MB
|
||||
double result = value / (1024.0 * 1024);
|
||||
return String.format("%.2f Mb", result);
|
||||
return String.format("%.2f MB", result);
|
||||
} else {
|
||||
double result = value / 1024.0;
|
||||
return String.format("%.2f Kb", result);
|
||||
return String.format("%.2f KB", result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ public class RmNetworkInterfaceChildController extends BaseController
|
||||
@PostMapping("/list")
|
||||
public AjaxResult list(@RequestBody RmNetworkInterfaceChild rmNetworkInterfaceChild)
|
||||
{
|
||||
List<RmNetworkInterfaceChild> list = rmNetworkInterfaceChildService.selectRmNetworkInterfaceChildList(rmNetworkInterfaceChild);
|
||||
List<RmNetworkInterfaceChild> list = rmNetworkInterfaceChildService.getNetworkInterfaceChildList(rmNetworkInterfaceChild);
|
||||
return success(list);
|
||||
}
|
||||
/**
|
||||
|
||||
+4
@@ -82,4 +82,8 @@ public class RmNetworkInterfaceChild extends BaseEntity
|
||||
private BigDecimal bandwidthResult;
|
||||
/** 有ipv4的标识 */
|
||||
private boolean ipv4Flag;
|
||||
/** 表名 */
|
||||
private String tableName;
|
||||
/** ping丢包率 */
|
||||
private Double pingDropped;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.tongran.rocketmq.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* tcpdump探测策略对象 rm_tcpdump_config
|
||||
*
|
||||
* @author tongran
|
||||
* @date 2026-01-21
|
||||
*/
|
||||
@Data
|
||||
public class RmTcpdumpVo
|
||||
{
|
||||
/** 开启探测(0:否,1:是) */
|
||||
private Integer detectFlag;
|
||||
|
||||
/** 探测频率 */
|
||||
private String frequency;
|
||||
|
||||
/** 探测时间列表(多个时间用,分隔) */
|
||||
private String detectTimes;
|
||||
|
||||
}
|
||||
@@ -129,6 +129,8 @@ public class MessageHandler {
|
||||
@Autowired
|
||||
private IRmOutboundTrafficStatisticsService rmOutboundTrafficStatisticsService;
|
||||
@Autowired
|
||||
private IRmTcpdumpConfigService rmTcpdumpConfigService;
|
||||
@Autowired
|
||||
private SendAlarmPushUtil sendAlarmPushUtil;
|
||||
|
||||
|
||||
@@ -163,6 +165,8 @@ public class MessageHandler {
|
||||
List<TcpdumpVo> tcpdumpVoList = JsonDataParser.parseJsonData(message.getData(), TcpdumpVo.class);
|
||||
if(tcpdumpVoList != null && !tcpdumpVoList.isEmpty()){
|
||||
String localProvince = "";
|
||||
String localIsp = "";
|
||||
boolean localHasFlag = false;
|
||||
// 根据clientId查询省份信息
|
||||
RmNetworkInterface networkInterfaceQuery = new RmNetworkInterface();
|
||||
networkInterfaceQuery.setClientId(message.getClientId());
|
||||
@@ -170,12 +174,26 @@ public class MessageHandler {
|
||||
List<RmNetworkInterface> networkInfoList = rmNetworkInterfaceService.selectRmNetworkInterfaceList(networkInterfaceQuery);
|
||||
if(networkInfoList != null && !networkInfoList.isEmpty()){
|
||||
for (RmNetworkInterface rmNetworkInterface : networkInfoList) {
|
||||
if(rmNetworkInterface.getProvince() != null){
|
||||
if(rmNetworkInterface.getProvince() != null && rmNetworkInterface.getIsp() != null
|
||||
&& ("1".equals(rmNetworkInterface.getBindIp()) || "3".equals(rmNetworkInterface.getBindIp()))){
|
||||
localProvince = rmNetworkInterface.getProvince();
|
||||
localIsp = rmNetworkInterface.getIsp();
|
||||
localHasFlag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!localHasFlag){
|
||||
// 查询子网卡
|
||||
RmNetworkInterfaceChild childQuery = new RmNetworkInterfaceChild();
|
||||
childQuery.setClientId(message.getClientId());
|
||||
List<RmNetworkInterfaceChild> existingChildren = rmNetworkInterfaceChildService.selectRmNetworkInterfaceChildList(childQuery);
|
||||
if(existingChildren != null && !existingChildren.isEmpty()){
|
||||
RmNetworkInterfaceChild networkInfoChild = existingChildren.get(0);
|
||||
localProvince = networkInfoChild.getProvince();
|
||||
localIsp = networkInfoChild.getIsp();
|
||||
}
|
||||
}
|
||||
|
||||
// 计算总数量
|
||||
Double totalCount = 0.0;
|
||||
@@ -199,11 +217,15 @@ public class MessageHandler {
|
||||
}
|
||||
}
|
||||
|
||||
// 构建content内容 - 根据图片格式
|
||||
// 构建content内容
|
||||
StringBuilder content = new StringBuilder();
|
||||
|
||||
// 添加时间戳 - 根据图片格式
|
||||
BigDecimal v4TotalRate = BigDecimal.ZERO;
|
||||
BigDecimal v6TotalRate = BigDecimal.ZERO;
|
||||
BigDecimal totalRate = BigDecimal.ZERO;
|
||||
// 添加时间戳
|
||||
content.append("时间:").append(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())).append("\n");
|
||||
int insertPosition = content.length();
|
||||
int insertPositionV6 = content.length();
|
||||
|
||||
// 处理IPv4统计
|
||||
if (!ipTypeMap.get("IPv4").isEmpty()) {
|
||||
@@ -218,7 +240,8 @@ public class MessageHandler {
|
||||
String province = locationInfo.get("province");
|
||||
|
||||
// 过滤本地省份和空值
|
||||
if (province != null && operator != null && !localProvince.equals(province)) {
|
||||
if (province != null && operator != null
|
||||
&& (!localProvince.equals(province) || !localIsp.equals(operator))) {
|
||||
String key = province + operator; // 根据图片格式,省份和运营商之间没有空格
|
||||
double currentCount = v4StatMap.getOrDefault(key, 0.0);
|
||||
v4StatMap.put(key, currentCount + tcpdumpVo.getCount());
|
||||
@@ -229,12 +252,19 @@ public class MessageHandler {
|
||||
// 计算百分比并排序
|
||||
List<Map.Entry<String, Double>> sortedV4List = new ArrayList<>(v4StatMap.entrySet());
|
||||
sortedV4List.sort((a, b) -> b.getValue().compareTo(a.getValue())); // 降序排序
|
||||
|
||||
// 先计算所有百分比并存储
|
||||
for (Map.Entry<String, Double> entry : sortedV4List) {
|
||||
BigDecimal percentage = new BigDecimal(entry.getValue() / totalCount * 100)
|
||||
BigDecimal percentage = new BigDecimal(entry.getValue())
|
||||
.divide(new BigDecimal(totalCount), 10, RoundingMode.HALF_UP)
|
||||
.multiply(new BigDecimal(100))
|
||||
.setScale(2, RoundingMode.HALF_UP);
|
||||
content.append(entry.getKey()).append(": ").append(percentage).append("%\n");
|
||||
v4TotalRate = v4TotalRate.add(percentage);
|
||||
}
|
||||
// 在记录的位置插入总计信息
|
||||
content.insert(insertPosition, "IPv4总计占比: " + v4TotalRate + "%\n");
|
||||
insertPositionV6 += ("IPv4总计占比: " + v4TotalRate + "%\n").length(); // 更新插入位置
|
||||
totalRate = totalRate.add(v4TotalRate);
|
||||
}
|
||||
|
||||
// 处理IPv6统计
|
||||
@@ -250,7 +280,8 @@ public class MessageHandler {
|
||||
String province = locationInfo.get("province");
|
||||
|
||||
// 过滤本地省份和空值
|
||||
if (province != null && operator != null && !localProvince.equals(province)) {
|
||||
if (province != null && operator != null
|
||||
&& (!localProvince.equals(province) || !localIsp.equals(operator))) {
|
||||
String key = province + operator; // 根据图片格式,省份和运营商之间没有空格
|
||||
double currentCount = v6StatMap.getOrDefault(key, 0.0);
|
||||
v6StatMap.put(key, currentCount + tcpdumpVo.getCount());
|
||||
@@ -263,11 +294,19 @@ public class MessageHandler {
|
||||
sortedV6List.sort((a, b) -> b.getValue().compareTo(a.getValue())); // 降序排序
|
||||
|
||||
for (Map.Entry<String, Double> entry : sortedV6List) {
|
||||
BigDecimal percentage = new BigDecimal(entry.getValue() / totalCount * 100)
|
||||
BigDecimal percentage = new BigDecimal(entry.getValue())
|
||||
.divide(new BigDecimal(totalCount), 10, RoundingMode.HALF_UP)
|
||||
.multiply(new BigDecimal(100))
|
||||
.setScale(2, RoundingMode.HALF_UP);
|
||||
content.append(entry.getKey()).append(": ").append(percentage).append("%\n");
|
||||
v6TotalRate = v6TotalRate.add(percentage);
|
||||
}
|
||||
// 在更新后的位置插入IPv6总计
|
||||
content.insert(insertPositionV6, "IPv6总计占比: " + v6TotalRate + "%\n");
|
||||
totalRate = totalRate.add(v6TotalRate);
|
||||
}
|
||||
// 在更新后的位置插入IPv6总计
|
||||
content.insert(insertPosition, "总占比: " + totalRate + "%\n");
|
||||
RmOutboundTrafficStatistics insertData = new RmOutboundTrafficStatistics();
|
||||
insertData.setClientId(message.getClientId());
|
||||
insertData.setDescription(content.toString());
|
||||
@@ -430,6 +469,18 @@ public class MessageHandler {
|
||||
if(rows == 2){
|
||||
// 注册成功,下发优先级为0的策略
|
||||
rmMonitorPolicyService.issueDefaultPolicyByClientId(message.getClientId());
|
||||
// 下发tcpdump默认策略
|
||||
String detectTimes = "20:00:00";
|
||||
RmTcpdumpConfig rmTcpdumpConfig = rmTcpdumpConfigService.selectRmTcpdumpConfigByClientId(clientId);
|
||||
if(rmTcpdumpConfig != null){
|
||||
detectTimes = detectTimes + "," + rmTcpdumpConfig.getDetectTimes();
|
||||
}
|
||||
RmTcpdumpConfig tcpdumpInsertData = new RmTcpdumpConfig();
|
||||
tcpdumpInsertData.setClientId(clientId);
|
||||
tcpdumpInsertData.setDetectFlag(1);
|
||||
tcpdumpInsertData.setFrequency("1");
|
||||
tcpdumpInsertData.setDetectTimes(detectTimes);
|
||||
rmTcpdumpConfigService.insertRmTcpdumpConfig(tcpdumpInsertData);
|
||||
// agent更新表插入数据
|
||||
// 存储更新结果
|
||||
// agent更新结果存储
|
||||
|
||||
@@ -86,4 +86,6 @@ public interface InitialDiskInfoMapper
|
||||
List<InitialDiskInfo> selectInitialDiskInfoListByCondition(InitialDiskInfo condition);
|
||||
|
||||
InitialDiskInfo getDiskTotal(InitialDiskInfo initialDiskInfo);
|
||||
|
||||
List<InitialDiskInfo> sumDistInfoByCondition(InitialDiskInfo condition);
|
||||
}
|
||||
|
||||
+2
@@ -64,4 +64,6 @@ public interface RmNetworkInterfaceChildMapper
|
||||
void deleteRmNetworkInterfaceChildByClientId(String clientId);
|
||||
|
||||
void deleteByParentInterfaceName(@Param("clientId") String clientId, @Param("name") String name);
|
||||
|
||||
List<RmNetworkInterfaceChild> getNetworkInterfaceChildList(RmNetworkInterfaceChild rmNetworkInterfaceChild);
|
||||
}
|
||||
|
||||
+2
@@ -63,4 +63,6 @@ public interface IRmNetworkInterfaceChildService
|
||||
void deleteRmNetworkInterfaceChildByClientId(String clientId);
|
||||
|
||||
void deleteByParentInterfaceName(String clientId, String name);
|
||||
|
||||
List<RmNetworkInterfaceChild> getNetworkInterfaceChildList(RmNetworkInterfaceChild rmNetworkInterfaceChild);
|
||||
}
|
||||
|
||||
+85
-2
@@ -691,9 +691,16 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf
|
||||
resultMap.put("cpuCores", cpuInfo.getCores());
|
||||
InitialDiskInfo diskInfo = new InitialDiskInfo();
|
||||
diskInfo.setClientId(initialBandwidthTraffic.getClientId());
|
||||
diskInfo.setType("HDD");
|
||||
InitialDiskInfo initialDiskInfo = diskInfoService.getDiskTotal(diskInfo);
|
||||
resultMap.put("diskTotal", initialDiskInfo.getTotal());
|
||||
if(initialDiskInfo != null){
|
||||
Long total = initialDiskInfo.getTotal();
|
||||
String totalStr = total + "G";
|
||||
if(total != null && total > 1024L){
|
||||
total = total / 1024;
|
||||
totalStr = total + "T";
|
||||
}
|
||||
resultMap.put("diskTotal", totalStr);
|
||||
}
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
@@ -709,6 +716,82 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf
|
||||
initialBandwidthTraffic.getStartTime(), initialBandwidthTraffic.getEndTime()
|
||||
);
|
||||
}
|
||||
// @Override
|
||||
// public Map<String, Object> pingDroppedEcharts(InitialBandwidthTraffic initialBandwidthTraffic) {
|
||||
// // 主网卡流量信息
|
||||
// List<InitialBandwidthTraffic> mainList = getListByTableName(initialBandwidthTraffic);
|
||||
// String originalName = initialBandwidthTraffic.getName();
|
||||
// String name = originalName;
|
||||
//
|
||||
// if (originalName != null && originalName.contains("(")) {
|
||||
// int index = originalName.indexOf("(");
|
||||
// name = originalName.substring(0, index);
|
||||
// }
|
||||
//
|
||||
// // 存储所有网卡的数据
|
||||
// Map<String, List<InitialBandwidthTraffic>> interfaceDataMap = new LinkedHashMap<>();
|
||||
// // 展示关系
|
||||
// Map<String, String> showRealation = new HashMap<>();
|
||||
//
|
||||
// // 添加主网卡数据
|
||||
// interfaceDataMap.put(name, mainList);
|
||||
// showRealation.put(name+"pingDropped", name+"的ping丢包率");
|
||||
//
|
||||
// boolean hasSubInterface = false;
|
||||
//
|
||||
// // 如果是Ethernet类型,查询子网卡
|
||||
// if(isEthernetInterface(name)){
|
||||
// RmNetworkInterfaceChild query = new RmNetworkInterfaceChild();
|
||||
// query.setClientId(initialBandwidthTraffic.getClientId());
|
||||
// query.setParentInterface(name);
|
||||
// List<RmNetworkInterfaceChild> children = rmNetworkInterfaceChildMapper.selectRmNetworkInterfaceChildList(query);
|
||||
// if(children != null && !children.isEmpty()){
|
||||
// hasSubInterface = true;
|
||||
// for (RmNetworkInterfaceChild child : children) {
|
||||
// InitialBandwidthTraffic childTraffic = new InitialBandwidthTraffic();
|
||||
// BeanUtils.copyProperties(initialBandwidthTraffic, childTraffic);
|
||||
// childTraffic.setName(child.getInterfaceName());
|
||||
// List<InitialBandwidthTraffic> childTrafficList = getListByTableName(childTraffic);
|
||||
//
|
||||
// if(childTrafficList != null && !childTrafficList.isEmpty()){
|
||||
// interfaceDataMap.put(child.getInterfaceName(), childTrafficList);
|
||||
// showRealation.put(child.getInterfaceName()+"pingDropped", child.getInterfaceName() + "的ping丢包率");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// try {
|
||||
// // 获取ping丢包率图表数据
|
||||
// Map<String, Object> resultMap = EchartsMoreDataUtils.buildMultiInterfaceEchartsDataWithTotal(
|
||||
// interfaceDataMap,
|
||||
// InitialBandwidthTraffic::getCreateTime,
|
||||
// info -> info.getPingDropped() != null ? new BigDecimal(info.getPingDropped()) : null,
|
||||
// null, // 出站流量设为null,因为ping丢包率只有单向数据
|
||||
// initialBandwidthTraffic.getStartTime(),
|
||||
// initialBandwidthTraffic.getEndTime(),
|
||||
// BigDecimal.ONE // 使用1作为除数,因为ping丢包率通常是百分比,不需要单位转换
|
||||
// );
|
||||
//
|
||||
// // 如果有子网卡,添加总丢包率显示
|
||||
// if(hasSubInterface){
|
||||
// showRealation.put("totalPingDropped", name+"总ping丢包率");
|
||||
// }
|
||||
//
|
||||
// // 排序显示关系
|
||||
// Map<String, String> sortedShowRealation = EchartsMoreDataUtils.sortInterfaceMap(showRealation, name, hasSubInterface);
|
||||
// resultMap.put("showRealation", sortedShowRealation);
|
||||
//
|
||||
// // 添加单位信息(ping丢包率通常用百分比表示)
|
||||
// resultMap.put("unit", "%");
|
||||
//
|
||||
// return resultMap;
|
||||
//
|
||||
// } catch (Exception e){
|
||||
// e.printStackTrace();
|
||||
// return new HashMap<>();
|
||||
// }
|
||||
// }
|
||||
|
||||
@Override
|
||||
public int countByClientIdAndTime(InitialBandwidthTraffic countQuery) {
|
||||
|
||||
+25
-3
@@ -210,6 +210,29 @@ public class InitialDiskInfoServiceImpl implements IInitialDiskInfoService
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
/**
|
||||
* 分表查询硬盘信息
|
||||
* @param queryParam
|
||||
* @return
|
||||
*/
|
||||
public List<InitialDiskInfo> sumDistInfoSharding(InitialDiskInfo queryParam) {
|
||||
// 获取涉及的表名
|
||||
Set<String> tableNames = TableSubUtil.getExistingTableNamesBetween(queryParam.getStartTime(), queryParam.getEndTime(), TABLE_PREFIX);
|
||||
|
||||
// 并行查询各表
|
||||
return tableNames.parallelStream()
|
||||
.flatMap(tableName -> {
|
||||
InitialDiskInfo condition = new InitialDiskInfo();
|
||||
condition.setTableName(tableName);
|
||||
condition.setClientId(queryParam.getClientId());
|
||||
condition.setName(queryParam.getName());
|
||||
condition.setType(queryParam.getType());
|
||||
condition.setStartTime(queryParam.getStartTime());
|
||||
condition.setEndTime(queryParam.getEndTime());
|
||||
return initialDiskInfoMapper.sumDistInfoByCondition(condition).stream();
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
/**
|
||||
* /dev/sda读写速率(KB/s)
|
||||
* @param initialDiskInfo
|
||||
@@ -251,9 +274,8 @@ public class InitialDiskInfoServiceImpl implements IInitialDiskInfoService
|
||||
}
|
||||
@Override
|
||||
public Map<String, Object> usedSpaceEcharts(InitialDiskInfo initialDiskInfo) {
|
||||
initialDiskInfo.setType("HDD");
|
||||
List<InitialDiskInfo> list = getDistInfoSharding(initialDiskInfo);
|
||||
String unit = "Kb";
|
||||
List<InitialDiskInfo> list = sumDistInfoSharding(initialDiskInfo);
|
||||
String unit = "KB";
|
||||
if(list != null && !list.isEmpty()){
|
||||
Long totalUsedSpace = 0L;
|
||||
for (InitialDiskInfo diskInfo : list) {
|
||||
|
||||
+9
@@ -1,6 +1,7 @@
|
||||
package com.tongran.rocketmq.service.impl;
|
||||
|
||||
import com.tongran.common.core.utils.DateUtils;
|
||||
import com.tongran.common.core.utils.TableSubUtil;
|
||||
import com.tongran.rocketmq.domain.RmNetworkInterfaceChild;
|
||||
import com.tongran.rocketmq.mapper.RmNetworkInterfaceChildMapper;
|
||||
import com.tongran.rocketmq.service.IRmNetworkInterfaceChildService;
|
||||
@@ -104,4 +105,12 @@ public class RmNetworkInterfaceChildServiceImpl implements IRmNetworkInterfaceCh
|
||||
public void deleteByParentInterfaceName(String clientId, String name) {
|
||||
rmNetworkInterfaceChildMapper.deleteByParentInterfaceName(clientId, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RmNetworkInterfaceChild> getNetworkInterfaceChildList(RmNetworkInterfaceChild rmNetworkInterfaceChild) {
|
||||
String tableName = TableSubUtil.getTableName(DateUtils.getNowDate(),"initial_bandwidth_traffic");
|
||||
rmNetworkInterfaceChild.setTableName(tableName);
|
||||
List<RmNetworkInterfaceChild> list = rmNetworkInterfaceChildMapper.getNetworkInterfaceChildList(rmNetworkInterfaceChild);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
+6
-5
@@ -6,6 +6,7 @@ import com.tongran.common.core.utils.DateUtils;
|
||||
import com.tongran.rocketmq.domain.DeviceMessage;
|
||||
import com.tongran.rocketmq.domain.RmTcpdumpConfig;
|
||||
import com.tongran.rocketmq.domain.vo.PolicyTypeVo;
|
||||
import com.tongran.rocketmq.domain.vo.RmTcpdumpVo;
|
||||
import com.tongran.rocketmq.mapper.RmTcpdumpConfigMapper;
|
||||
import com.tongran.rocketmq.model.ProducerMode;
|
||||
import com.tongran.rocketmq.producer.MessageProducer;
|
||||
@@ -66,11 +67,11 @@ public class RmTcpdumpConfigServiceImpl implements IRmTcpdumpConfigService
|
||||
rmTcpdumpConfigMapper.insertRmTcpdumpConfig(rmTcpdumpConfig);
|
||||
// 下发消息给agent
|
||||
PolicyTypeVo policyTypeVo = new PolicyTypeVo();
|
||||
if(rmTcpdumpConfig.getDetectFlag() == 1 && rmTcpdumpConfig.getDetectTimes() != null){
|
||||
policyTypeVo.setTcpdumpTimes(rmTcpdumpConfig.getDetectTimes());
|
||||
}else{
|
||||
policyTypeVo.setTcpdumpTimes("");
|
||||
}
|
||||
RmTcpdumpVo rmTcpdumpVo = new RmTcpdumpVo();
|
||||
rmTcpdumpVo.setDetectFlag(rmTcpdumpConfig.getDetectFlag());
|
||||
rmTcpdumpVo.setFrequency(rmTcpdumpConfig.getFrequency());
|
||||
rmTcpdumpVo.setDetectTimes(rmTcpdumpConfig.getDetectTimes()==null?"":rmTcpdumpConfig.getDetectTimes());
|
||||
policyTypeVo.setTcpdumpTimes(JSONObject.toJSONString(rmTcpdumpVo));
|
||||
MessageProducer messageProducer = new MessageProducer();
|
||||
String configJson = JSONObject.toJSONString(policyTypeVo);
|
||||
DeviceMessage message = new DeviceMessage();
|
||||
|
||||
@@ -147,8 +147,8 @@
|
||||
a.update_time as updateTime,
|
||||
b.serial,
|
||||
TRUNCATE(IFNULL(b.total,0)/(1024 * 1024 * 1024), 0) as total,
|
||||
TRUNCATE(IFNULL(b.write_speed,0)/1024, 0) as writeSpeed,
|
||||
TRUNCATE(IFNULL(b.read_speed,0)/1024, 0) as readSpeed,
|
||||
TRUNCATE(IFNULL(b.write_speed,0)/(1024*1024), 0) as writeSpeed,
|
||||
TRUNCATE(IFNULL(b.read_speed,0)/(1024*1024), 0) as readSpeed,
|
||||
b.type,
|
||||
TRUNCATE(IFNULL(b.used_space,0)/(1024 * 1024 * 1024), 0) as usedSpace
|
||||
FROM all_disk_name a
|
||||
|
||||
@@ -219,10 +219,22 @@
|
||||
inner join (
|
||||
select client_id, type, max(create_time) as latest_time
|
||||
from ${tableName}
|
||||
where client_id = #{clientId} and type = #{type}
|
||||
group by client_id, type
|
||||
where client_id = #{clientId}
|
||||
group by client_id
|
||||
) t1 on t2.client_id = t1.client_id
|
||||
and t2.type = t1.type
|
||||
and t2.create_time = t1.latest_time
|
||||
</select>
|
||||
<select id="sumDistInfoByCondition" parameterType="InitialDiskInfo" resultMap="InitialDiskInfoResult">
|
||||
select sum(used_space) used_space,create_time
|
||||
from ${tableName}
|
||||
<where>
|
||||
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
|
||||
<if test="name != null and name != ''"> and name = #{name}</if>
|
||||
<if test="type != null and type != ''"> and type = #{type}</if>
|
||||
<if test="startTime != null and startTime != ''"> and create_time >= #{startTime}</if>
|
||||
<if test="endTime != null and endTime != ''"> and create_time <= #{endTime}</if>
|
||||
</where>
|
||||
group by create_time
|
||||
order by create_time desc
|
||||
</select>
|
||||
</mapper>
|
||||
+103
@@ -184,4 +184,107 @@
|
||||
<delete id="deleteByParentInterfaceName" parameterType="String">
|
||||
delete from rm_network_interface_child where client_id = #{clientId} and parent_interface =#{name}
|
||||
</delete>
|
||||
<select id="getNetworkInterfaceChildList" parameterType="RmNetworkInterfaceChild" resultType="RmNetworkInterfaceChild">
|
||||
SELECT
|
||||
a.id,
|
||||
a.client_id AS clientId,
|
||||
a.parent_interface AS parentInterface,
|
||||
a.isp,
|
||||
a.province,
|
||||
a.city,
|
||||
a.public_ip AS publicIp,
|
||||
a.interface_name AS interfaceName,
|
||||
a.mac_address AS macAddress,
|
||||
a.interface_type AS interfaceType,
|
||||
a.ipv4_address AS ipv4Address,
|
||||
a.ipv6_address AS ipv6Address,
|
||||
a.gateway,
|
||||
a.create_time AS createTime,
|
||||
a.update_time AS updateTime,
|
||||
a.create_by AS createBy,
|
||||
a.update_by AS updateBy,
|
||||
a.bind_ip AS bindIp,
|
||||
a.new_flag AS newFlag,
|
||||
a.status,
|
||||
a.bandwidth_result AS bandwidthResult,
|
||||
a.net_create_time AS netCreateTime,
|
||||
b.ping_dropped AS pingDropped
|
||||
FROM rm_network_interface_child a
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
t1.client_id,
|
||||
t1.create_time,
|
||||
CASE
|
||||
WHEN t1.name LIKE '%(%' THEN
|
||||
TRIM(SUBSTRING_INDEX(t1.name, '(', 1))
|
||||
ELSE t1.name
|
||||
END as name,
|
||||
t1.mac,
|
||||
t1.ping_dropped
|
||||
FROM
|
||||
${tableName} t1
|
||||
INNER JOIN (
|
||||
SELECT
|
||||
client_id,
|
||||
MAX(create_time) as latest_time
|
||||
FROM
|
||||
${tableName}
|
||||
WHERE
|
||||
client_id = #{clientId}
|
||||
GROUP BY
|
||||
client_id
|
||||
) t2 ON t1.client_id = t2.client_id AND t1.create_time = t2.latest_time
|
||||
) b ON a.client_id = b.client_id and a.interface_name = b.name and a.mac_address = b.mac
|
||||
<where>
|
||||
<if test="clientId != null and clientId != ''">
|
||||
and a.client_id = #{clientId}
|
||||
</if>
|
||||
<if test="parentInterface != null and parentInterface != ''">
|
||||
and a.parent_interface = #{parentInterface}
|
||||
and a.ipv4_address != '' and a.ipv4_address != 'N/A'
|
||||
</if>
|
||||
<if test="isp != null and isp != ''">
|
||||
and a.isp = #{isp}
|
||||
</if>
|
||||
<if test="province != null and province != ''">
|
||||
and a.province = #{province}
|
||||
</if>
|
||||
<if test="city != null and city != ''">
|
||||
and a.city = #{city}
|
||||
</if>
|
||||
<if test="publicIp != null and publicIp != ''">
|
||||
and a.public_ip = #{publicIp}
|
||||
</if>
|
||||
<if test="interfaceName != null and interfaceName != ''">
|
||||
and a.interface_name like concat('%', #{interfaceName}, '%')
|
||||
</if>
|
||||
<if test="macAddress != null and macAddress != ''">
|
||||
and a.mac_address = #{macAddress}
|
||||
</if>
|
||||
<if test="interfaceType != null and interfaceType != ''">
|
||||
and a.interface_type = #{interfaceType}
|
||||
</if>
|
||||
<if test="ipv4Address != null and ipv4Address != ''">
|
||||
and a.ipv4_address = #{ipv4Address}
|
||||
</if>
|
||||
<if test="ipv6Address != null and ipv6Address != ''">
|
||||
and a.ipv6_address = #{ipv6Address}
|
||||
</if>
|
||||
<if test="gateway != null and gateway != ''">
|
||||
and a.gateway = #{gateway}
|
||||
</if>
|
||||
<if test="bindIp != null and bindIp != ''">
|
||||
and a.bind_ip = #{bindIp}
|
||||
</if>
|
||||
<if test="newFlag != null">
|
||||
and a.new_flag = #{newFlag}
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
and a.status = #{status}
|
||||
</if>
|
||||
<if test="ipv4Flag != null and ipv4Flag">
|
||||
and a.ipv4_address != '' and a.ipv4_address != 'N/A'
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user