1、适配cpu信息表、容器信息表、挂载点信息表分表。

2、agent增加采集磁盘健康状态。
3、优化磁盘上报数据处理。
This commit is contained in:
gaoyutao
2026-02-05 18:04:34 +08:00
parent 0fb6a33f2e
commit 60db343cb0
42 changed files with 1455 additions and 77 deletions
@@ -115,7 +115,7 @@
</foreach>
</delete>
<insert id="batchInsertAllDistName" parameterType="java.util.List">
insert IGNORE into all_disk_name
insert into all_disk_name
(client_id, name, status, read_iops, write_iops, umount_flag, create_time, update_time, create_by, update_by)
values
<foreach collection="list" item="item" separator=",">
@@ -132,6 +132,8 @@
#{item.updateBy}
)
</foreach>
ON DUPLICATE KEY UPDATE
status = 1
</insert>
<select id="selectDiskInfoList" parameterType="AllDiskName" resultType="AllDiskName">
@@ -150,7 +152,8 @@
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
TRUNCATE(IFNULL(b.used_space,0)/(1024 * 1024 * 1024), 0) as usedSpace,
b.health_status as healthStatus
FROM all_disk_name a
LEFT JOIN (
SELECT client_id, name, MAX(create_time) as max_create_time
@@ -0,0 +1,92 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tongran.rocketmq.mapper.AllDockerNameMapper">
<resultMap type="AllDockerName" id="AllDockerNameResult">
<result property="id" column="id" />
<result property="clientId" column="client_id" />
<result property="dockerId" column="docker_id" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="createBy" column="create_by" />
<result property="updateBy" column="update_by" />
</resultMap>
<sql id="selectAllDockerNameVo">
select id, client_id, docker_id, create_time, update_time, create_by, update_by from all_docker_name
</sql>
<select id="selectAllDockerNameList" parameterType="AllDockerName" resultMap="AllDockerNameResult">
<include refid="selectAllDockerNameVo"/>
<where>
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
<if test="dockerId != null and dockerId != ''"> and docker_id = #{dockerId}</if>
</where>
</select>
<select id="selectAllDockerNameById" parameterType="Long" resultMap="AllDockerNameResult">
<include refid="selectAllDockerNameVo"/>
where id = #{id}
</select>
<insert id="insertAllDockerName" parameterType="AllDockerName" useGeneratedKeys="true" keyProperty="id">
insert into all_docker_name
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="clientId != null">client_id,</if>
<if test="dockerId != null">docker_id,</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>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="clientId != null">#{clientId},</if>
<if test="dockerId != null">#{dockerId},</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>
</insert>
<update id="updateAllDockerName" parameterType="AllDockerName">
update all_docker_name
<trim prefix="SET" suffixOverrides=",">
<if test="clientId != null">client_id = #{clientId},</if>
<if test="dockerId != null">docker_id = #{dockerId},</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>
</trim>
where id = #{id}
</update>
<delete id="deleteAllDockerNameById" parameterType="Long">
delete from all_docker_name where id = #{id}
</delete>
<delete id="deleteAllDockerNameByIds" parameterType="String">
delete from all_docker_name where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<insert id="batchInsertAllDockerId" parameterType="java.util.List">
insert IGNORE into all_docker_name
(client_id, docker_id, create_time, update_time, create_by, update_by)
values
<foreach collection="list" item="item" separator=",">
(
#{item.clientId},
#{item.dockerId},
#{item.createTime},
#{item.updateTime},
#{item.createBy},
#{item.updateBy}
)
</foreach>
</insert>
</mapper>
@@ -0,0 +1,92 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tongran.rocketmq.mapper.AllMountNameMapper">
<resultMap type="AllMountName" id="AllMountNameResult">
<result property="id" column="id" />
<result property="clientId" column="client_id" />
<result property="mount" column="mount" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="createBy" column="create_by" />
<result property="updateBy" column="update_by" />
</resultMap>
<sql id="selectAllMountNameVo">
select id, client_id, mount, create_time, update_time, create_by, update_by from all_mount_name
</sql>
<select id="selectAllMountNameList" parameterType="AllMountName" resultMap="AllMountNameResult">
<include refid="selectAllMountNameVo"/>
<where>
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
<if test="mount != null and mount != ''"> and mount = #{mount}</if>
</where>
</select>
<select id="selectAllMountNameById" parameterType="Long" resultMap="AllMountNameResult">
<include refid="selectAllMountNameVo"/>
where id = #{id}
</select>
<insert id="insertAllMountName" parameterType="AllMountName" useGeneratedKeys="true" keyProperty="id">
insert into all_mount_name
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="clientId != null">client_id,</if>
<if test="mount != null">mount,</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>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="clientId != null">#{clientId},</if>
<if test="mount != null">#{mount},</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>
</insert>
<update id="updateAllMountName" parameterType="AllMountName">
update all_mount_name
<trim prefix="SET" suffixOverrides=",">
<if test="clientId != null">client_id = #{clientId},</if>
<if test="mount != null">mount = #{mount},</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>
</trim>
where id = #{id}
</update>
<delete id="deleteAllMountNameById" parameterType="Long">
delete from all_mount_name where id = #{id}
</delete>
<delete id="deleteAllMountNameByIds" parameterType="String">
delete from all_mount_name where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<insert id="batchInsertAllMount" parameterType="java.util.List">
insert IGNORE into all_mount_name
(client_id, mount, create_time, update_time, create_by, update_by)
values
<foreach collection="list" item="item" separator=",">
(
#{item.clientId},
#{item.mount},
#{item.createTime},
#{item.updateTime},
#{item.createBy},
#{item.updateBy}
)
</foreach>
</insert>
</mapper>
@@ -155,8 +155,8 @@
</foreach>
</delete>
<insert id="batchInsertInitialCpuInfo" parameterType="java.util.List">
INSERT IGNORE INTO initial_cpu_info
<insert id="batchInsertInitialCpuInfo" parameterType="InitialCpuInfo">
INSERT IGNORE INTO ${tableName}
(
client_id,
avg1,
@@ -218,10 +218,45 @@
</foreach>
</insert>
<select id="getCpuInfoByClientId" parameterType="String" resultMap="InitialCpuInfoResult">
<include refid="selectInitialCpuInfoVo"/>
<select id="getCpuInfoByClientId" resultMap="InitialCpuInfoResult">
select
id, client_id, avg1, avg5, avg15, interrupt, uti, num, cores,normal,idle,iowait,system,
noresp,user,temperature,create_by,update_by,create_time,update_time
from ${tableName}
where client_id = #{clientId}
order by create_time desc
limit 1
</select>
<select id="selectInitialCpuInfoListByCondition" parameterType="InitialCpuInfo" resultMap="InitialCpuInfoResult">
select
id,
client_id,
avg1,
avg5,
avg15,
interrupt,
uti,
num,
cores,
normal,
idle,
iowait,
system,
noresp,
user,
temperature,
create_by,
update_by,
create_time,
update_time
from ${tableName}
<where>
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
<if test="temperature != null"> and temperature = #{temperature}</if>
<if test="startTime != null and startTime != ''"> and create_time &gt;= #{startTime}</if>
<if test="endTime != null and endTime != ''"> and create_time &lt;= #{endTime}</if>
</where>
order by create_time desc
</select>
</mapper>
@@ -19,6 +19,7 @@
<!-- 新增的两个字段 -->
<result property="type" column="type" />
<result property="usedSpace" column="used_space" />
<result property="healthStatus" column="health_status" />
<result property="createBy" column="create_by" />
<result property="updateBy" column="update_by" />
<result property="createTime" column="create_time" />
@@ -42,7 +43,7 @@
</select>
<select id="selectInitialDiskInfoListByCondition" parameterType="InitialDiskInfo" resultMap="InitialDiskInfoResult">
select id, client_id, name, serial, total, write_speed, read_speed, write_times, read_times, write_bytes,
read_bytes, type, used_space, create_by, update_by, create_time, update_time
read_bytes, type, used_space,health_status, create_by, update_by, create_time, update_time
from ${tableName}
<where>
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
@@ -154,6 +155,7 @@
read_bytes,
type,
used_space,
health_status,
create_by,
update_by,
create_time,
@@ -175,6 +177,7 @@
#{item.readBytes},
#{item.type},
#{item.usedSpace},
#{item.healthStatus},
#{item.createBy},
#{item.updateBy},
<choose>
@@ -199,7 +202,7 @@
<select id="getDistDetailsMsgByClientId" parameterType="InitialDiskInfo" resultMap="InitialDiskInfoResult">
select id, client_id, name, serial, total, write_speed, read_speed, write_times, read_times, write_bytes,
read_bytes, type, used_space, create_by, update_by, create_time, update_time
read_bytes, type, used_space,health_status, create_by, update_by, create_time, update_time
from ${tableName}
where client_id = #{clientId} and `name`= #{name}
order by create_time desc
@@ -102,8 +102,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</delete>
<insert id="batchInsertInitialDockerInfo" parameterType="java.util.List">
INSERT IGNORE INTO initial_docker_info
<insert id="batchInsertInitialDockerInfo" parameterType="InitialDockerInfo">
INSERT IGNORE INTO ${tableName}
(
`id`,
`name`,
@@ -152,16 +152,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</insert>
<select id="getDockerDetailsMsg" parameterType="InitialDockerInfo" resultMap="InitialDockerInfoResult">
<include refid="selectInitialDockerInfoVo"/>
select auto_id, id, name, status, cpu_util, mem_util, net_in_speed, net_out_speed, client_id, create_time, update_time, create_by, update_by from ${tableName}
where client_id = #{clientId} and `id` = #{id}
order by create_time desc
limit 1
</select>
<select id="getAllDockerId" parameterType="String" resultType="java.util.Map">
select id from initial_docker_info
select docker_id id from all_docker_name
<where>
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
</where>
group by id
</select>
<select id="selectInitialDockerInfoListByCondition" parameterType="InitialDockerInfo" resultMap="InitialDockerInfoResult">
select auto_id, id, name, status, cpu_util, mem_util, net_in_speed, net_out_speed, client_id, create_time, update_time, create_by, update_by from ${tableName}
<where>
<if test="id != null"> and id = #{id}</if>
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
<if test="startTime != null and startTime != ''"> and create_time &gt;= #{startTime}</if>
<if test="endTime != null and endTime != ''"> and create_time &lt;= #{endTime}</if>
</where>
order by create_time desc
</select>
</mapper>
@@ -94,8 +94,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</delete>
<insert id="batchInsertInitialMountPointInfo" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
INSERT IGNORE INTO initial_mount_point_info
<insert id="batchInsertInitialMountPointInfo" parameterType="java.util.List">
INSERT IGNORE INTO ${tableName}
(
client_id,
mount,
@@ -140,7 +140,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</insert>
<select id="pointDetailsMsg" parameterType="InitialMountPointInfo" resultMap="InitialMountPointInfoResult">
<include refid="selectInitialMountPointInfoVo"/>
select id, client_id, mount, vfs_type, vfs_free, vfs_total, vfs_util, create_by, update_by, create_time, update_time from ${tableName}
<where>
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
<if test="mount != null and mount != ''"> and mount = #{mount}</if>
@@ -149,10 +149,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
limit 1
</select>
<select id="getAllMountName" parameterType="String" resultType="java.util.Map">
select mount from initial_mount_point_info
select mount from all_mount_name
<where>
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
</where>
group by mount
</select>
<select id="selectInitialMountPointInfoListByCondition" parameterType="InitialMountPointInfo" resultMap="InitialMountPointInfoResult">
select id, client_id, mount, vfs_type, vfs_free, vfs_total, vfs_util, create_by, update_by, create_time, update_time from ${tableName}
<where>
<if test="mount != null and mount != ''"> and mount = #{mount}</if>
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
<if test="startTime != null and startTime != ''"> and create_time &gt;= #{startTime}</if>
<if test="endTime != null and endTime != ''"> and create_time &lt;= #{endTime}</if>
</where>
order by create_time desc
</select>
</mapper>