feat: MonitorsController Chinese and English support #huacheng (#85)
This commit is contained in:
@@ -15,6 +15,7 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 采集job管理提供api接口
|
||||
*
|
||||
* @author tomsun28
|
||||
* @date 2021/11/6 13:58
|
||||
*/
|
||||
@@ -27,6 +28,7 @@ public class CollectJobService {
|
||||
|
||||
/**
|
||||
* 执行一次性采集任务,获取采集数据响应
|
||||
*
|
||||
* @param job 采集任务详情
|
||||
* @return 采集结果
|
||||
*/
|
||||
@@ -52,9 +54,11 @@ public class CollectJobService {
|
||||
}
|
||||
|
||||
/**
|
||||
* Issue periodic asynchronous collection tasks
|
||||
* 下发周期性异步采集任务
|
||||
* @param job 采集任务详情
|
||||
* @return long 任务ID
|
||||
*
|
||||
* @param job Collect task details 采集任务详情
|
||||
* @return long Job ID 任务ID
|
||||
*/
|
||||
public long addAsyncCollectJob(Job job) {
|
||||
if (job.getId() == 0L) {
|
||||
@@ -66,8 +70,10 @@ public class CollectJobService {
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the periodic asynchronous collection tasks that have been delivered
|
||||
* 更新已经下发的周期性异步采集任务
|
||||
* @param modifyJob 采集任务详情
|
||||
*
|
||||
* @param modifyJob Collect task details 采集任务详情
|
||||
*/
|
||||
public void updateAsyncCollectJob(Job modifyJob) {
|
||||
timerDispatch.deleteJob(modifyJob.getId(), true);
|
||||
@@ -75,8 +81,10 @@ public class CollectJobService {
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel periodic asynchronous collection tasks
|
||||
* 取消周期性异步采集任务
|
||||
* @param jobId 任务ID
|
||||
*
|
||||
* @param jobId Job ID 任务ID
|
||||
*/
|
||||
public void cancelAsyncCollectJob(Long jobId) {
|
||||
timerDispatch.deleteJob(jobId, true);
|
||||
|
||||
@@ -10,36 +10,42 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 时间轮调度接口
|
||||
*
|
||||
* @author tomsun28
|
||||
* @date 2021/10/17 22:14
|
||||
*/
|
||||
public interface TimerDispatch {
|
||||
|
||||
/**
|
||||
* Add new job
|
||||
* 增加新的job
|
||||
* @param addJob job
|
||||
* @param eventListener 一次性同步任务监听器,异步任务不需要listener
|
||||
*
|
||||
* @param addJob job
|
||||
* @param eventListener One-time synchronous task listener, asynchronous task does not need listener一次性同步任务监听器,异步任务不需要listener
|
||||
*/
|
||||
void addJob(Job addJob, CollectResponseEventListener eventListener);
|
||||
|
||||
/**
|
||||
* 调度循环周期性job
|
||||
*
|
||||
* @param timerTask timerTask
|
||||
* @param interval 开始调度的间隔时间
|
||||
* @param timeUnit 时间单位
|
||||
* @param interval 开始调度的间隔时间
|
||||
* @param timeUnit 时间单位
|
||||
*/
|
||||
void cyclicJob(WheelTimerTask timerTask, long interval, TimeUnit timeUnit);
|
||||
|
||||
/**
|
||||
* 删除存在的job
|
||||
* @param jobId jobId
|
||||
*
|
||||
* @param jobId jobId
|
||||
* @param isCyclic 是否是周期性任务,true是, false为临时性任务
|
||||
*/
|
||||
void deleteJob(long jobId, boolean isCyclic);
|
||||
|
||||
/**
|
||||
* 一次性同步采集任务采集结果通知监听器
|
||||
* @param jobId jobId
|
||||
*
|
||||
* @param jobId jobId
|
||||
* @param metricsDataTemps 采集结果数据
|
||||
*/
|
||||
void responseSyncJobData(long jobId, List<CollectRep.MetricsData> metricsDataTemps);
|
||||
|
||||
@@ -22,7 +22,9 @@ import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_ONLY;
|
||||
import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_WRITE;
|
||||
|
||||
/**
|
||||
* Monitor Entity
|
||||
* 监控实体
|
||||
*
|
||||
* @author tomsun28
|
||||
* @date 2021/11/14 9:53
|
||||
*/
|
||||
@@ -32,10 +34,11 @@ import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_WRITE;
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ApiModel(description = "监控实体")
|
||||
@ApiModel(description = "en: Monitor Entity,zh: 监控实体")
|
||||
public class Monitor {
|
||||
|
||||
/**
|
||||
* Monitor ID
|
||||
* 主键ID
|
||||
*/
|
||||
@Id
|
||||
@@ -43,12 +46,14 @@ public class Monitor {
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* Job ID
|
||||
* 监控对应下发的任务ID
|
||||
*/
|
||||
@ApiModelProperty(value = "任务ID", example = "43243543543", accessMode = READ_ONLY, position = 1)
|
||||
private Long jobId;
|
||||
|
||||
/**
|
||||
* Monitor Name
|
||||
* 监控的名称
|
||||
*/
|
||||
@ApiModelProperty(value = "监控名称", example = "Api-TanCloud.cn", accessMode = READ_WRITE, position = 2)
|
||||
@@ -56,6 +61,7 @@ public class Monitor {
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* Type of monitoring: linux, mysql, jvm...
|
||||
* 监控的类型:linux,mysql,jvm...
|
||||
*/
|
||||
@ApiModelProperty(value = "监控类型", example = "TanCloud", accessMode = READ_WRITE, position = 3)
|
||||
@@ -63,6 +69,7 @@ public class Monitor {
|
||||
private String app;
|
||||
|
||||
/**
|
||||
* Monitored peer host: ipv4, ipv6, domain name
|
||||
* 监控的对端host:ipv4,ipv6,域名
|
||||
*/
|
||||
@ApiModelProperty(value = "监控的对端host", example = "192.167.25.11", accessMode = READ_WRITE, position = 4)
|
||||
@@ -71,6 +78,7 @@ public class Monitor {
|
||||
private String host;
|
||||
|
||||
/**
|
||||
* Monitoring collection interval time, in seconds
|
||||
* 监控的采集间隔时间,单位秒
|
||||
*/
|
||||
@ApiModelProperty(value = "监控的采集间隔时间,单位秒", example = "600", accessMode = READ_WRITE, position = 5)
|
||||
@@ -78,6 +86,7 @@ public class Monitor {
|
||||
private Integer intervals;
|
||||
|
||||
/**
|
||||
* Monitoring status 0: Unmonitored, 1: Available, 2: Unavailable, 3: Unreachable, 4: Suspended
|
||||
* 监控状态 0:未监控,1:可用,2:不可用,3:不可达,4:挂起
|
||||
*/
|
||||
@ApiModelProperty(value = "监控状态 0:未监控,1:可用,2:不可用,3:不可达,4:挂起", accessMode = READ_WRITE, position = 6)
|
||||
@@ -86,6 +95,7 @@ public class Monitor {
|
||||
private byte status;
|
||||
|
||||
/**
|
||||
* Monitoring note description
|
||||
* 监控备注描述
|
||||
*/
|
||||
@ApiModelProperty(value = "监控备注描述", example = "对SAAS网站TanCloud的可用性监控", accessMode = READ_WRITE, position = 7)
|
||||
@@ -93,18 +103,21 @@ public class Monitor {
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* The creator of this record
|
||||
* 此条记录创建者
|
||||
*/
|
||||
@ApiModelProperty(value = "此条记录创建者", example = "tom", accessMode = READ_ONLY, position = 8)
|
||||
private String creator;
|
||||
|
||||
/**
|
||||
* This record was last modified by
|
||||
* 此条记录最新修改者
|
||||
*/
|
||||
@ApiModelProperty(value = "此条记录最新修改者", example = "tom", accessMode = READ_ONLY, position = 9)
|
||||
private String modifier;
|
||||
|
||||
/**
|
||||
* record creation time (millisecond timestamp)
|
||||
* 记录创建时间
|
||||
*/
|
||||
@ApiModelProperty(value = "记录创建时间(毫秒时间戳)", example = "1612198922000", accessMode = READ_ONLY, position = 10)
|
||||
@@ -112,6 +125,7 @@ public class Monitor {
|
||||
private LocalDateTime gmtCreate;
|
||||
|
||||
/**
|
||||
* Record the latest modification time (timestamp in milliseconds)
|
||||
* 记录最新修改时间
|
||||
*/
|
||||
@ApiModelProperty(value = "记录最新修改时间(毫秒时间戳)", example = "1612198444000", accessMode = READ_ONLY, position = 11)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.usthe.common.util;
|
||||
|
||||
/**
|
||||
* Snowflake Algorithm Generator Tool
|
||||
* 雪花算法生成器工具
|
||||
*
|
||||
* @author tomsun28
|
||||
* @date 2021/11/10 11:04
|
||||
*/
|
||||
|
||||
@@ -29,11 +29,13 @@ import java.util.List;
|
||||
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
|
||||
|
||||
/**
|
||||
* Monitor and manage batch API
|
||||
* 监控管理批量API
|
||||
*
|
||||
* @author tom
|
||||
* @date 2021/12/1 20:43
|
||||
*/
|
||||
@Api(tags = "监控列表API")
|
||||
@Api(tags = "en: Monitor and manage batch API,zh: 监控列表API")
|
||||
@RestController
|
||||
@RequestMapping(path = "/monitors", produces = {APPLICATION_JSON_VALUE})
|
||||
public class MonitorsController {
|
||||
@@ -44,22 +46,23 @@ public class MonitorsController {
|
||||
private MonitorService monitorService;
|
||||
|
||||
@GetMapping
|
||||
@ApiOperation(value = "查询监控列表", notes = "根据查询过滤项获取监控信息列表")
|
||||
@ApiOperation(value = "Obtain a list of monitoring information based on query filter items",
|
||||
notes = "根据查询过滤项获取监控信息列表")
|
||||
public ResponseEntity<Message<Page<Monitor>>> getMonitors(
|
||||
@ApiParam(value = "监控ID", example = "6565463543") @RequestParam(required = false) final List<Long> ids,
|
||||
@ApiParam(value = "监控类型", example = "linux") @RequestParam(required = false) final String app,
|
||||
@ApiParam(value = "监控名称,模糊查询", example = "linux-127.0.0.1") @RequestParam(required = false) final String name,
|
||||
@ApiParam(value = "监控Host,模糊查询", example = "127.0.0.1") @RequestParam(required = false) final String host,
|
||||
@ApiParam(value = "监控状态 0:未监控,1:可用,2:不可用,3:不可达,4:挂起,9:全部状态", example = "1") @RequestParam(required = false) final Byte status,
|
||||
@ApiParam(value = "排序字段,默认id", example = "name") @RequestParam(defaultValue = "id") final String sort,
|
||||
@ApiParam(value = "排序方式,asc:升序,desc:降序", example = "desc") @RequestParam(defaultValue = "desc") final String order,
|
||||
@ApiParam(value = "列表当前分页", example = "0") @RequestParam(defaultValue = "0") int pageIndex,
|
||||
@ApiParam(value = "列表分页数量", example = "8") @RequestParam(defaultValue = "8") int pageSize) {
|
||||
@ApiParam(value = "en: Monitor ID,zh: 监控ID", example = "6565463543") @RequestParam(required = false) final List<Long> ids,
|
||||
@ApiParam(value = "en: Monitor Type,zh: 监控类型", example = "linux") @RequestParam(required = false) final String app,
|
||||
@ApiParam(value = "en: Monitor Name,zh: 监控名称,模糊查询", example = "linux-127.0.0.1") @RequestParam(required = false) final String name,
|
||||
@ApiParam(value = "en: Monitor Host,zh: 监控Host,模糊查询", example = "127.0.0.1") @RequestParam(required = false) final String host,
|
||||
@ApiParam(value = "en: Monitor Status,zh: 监控状态 0:未监控,1:可用,2:不可用,3:不可达,4:挂起,9:全部状态", example = "1") @RequestParam(required = false) final Byte status,
|
||||
@ApiParam(value = "en: Sort Field,default id,zh: 排序字段,默认id", example = "name") @RequestParam(defaultValue = "id") final String sort,
|
||||
@ApiParam(value = "en: Sort by,zh: 排序方式,asc:升序,desc:降序", example = "desc") @RequestParam(defaultValue = "desc") final String order,
|
||||
@ApiParam(value = "en: List current page,zh: 列表当前分页", example = "0") @RequestParam(defaultValue = "0") int pageIndex,
|
||||
@ApiParam(value = "en: Number of list pagination,zh: 列表分页数量", example = "8") @RequestParam(defaultValue = "8") int pageSize) {
|
||||
|
||||
Specification<Monitor> specification = (root, query, criteriaBuilder) -> {
|
||||
List<Predicate> andList = new ArrayList<>();
|
||||
if (ids != null && !ids.isEmpty()) {
|
||||
CriteriaBuilder.In<Long> inPredicate= criteriaBuilder.in(root.get("id"));
|
||||
CriteriaBuilder.In<Long> inPredicate = criteriaBuilder.in(root.get("id"));
|
||||
for (long id : ids) {
|
||||
inPredicate.value(id);
|
||||
}
|
||||
@@ -95,10 +98,10 @@ public class MonitorsController {
|
||||
} else if (orPredicate.getExpressions().isEmpty()) {
|
||||
return query.where(andPredicate).getRestriction();
|
||||
} else {
|
||||
return query.where(andPredicate,orPredicate).getRestriction();
|
||||
return query.where(andPredicate, orPredicate).getRestriction();
|
||||
}
|
||||
};
|
||||
// 分页是必须的
|
||||
// Pagination is a must 分页是必须的
|
||||
Sort sortExp = Sort.by(new Sort.Order(Sort.Direction.fromString(order), sort));
|
||||
PageRequest pageRequest = PageRequest.of(pageIndex, pageSize, sortExp);
|
||||
Page<Monitor> monitorPage = monitorService.getMonitors(specification, pageRequest);
|
||||
@@ -107,18 +110,20 @@ public class MonitorsController {
|
||||
}
|
||||
|
||||
@GetMapping(path = "/{app}")
|
||||
@ApiOperation(value = "查询指定监控类型的监控列表", notes = "根据查询过滤指定监控类型的所有获取监控信息列表")
|
||||
@ApiOperation(value = "Filter all acquired monitoring information lists of the specified monitoring type according to the query",
|
||||
notes = "根据查询过滤指定监控类型的所有获取监控信息列表")
|
||||
public ResponseEntity<Message<List<Monitor>>> getAppMonitors(
|
||||
@ApiParam(value = "监控类型", example = "linux") @PathVariable(required = false) final String app) {
|
||||
@ApiParam(value = "en: Monitoring type,zh: 监控类型", example = "linux") @PathVariable(required = false) final String app) {
|
||||
List<Monitor> monitors = monitorService.getAppMonitors(app);
|
||||
Message<List<Monitor>> message = new Message<>(monitors);
|
||||
return ResponseEntity.ok(message);
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@ApiOperation(value = "批量删除监控", notes = "根据监控ID列表批量删除监控项")
|
||||
@ApiOperation(value = "Delete monitoring items in batches according to the monitoring ID list",
|
||||
notes = "根据监控ID列表批量删除监控项")
|
||||
public ResponseEntity<Message<Void>> deleteMonitors(
|
||||
@ApiParam(value = "监控IDs", example = "6565463543") @RequestParam(required = false) List<Long> ids
|
||||
@ApiParam(value = "en: Monitoring ID List,zh: 监控ID列表", example = "6565463543") @RequestParam(required = false) List<Long> ids
|
||||
) {
|
||||
if (ids != null && !ids.isEmpty()) {
|
||||
monitorService.deleteMonitors(new HashSet<>(ids));
|
||||
@@ -128,9 +133,10 @@ public class MonitorsController {
|
||||
}
|
||||
|
||||
@DeleteMapping("manage")
|
||||
@ApiOperation(value = "批量取消纳管监控", notes = "根据监控ID列表批量取消纳管监控项")
|
||||
@ApiOperation(value = "Unmanaged monitoring items in batches according to the monitoring ID list",
|
||||
notes = "根据监控ID列表批量取消纳管监控项")
|
||||
public ResponseEntity<Message<Void>> cancelManageMonitors(
|
||||
@ApiParam(value = "监控IDs", example = "6565463543") @RequestParam(required = false) List<Long> ids
|
||||
@ApiParam(value = "en: Monitoring ID List,zh: 监控ID列表", example = "6565463543") @RequestParam(required = false) List<Long> ids
|
||||
) {
|
||||
if (ids != null && !ids.isEmpty()) {
|
||||
monitorService.cancelManageMonitors(new HashSet<>(ids));
|
||||
@@ -140,9 +146,10 @@ public class MonitorsController {
|
||||
}
|
||||
|
||||
@GetMapping("manage")
|
||||
@ApiOperation(value = "批量启动纳管监控", notes = "根据监控ID列表批量启动纳管监控项")
|
||||
@ApiOperation(value = "Start the managed monitoring items in batches according to the monitoring ID list",
|
||||
notes = "根据监控ID列表批量启动纳管监控项")
|
||||
public ResponseEntity<Message<Void>> enableManageMonitors(
|
||||
@ApiParam(value = "监控IDs", example = "6565463543") @RequestParam(required = false) List<Long> ids
|
||||
@ApiParam(value = "en: Monitor ID List,zh: 监控ID列表", example = "6565463543") @RequestParam(required = false) List<Long> ids
|
||||
) {
|
||||
if (ids != null && !ids.isEmpty()) {
|
||||
monitorService.enableManageMonitors(new HashSet<>(ids));
|
||||
|
||||
@@ -22,33 +22,37 @@ public interface MonitorDao extends JpaRepository<Monitor, Long>, JpaSpecificati
|
||||
|
||||
|
||||
/**
|
||||
* Delete monitor based on monitor ID list
|
||||
* 根据监控ID列表删除监控
|
||||
*
|
||||
* @param monitorIds 监控ID列表
|
||||
* @param monitorIds Monitoring ID List 监控ID列表
|
||||
*/
|
||||
void deleteAllByIdIn(Set<Long> monitorIds);
|
||||
|
||||
/**
|
||||
* Query monitoring based on monitoring ID list
|
||||
* 根据监控ID列表查询监控
|
||||
*
|
||||
* @param monitorIds 监控ID列表
|
||||
* @return 监控列表
|
||||
* @param monitorIds Monitoring ID List 监控ID列表
|
||||
* @return Monitor List 监控列表
|
||||
*/
|
||||
List<Monitor> findMonitorsByIdIn(Set<Long> monitorIds);
|
||||
|
||||
/**
|
||||
* Query monitoring by monitoring type
|
||||
* 根据监控类型查询监控
|
||||
*
|
||||
* @param app 监控类型
|
||||
* @return 监控列表
|
||||
* @param app Monitor Type 监控类型
|
||||
* @return Monitor List 监控列表
|
||||
*/
|
||||
List<Monitor> findMonitorsByAppEquals(String app);
|
||||
|
||||
/**
|
||||
* Querying Monitoring of Sent Collection Tasks
|
||||
* 查询已下发采集任务的监控
|
||||
*
|
||||
* @param status 监控状态
|
||||
* @return 监控列表
|
||||
* @param status Monitor Status 监控状态
|
||||
* @return Monitor List 监控列表
|
||||
*/
|
||||
List<Monitor> findMonitorsByStatusNotInAndAndJobIdNotNull(List<Byte> status);
|
||||
|
||||
|
||||
@@ -67,49 +67,55 @@ public interface MonitorService {
|
||||
void deleteMonitor(long id) throws RuntimeException;
|
||||
|
||||
/**
|
||||
* Batch delete monitoring
|
||||
* 批量删除监控
|
||||
*
|
||||
* @param ids 监控ID
|
||||
* @throws RuntimeException 删除过程中异常抛出
|
||||
* @param ids Monitoring ID List 监控ID列表
|
||||
* @throws RuntimeException Exception thrown during deletion 删除过程中异常抛出
|
||||
*/
|
||||
void deleteMonitors(Set<Long> ids) throws RuntimeException;
|
||||
|
||||
/**
|
||||
* Get monitoring information
|
||||
* 获取监控信息
|
||||
*
|
||||
* @param id 监控ID
|
||||
* @return MonitorDto
|
||||
* @throws RuntimeException 查询过程中异常抛出
|
||||
* @param id Monitor ID 监控ID
|
||||
* @return MonitorDto Monitor Entity 監控实体
|
||||
* @throws RuntimeException Exception thrown during query 查询过程中异常抛出
|
||||
*/
|
||||
MonitorDto getMonitorDto(long id) throws RuntimeException;
|
||||
|
||||
/**
|
||||
* Dynamic conditional query
|
||||
* 动态条件查询
|
||||
*
|
||||
* @param specification 查询条件
|
||||
* @param pageRequest 分页参数
|
||||
* @return 查询结果
|
||||
* @param specification Query conditions 查询条件
|
||||
* @param pageRequest Pagination parameters 分页参数
|
||||
* @return Search Result 查询结果
|
||||
*/
|
||||
Page<Monitor> getMonitors(Specification<Monitor> specification, PageRequest pageRequest);
|
||||
|
||||
/**
|
||||
* Unmanaged monitoring items in batches according to the monitoring ID list
|
||||
* 根据监控ID列表批量取消纳管监控项
|
||||
*
|
||||
* @param ids 监控IDs
|
||||
* @param ids Monitoring ID List 监控ID列表
|
||||
*/
|
||||
void cancelManageMonitors(HashSet<Long> ids);
|
||||
|
||||
/**
|
||||
* Start the managed monitoring items in batches according to the monitoring ID list
|
||||
* 根据监控ID列表批量启动纳管监控项
|
||||
*
|
||||
* @param ids 监控IDs
|
||||
* @param ids Monitoring ID List 监控ID列表
|
||||
*/
|
||||
void enableManageMonitors(HashSet<Long> ids);
|
||||
|
||||
/**
|
||||
* Query the monitoring category and its corresponding monitoring quantity
|
||||
* 查询监控类别及其对应的监控数量
|
||||
*
|
||||
* @return 监控类别与监控数量映射
|
||||
* @return Monitoring Category and Monitoring Quantity Mapping 监控类别与监控数量映射
|
||||
*/
|
||||
List<AppCount> getAllAppMonitorsCount();
|
||||
|
||||
@@ -132,10 +138,11 @@ public interface MonitorService {
|
||||
void updateMonitorStatus(Long monitorId, byte status);
|
||||
|
||||
/**
|
||||
* Query the list of all monitoring information under the specified monitoring type
|
||||
* 查询指定监控类型下的所有监控信息列表
|
||||
*
|
||||
* @param app 监控类型
|
||||
* @return 监控列表
|
||||
* @param app Monitor Type 监控类型
|
||||
* @return Monitor Entity List 监控列表
|
||||
*/
|
||||
List<Monitor> getAppMonitors(String app);
|
||||
}
|
||||
|
||||
@@ -345,7 +345,9 @@ public class MonitorServiceImpl implements MonitorService {
|
||||
|
||||
@Override
|
||||
public void cancelManageMonitors(HashSet<Long> ids) {
|
||||
// Update monitoring status Delete corresponding monitoring periodic task
|
||||
// 更新监控状态 删除对应的监控周期性任务
|
||||
// The jobId is not deleted, and the jobId is reused again after the management is started.
|
||||
// jobId不删除 待启动纳管之后再次复用jobId
|
||||
List<Monitor> managedMonitors = monitorDao.findMonitorsByIdIn(ids)
|
||||
.stream().filter(monitor ->
|
||||
@@ -362,6 +364,7 @@ public class MonitorServiceImpl implements MonitorService {
|
||||
|
||||
@Override
|
||||
public void enableManageMonitors(HashSet<Long> ids) {
|
||||
// Update monitoring status Add corresponding monitoring periodic task
|
||||
// 更新监控状态 新增对应的监控周期性任务
|
||||
List<Monitor> unManagedMonitors = monitorDao.findMonitorsByIdIn(ids)
|
||||
.stream().filter(monitor ->
|
||||
@@ -371,6 +374,7 @@ public class MonitorServiceImpl implements MonitorService {
|
||||
if (!unManagedMonitors.isEmpty()) {
|
||||
monitorDao.saveAll(unManagedMonitors);
|
||||
for (Monitor monitor : unManagedMonitors) {
|
||||
// Construct the collection task Job entity
|
||||
// 构造采集任务Job实体
|
||||
Job appDefine = appService.getAppDefine(monitor.getApp());
|
||||
appDefine.setMonitorId(monitor.getId());
|
||||
@@ -381,7 +385,7 @@ public class MonitorServiceImpl implements MonitorService {
|
||||
List<Configmap> configmaps = params.stream().map(param ->
|
||||
new Configmap(param.getField(), param.getValue(), param.getType())).collect(Collectors.toList());
|
||||
appDefine.setConfigmap(configmaps);
|
||||
// 下发采集任务
|
||||
// Issue collection tasks 下发采集任务
|
||||
collectJobService.addAsyncCollectJob(appDefine);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user