1、适配cpu信息表、容器信息表、挂载点信息表分表。
2、agent增加采集磁盘健康状态。 3、优化磁盘上报数据处理。
This commit is contained in:
+6
@@ -76,4 +76,10 @@ public interface EpsInitialTrafficDataMapper {
|
||||
void createDiskInfo(String tableName);
|
||||
|
||||
void batchInsertRecoverDetailTraffic(EpsInitialTrafficData batchData);
|
||||
|
||||
void createCpuInfo(String tableName);
|
||||
|
||||
void createMountPointInfo(String tableName);
|
||||
|
||||
void createDockerInfo(String tableName);
|
||||
}
|
||||
|
||||
+2
-2
@@ -123,9 +123,9 @@ public interface RmResourceRegistrationMapper
|
||||
int countChildNetwork(@Param("clientId") String clientId,
|
||||
@Param("interfaceName") String interfaceName);
|
||||
|
||||
List<RmResourceRegistration> getCpuUtil(@Param("clientIdsStr") String clientIdsStr);
|
||||
List<RmResourceRegistration> getCpuUtil(@Param("clientIdsStr") String clientIdsStr, @Param("tableName") String tableName);
|
||||
|
||||
List<RmResourceRegistration> getMemUtil(@Param("clientIdsStr") String clientIdsStr);
|
||||
List<RmResourceRegistration> getMemUtil(@Param("clientIdsStr") String clientIdsStr, @Param("tableName") String tableName);
|
||||
|
||||
int removeAlarmFlag(RmResourceRegistration rmResourceRegistration);
|
||||
|
||||
|
||||
+27
@@ -76,6 +76,12 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
|
||||
createSwitchOpMdTable(year, month);
|
||||
// 创建磁盘信息表
|
||||
createDiskInfo(year, month);
|
||||
// 创建cpu信息表
|
||||
createCpuInfo(year, month);
|
||||
// 创建挂载点信息表
|
||||
createMountPointInfo(year, month);
|
||||
// 创建容器信息表
|
||||
createDockerInfo(year, month);
|
||||
}
|
||||
public void createNextMonthTables(Long plusMonth) {
|
||||
LocalDate nextMonth = LocalDate.now().plusMonths(plusMonth);
|
||||
@@ -98,6 +104,12 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
|
||||
createSwitchOpMdTable(year, month);
|
||||
// 创建磁盘信息表
|
||||
createDiskInfo(year, month);
|
||||
// 创建cpu信息表
|
||||
createCpuInfo(year, month);
|
||||
// 创建挂载点信息表
|
||||
createMountPointInfo(year, month);
|
||||
// 创建容器信息表
|
||||
createDockerInfo(year, month);
|
||||
}
|
||||
private void createTrafficDetailsTable(int year, int month) {
|
||||
createRangeTables(year, month, "eps_traffic_details", (tableName) -> {
|
||||
@@ -142,7 +154,22 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
|
||||
epsInitialTrafficDataMapper.createDiskInfo(tableName);
|
||||
});
|
||||
}
|
||||
private void createCpuInfo(int year, int month) {
|
||||
createRangeTables(year, month, "initial_cpu_info", (tableName) -> {
|
||||
epsInitialTrafficDataMapper.createCpuInfo(tableName);
|
||||
});
|
||||
}
|
||||
private void createMountPointInfo(int year, int month) {
|
||||
createRangeTables(year, month, "initial_mount_point_info", (tableName) -> {
|
||||
epsInitialTrafficDataMapper.createMountPointInfo(tableName);
|
||||
});
|
||||
}
|
||||
|
||||
private void createDockerInfo(int year, int month) {
|
||||
createRangeTables(year, month, "initial_docker_info", (tableName) -> {
|
||||
epsInitialTrafficDataMapper.createDockerInfo(tableName);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用创建表方法
|
||||
|
||||
+9
-5
@@ -6,6 +6,7 @@ import com.tongran.common.core.domain.R;
|
||||
import com.tongran.common.core.enums.MsgEnum;
|
||||
import com.tongran.common.core.utils.DateUtils;
|
||||
import com.tongran.common.core.utils.StringUtils;
|
||||
import com.tongran.common.core.utils.TableSubUtil;
|
||||
import com.tongran.common.core.web.domain.AjaxResult;
|
||||
import com.tongran.common.core.web.page.PageDomain;
|
||||
import com.tongran.common.security.utils.SecurityUtils;
|
||||
@@ -338,7 +339,8 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
|
||||
if (CollectionUtils.isEmpty(pageList)) {
|
||||
return;
|
||||
}
|
||||
|
||||
String cpuTbaleName = TableSubUtil.getTableName(DateUtils.getNowDate(), "initial_cpu_info");
|
||||
String memTbaleName = TableSubUtil.getTableName(DateUtils.getNowDate(), "initial_system_other_collect_data");
|
||||
long startTime = System.currentTimeMillis();
|
||||
int batchSize = 200;
|
||||
int totalBatches = (int) Math.ceil((double) pageList.size() / batchSize);
|
||||
@@ -361,10 +363,10 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
|
||||
try {
|
||||
// 并行查询
|
||||
CompletableFuture<List<RmResourceRegistration>> cpuFuture = CompletableFuture
|
||||
.supplyAsync(() -> rmResourceRegistrationMapper.getCpuUtil(clientIdsStr));
|
||||
.supplyAsync(() -> rmResourceRegistrationMapper.getCpuUtil(clientIdsStr, cpuTbaleName));
|
||||
|
||||
CompletableFuture<List<RmResourceRegistration>> memFuture = CompletableFuture
|
||||
.supplyAsync(() -> rmResourceRegistrationMapper.getMemUtil(clientIdsStr));
|
||||
.supplyAsync(() -> rmResourceRegistrationMapper.getMemUtil(clientIdsStr, memTbaleName));
|
||||
|
||||
CompletableFuture<List<RmNetworkInterfaceRemote>> networkFuture = CompletableFuture
|
||||
.supplyAsync(() -> {
|
||||
@@ -530,10 +532,12 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
|
||||
*/
|
||||
public void setNetWorkMsg(RmResourceRegistration registration) {
|
||||
String clientId = registration.getClientId();
|
||||
String cpuTbaleName = TableSubUtil.getTableName(DateUtils.getNowDate(), "initial_cpu_info");
|
||||
String memTbaleName = TableSubUtil.getTableName(DateUtils.getNowDate(), "initial_system_other_collect_data");
|
||||
// 根据clientId查询cpu利用率
|
||||
List<RmResourceRegistration> cpuUtilList = rmResourceRegistrationMapper.getCpuUtil(clientId);
|
||||
List<RmResourceRegistration> cpuUtilList = rmResourceRegistrationMapper.getCpuUtil(clientId, cpuTbaleName);
|
||||
// 根据clientId查询mem利用率
|
||||
List<RmResourceRegistration> memUtilList = rmResourceRegistrationMapper.getMemUtil(clientId);
|
||||
List<RmResourceRegistration> memUtilList = rmResourceRegistrationMapper.getMemUtil(clientId, memTbaleName);
|
||||
// 查询agent最新版本
|
||||
RmResourceRegistration rmResourceRegistration = rmResourceRegistrationMapper.getMaxAgentVersion();
|
||||
if(cpuUtilList != null && !cpuUtilList.isEmpty()){
|
||||
|
||||
+64
@@ -222,11 +222,75 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`type` varchar(255) COMMENT '磁盘类型',
|
||||
`used_space` bigint(20) COMMENT '已用空间',
|
||||
`health_status` int(2) COMMENT '健康状态(0-不健康,1-健康)',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY uk_client_disk_time (`client_id`, `name`, `create_time`),
|
||||
INDEX idx_clent_type_time(`client_id`, `create_time`, `type`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='磁盘监控信息表';
|
||||
</update>
|
||||
<update id="createCpuInfo">
|
||||
CREATE TABLE IF NOT EXISTS ${tableName} (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
`client_id` varchar(255) NOT NULL COMMENT '客户端ID',
|
||||
`avg1` double(20, 2) COMMENT 'CPU1分钟负载',
|
||||
`avg5` double(20, 2) COMMENT 'CPU5分钟负载',
|
||||
`avg15` double(20, 2) COMMENT 'CPU15分钟负载',
|
||||
`interrupt` double(20, 2) COMMENT 'CPU硬件中断提供服务时间',
|
||||
`uti` double(20, 2) COMMENT 'CPU使用率(%)',
|
||||
`num` double(20, 2) COMMENT 'CPU数量',
|
||||
`cores` int(11) COMMENT 'cpu核数',
|
||||
`normal` bigint(20) COMMENT 'CPU正常运行时间',
|
||||
`idle` double(20, 2) COMMENT 'CPU空闲时间',
|
||||
`iowait` double(20, 2) COMMENT 'CPU等待响应时间',
|
||||
`system` double(20, 2) COMMENT 'CPU系统时间',
|
||||
`noresp` double(20, 2) COMMENT 'CPU软件无响应时间',
|
||||
`user` double(20, 2) COMMENT 'CPU用户进程所花费的时间',
|
||||
`create_by` varchar(50) COMMENT '创建人',
|
||||
`update_by` varchar(50) COMMENT '更新人',
|
||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`temperature` double(20, 1) COMMENT 'cpu温度',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE INDEX `idx_unnque_key`(`client_id`, `create_time`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT = 'CPU监控信息表';
|
||||
</update>
|
||||
<update id="createDockerInfo">
|
||||
CREATE TABLE ${tableName} (
|
||||
`id` varchar(64) COMMENT '容器ID',
|
||||
`name` varchar(255) COMMENT '容器名称',
|
||||
`status` varchar(20) COMMENT '容器状态(running/stopped/error等)',
|
||||
`auto_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||
`cpu_util` varchar(10) COMMENT '容器CPU使用率(%)',
|
||||
`mem_util` varchar(10) COMMENT '容器内存使用率(%)',
|
||||
`net_in_speed` varchar(20) COMMENT '容器网络接收速率(KB/s)',
|
||||
`net_out_speed` varchar(20) COMMENT '容器网络发送速率(KB/s)',
|
||||
`client_id` varchar(255) COMMENT '设备唯一标识',
|
||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`create_by` varchar(20) COMMENT '创建人',
|
||||
`update_by` varchar(20) COMMENT '修改人',
|
||||
PRIMARY KEY (`auto_id`),
|
||||
UNIQUE INDEX `idx_unique_key`(`id`, `client_id`, `create_time`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT = '容器监控信息表';
|
||||
</update>
|
||||
<update id="createMountPointInfo">
|
||||
CREATE TABLE ${tableName} (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增主键ID',
|
||||
`client_id` varchar(255) NOT NULL COMMENT '客户端ID',
|
||||
`mount` varchar(255) NOT NULL COMMENT '挂载点路径(如\"/\"、\"/data\"等)',
|
||||
`vfs_type` varchar(50) COMMENT '文件系统类型(如ext4、xfs、ntfs等)',
|
||||
`vfs_free` bigint(20) COMMENT '可用空间(字节)',
|
||||
`vfs_total` bigint(20) COMMENT '总空间(字节)',
|
||||
`vfs_util` double(5, 2) COMMENT '空间利用率(%)',
|
||||
`create_by` varchar(50) COMMENT '创建人',
|
||||
`update_by` varchar(50) COMMENT '更新人',
|
||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE INDEX `idx_unique_key`(`client_id`, `mount`, `create_time`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT = '挂载点监控信息表';
|
||||
</update>
|
||||
|
||||
<!-- 单条插入语句 -->
|
||||
<insert id="insert">
|
||||
INSERT INTO ${tableName} (
|
||||
|
||||
+4
-4
@@ -336,12 +336,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
d.client_id as clientId,
|
||||
d.cores as cpuCores,
|
||||
d.uti as cpuUtil
|
||||
FROM initial_cpu_info d
|
||||
FROM ${tableName} d
|
||||
INNER JOIN (
|
||||
SELECT
|
||||
client_id,
|
||||
MAX(create_time) as latest_time
|
||||
FROM initial_cpu_info
|
||||
FROM ${tableName}
|
||||
WHERE client_id in
|
||||
<foreach collection="clientIdsStr.split(',')" item="clientId" open="(" separator="," close=")">
|
||||
#{clientId}
|
||||
@@ -354,12 +354,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
SELECT
|
||||
d.client_id as clientId,
|
||||
ROUND(d.collect_value, 1) as memUtil
|
||||
FROM initial_system_other_collect_data d
|
||||
FROM ${tableName} d
|
||||
INNER JOIN (
|
||||
SELECT
|
||||
client_id,
|
||||
MAX(create_time) as max_time
|
||||
FROM initial_system_other_collect_data
|
||||
FROM ${tableName}
|
||||
WHERE collect_type='memoryUtilizationCollect'
|
||||
AND client_id in
|
||||
<foreach collection="clientIdsStr.split(',')" item="clientId" open="(" separator="," close=")">
|
||||
|
||||
Reference in New Issue
Block a user