Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
王蔡翾
operation_platform
Commits
454aef65
Commit
454aef65
authored
Mar 05, 2026
by
wujipeng
Browse files
服务器监控
parent
caaedc2f
Changes
15
Show whitespace changes
Inline
Side-by-side
src/main/java/com/example/operation_platform/controller/ProjectServerMonitorController.java
0 → 100644
View file @
454aef65
package
com.example.operation_platform.controller
;
import
com.example.operation_platform.model.dto.ProjectServerAlertsDTO
;
import
com.example.operation_platform.model.dto.ProjectServerMonitorDTO
;
import
com.example.operation_platform.model.vo.ProjectServerAlertsVO
;
import
com.example.operation_platform.model.vo.ProjectServerMonitorVO
;
import
com.example.operation_platform.service.ProjectServerAlertsService
;
import
com.example.operation_platform.service.ProjectServerMonitorService
;
import
com.platform.controller.BaseController
;
import
com.platform.model.resp.Result
;
import
com.platform.page.TableDataInfo
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.annotation.Resource
;
import
java.util.List
;
/**
* @author : wujipeng
* @date : 2026/3/5 10:06
* @Version: 1.0
* @Desc : 描述信息
*/
@RestController
@RequestMapping
(
"/project/server/monitor"
)
public
class
ProjectServerMonitorController
extends
BaseController
{
@Resource
private
ProjectServerMonitorService
projectServerMonitorService
;
@Resource
private
ProjectServerAlertsService
projectServerAlertsService
;
@ApiOperation
(
value
=
"ip列表"
)
@PostMapping
(
"/ip/list"
)
public
TableDataInfo
ipList
(
@RequestBody
ProjectServerMonitorDTO
projectServerMonitorDTO
)
{
startPage
(
projectServerMonitorDTO
.
getPageNum
(),
projectServerMonitorDTO
.
getPageSize
());
return
getDataTable
(
projectServerMonitorService
.
ipList
(
projectServerMonitorDTO
));
}
@ApiOperation
(
value
=
"实时数据"
)
@PostMapping
(
"/data/list"
)
public
Result
<
List
<
ProjectServerMonitorVO
>>
dataList
(
@RequestBody
ProjectServerMonitorDTO
projectServerMonitorDTO
)
{
return
Result
.
data
(
projectServerMonitorService
.
dataList
(
projectServerMonitorDTO
));
}
@ApiOperation
(
value
=
"最新告警信息"
)
@PostMapping
(
"/alerts/list"
)
public
Result
<
List
<
ProjectServerAlertsVO
>>
alertsList
(
@RequestBody
ProjectServerAlertsDTO
projectServerAlertsDTO
)
{
return
Result
.
data
(
projectServerAlertsService
.
alertsList
(
projectServerAlertsDTO
));
}
}
src/main/java/com/example/operation_platform/mapper/ProjectServerAlertsMapper.java
0 → 100644
View file @
454aef65
package
com.example.operation_platform.mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.example.operation_platform.model.dto.ProjectServerAlertsDTO
;
import
com.example.operation_platform.model.entity.ProjectServerAlertsEntity
;
import
com.example.operation_platform.model.vo.ProjectServerAlertsVO
;
import
org.apache.ibatis.annotations.Mapper
;
import
java.util.List
;
/**
* @author : wujipeng
* @date : 2026/3/5 11:37
* @Version: 1.0
* @Desc : 描述信息
*/
@Mapper
public
interface
ProjectServerAlertsMapper
extends
BaseMapper
<
ProjectServerAlertsEntity
>
{
List
<
ProjectServerAlertsVO
>
alertsList
(
ProjectServerAlertsDTO
projectServerAlertsDTO
);
}
src/main/java/com/example/operation_platform/mapper/ProjectServerMonitorMapper.java
0 → 100644
View file @
454aef65
package
com.example.operation_platform.mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.example.operation_platform.model.dto.ProjectServerMonitorDTO
;
import
com.example.operation_platform.model.entity.ProjectServerMonitorEntity
;
import
com.example.operation_platform.model.vo.ProjectServerMonitorVO
;
import
org.apache.ibatis.annotations.Mapper
;
import
java.util.List
;
/**
* @author : wujipeng
* @date : 2026/3/5 10:05
* @Version: 1.0
* @Desc : 描述信息
*/
@Mapper
public
interface
ProjectServerMonitorMapper
extends
BaseMapper
<
ProjectServerMonitorEntity
>
{
List
<
ProjectServerMonitorVO
>
ipList
(
ProjectServerMonitorDTO
projectServerMonitorDTO
);
List
<
ProjectServerMonitorVO
>
dataList
(
ProjectServerMonitorDTO
projectServerMonitorDTO
);
}
src/main/java/com/example/operation_platform/model/dto/ProjectServerAlertsDTO.java
0 → 100644
View file @
454aef65
package
com.example.operation_platform.model.dto
;
import
com.example.operation_platform.model.entity.ProjectServerAlertsEntity
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
/**
* @author : wujipeng
* @date : 2026/3/5 11:45
* @Version: 1.0
* @Desc : 描述信息
*/
@EqualsAndHashCode
(
callSuper
=
true
)
@Data
public
class
ProjectServerAlertsDTO
extends
ProjectServerAlertsEntity
{
}
src/main/java/com/example/operation_platform/model/dto/ProjectServerMonitorDTO.java
0 → 100644
View file @
454aef65
package
com.example.operation_platform.model.dto
;
import
com.example.operation_platform.model.entity.ProjectServerMonitorEntity
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
java.util.Date
;
/**
* @author : wujipeng
* @date : 2026/3/5 10:08
* @Version: 1.0
* @Desc : 描述信息
*/
@EqualsAndHashCode
(
callSuper
=
true
)
@Data
public
class
ProjectServerMonitorDTO
extends
ProjectServerMonitorEntity
{
@ApiModelProperty
(
value
=
"页码"
)
private
Integer
pageNum
;
@ApiModelProperty
(
value
=
"每页条数"
)
private
Integer
pageSize
;
@ApiModelProperty
(
value
=
"开始时间"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Date
startDate
;
@ApiModelProperty
(
value
=
"结束时间"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Date
endDate
;
}
src/main/java/com/example/operation_platform/model/entity/ProjectServerAlertsEntity.java
0 → 100644
View file @
454aef65
package
com.example.operation_platform.model.entity
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
lombok.Data
;
import
java.util.Date
;
/**
* @author : wujipeng
* @date : 2026/3/5 11:34
* @Version: 1.0
* @Desc : 描述信息
*/
@Data
@TableName
(
"project_server_alerts"
)
public
class
ProjectServerAlertsEntity
{
@TableId
(
type
=
IdType
.
AUTO
)
private
Integer
id
;
@TableField
(
"alert_time"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Date
alertTime
;
@TableField
(
"alert_type"
)
private
String
alertType
;
@TableField
(
"metric_value"
)
private
String
metricValue
;
private
String
threshold
;
@TableField
(
"ip_address"
)
private
String
ipAddress
;
private
String
description
;
private
Boolean
resolved
;
}
src/main/java/com/example/operation_platform/model/entity/ProjectServerMonitorEntity.java
0 → 100644
View file @
454aef65
package
com.example.operation_platform.model.entity
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
lombok.Data
;
import
java.util.Date
;
/**
* @author : wujipeng
* @date : 2026/3/5 10:00
* @Version: 1.0
* @Desc : 描述信息
*/
@Data
@TableName
(
"project_server_monitor"
)
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
public
class
ProjectServerMonitorEntity
{
@TableId
(
type
=
IdType
.
AUTO
)
private
Integer
id
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Date
timestamp
;
@TableField
(
value
=
"cpu_percent"
)
private
String
cpuPercent
;
@TableField
(
value
=
"memory_percent"
)
private
String
memoryPercent
;
@TableField
(
value
=
"read_count"
)
private
Integer
readCount
;
@TableField
(
value
=
"write_count"
)
private
Integer
writeCount
;
@TableField
(
value
=
"ip_address"
)
private
String
ipAddress
;
}
src/main/java/com/example/operation_platform/model/vo/ProjectServerAlertsVO.java
0 → 100644
View file @
454aef65
package
com.example.operation_platform.model.vo
;
import
com.example.operation_platform.model.entity.ProjectServerAlertsEntity
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
/**
* @author : wujipeng
* @date : 2026/3/5 11:46
* @Version: 1.0
* @Desc : 描述信息
*/
@EqualsAndHashCode
(
callSuper
=
true
)
@Data
public
class
ProjectServerAlertsVO
extends
ProjectServerAlertsEntity
{
}
src/main/java/com/example/operation_platform/model/vo/ProjectServerMonitorVO.java
0 → 100644
View file @
454aef65
package
com.example.operation_platform.model.vo
;
import
com.example.operation_platform.model.entity.ProjectServerMonitorEntity
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
/**
* @author : wujipeng
* @date : 2026/3/5 10:09
* @Version: 1.0
* @Desc : 描述信息
*/
@EqualsAndHashCode
(
callSuper
=
true
)
@Data
public
class
ProjectServerMonitorVO
extends
ProjectServerMonitorEntity
{
}
src/main/java/com/example/operation_platform/service/ProjectServerAlertsService.java
0 → 100644
View file @
454aef65
package
com.example.operation_platform.service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.example.operation_platform.model.dto.ProjectServerAlertsDTO
;
import
com.example.operation_platform.model.entity.ProjectServerAlertsEntity
;
import
com.example.operation_platform.model.vo.ProjectServerAlertsVO
;
import
java.util.List
;
/**
* @author : wujipeng
* @date : 2026/3/5 11:37
* @Version: 1.0
* @Desc : 描述信息
*/
public
interface
ProjectServerAlertsService
extends
IService
<
ProjectServerAlertsEntity
>
{
List
<
ProjectServerAlertsVO
>
alertsList
(
ProjectServerAlertsDTO
projectServerAlertsDTO
);
}
src/main/java/com/example/operation_platform/service/ProjectServerMonitorService.java
0 → 100644
View file @
454aef65
package
com.example.operation_platform.service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.example.operation_platform.model.dto.ProjectServerMonitorDTO
;
import
com.example.operation_platform.model.entity.ProjectServerMonitorEntity
;
import
com.example.operation_platform.model.vo.ProjectServerMonitorVO
;
import
java.util.List
;
/**
* @author : wujipeng
* @date : 2026/3/5 10:05
* @Version: 1.0
* @Desc : 描述信息
*/
public
interface
ProjectServerMonitorService
extends
IService
<
ProjectServerMonitorEntity
>
{
List
<
ProjectServerMonitorVO
>
ipList
(
ProjectServerMonitorDTO
projectServerMonitorDTO
);
List
<
ProjectServerMonitorVO
>
dataList
(
ProjectServerMonitorDTO
projectServerMonitorDTO
);
}
src/main/java/com/example/operation_platform/service/impl/ProjectServerAlertsServiceImpl.java
0 → 100644
View file @
454aef65
package
com.example.operation_platform.service.impl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.example.operation_platform.mapper.ProjectServerAlertsMapper
;
import
com.example.operation_platform.model.dto.ProjectServerAlertsDTO
;
import
com.example.operation_platform.model.entity.ProjectServerAlertsEntity
;
import
com.example.operation_platform.model.vo.ProjectServerAlertsVO
;
import
com.example.operation_platform.service.ProjectServerAlertsService
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
/**
* @author : wujipeng
* @date : 2026/3/5 11:38
* @Version: 1.0
* @Desc : 描述信息
*/
@Service
public
class
ProjectServerAlertsServiceImpl
extends
ServiceImpl
<
ProjectServerAlertsMapper
,
ProjectServerAlertsEntity
>
implements
ProjectServerAlertsService
{
@Override
public
List
<
ProjectServerAlertsVO
>
alertsList
(
ProjectServerAlertsDTO
projectServerAlertsDTO
)
{
return
baseMapper
.
alertsList
(
projectServerAlertsDTO
);
}
}
src/main/java/com/example/operation_platform/service/impl/ProjectServerMonitorServiceImpl.java
0 → 100644
View file @
454aef65
package
com.example.operation_platform.service.impl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.example.operation_platform.mapper.ProjectServerMonitorMapper
;
import
com.example.operation_platform.model.dto.ProjectServerMonitorDTO
;
import
com.example.operation_platform.model.entity.ProjectServerMonitorEntity
;
import
com.example.operation_platform.model.vo.ProjectServerMonitorVO
;
import
com.example.operation_platform.service.ProjectServerMonitorService
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
/**
* @author : wujipeng
* @date : 2026/3/5 10:05
* @Version: 1.0
* @Desc : 描述信息
*/
@Service
public
class
ProjectServerMonitorServiceImpl
extends
ServiceImpl
<
ProjectServerMonitorMapper
,
ProjectServerMonitorEntity
>
implements
ProjectServerMonitorService
{
@Override
public
List
<
ProjectServerMonitorVO
>
ipList
(
ProjectServerMonitorDTO
projectServerMonitorDTO
)
{
return
baseMapper
.
ipList
(
projectServerMonitorDTO
);
}
@Override
public
List
<
ProjectServerMonitorVO
>
dataList
(
ProjectServerMonitorDTO
projectServerMonitorDTO
)
{
return
baseMapper
.
dataList
(
projectServerMonitorDTO
);
}
}
src/main/resources/mapper/ProjectServerAlertsMapper.xml
0 → 100644
View file @
454aef65
<?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.example.operation_platform.mapper.ProjectServerAlertsMapper"
>
<select
id=
"alertsList"
resultType=
"com.example.operation_platform.model.vo.ProjectServerAlertsVO"
>
select
id,
alert_time,
alert_type,
metric_value,
threshold,
ip_address,
description,
resolved
from
project_server_alerts
where
ip_address = #{ipAddress}
order by
alert_time
limit 10
</select>
</mapper>
src/main/resources/mapper/ProjectServerMonitorMapper.xml
0 → 100644
View file @
454aef65
<?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.example.operation_platform.mapper.ProjectServerMonitorMapper"
>
<select
id=
"ipList"
resultType=
"com.example.operation_platform.model.vo.ProjectServerMonitorVO"
>
SELECT ip_address,cpu_percent,memory_percent
FROM (
SELECT *,
ROW_NUMBER() OVER (PARTITION BY ip_address ORDER BY timestamp DESC) as rn
FROM project_server_monitor
) t
WHERE t.rn = 1
</select>
<select
id=
"dataList"
resultType=
"com.example.operation_platform.model.vo.ProjectServerMonitorVO"
>
select
id,
timestamp,
cpu_percent,
memory_percent,
read_count,
write_count,
ip_address
from
project_server_monitor
<where>
<if
test=
"startDate != null"
>
and timestamp >= #{startDate}
</if>
<if
test=
"endDate != null"
>
and timestamp
<
= #{endDate}
</if>
<if
test=
"ipAddress != null and ipAddress != ''"
>
and ip_address = #{ipAddress}
</if>
</where>
order by timestamp
</select>
</mapper>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment