[ server ] [ scheduler ]- script scheduler add function
This commit is contained in:
@@ -10,6 +10,7 @@ import lombok.experimental.SuperBuilder;
|
|||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
import javax.validation.constraints.Null;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@@ -53,9 +54,16 @@ public class ScriptSchedulerVO {
|
|||||||
* 脚本任务的内容
|
* 脚本任务的内容
|
||||||
*/
|
*/
|
||||||
@TableField(value = "script_content")
|
@TableField(value = "script_content")
|
||||||
@NotNull
|
@Nullable
|
||||||
private String scriptContent;
|
private String scriptContent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 脚本任务的类型
|
||||||
|
*/
|
||||||
|
@TableField(value = "script_type")
|
||||||
|
@Nullable
|
||||||
|
private String scriptType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 执行目标机器agent_topic_name列表,使用, 分隔
|
* 执行目标机器agent_topic_name列表,使用, 分隔
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import io.wdd.rpc.execute.service.CoreExecutionService;
|
|||||||
import io.wdd.rpc.scheduler.beans.ScriptSchedulerDTO;
|
import io.wdd.rpc.scheduler.beans.ScriptSchedulerDTO;
|
||||||
import io.wdd.rpc.scheduler.config.QuartzSchedulerUtils;
|
import io.wdd.rpc.scheduler.config.QuartzSchedulerUtils;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
@@ -31,9 +32,15 @@ public class AgentApplyScheduledScript {
|
|||||||
|
|
||||||
HashMap<String, String> futureResultKeyMap = scriptSchedulerDTO.getAgentTopicNameToFutureResultKeyMap();
|
HashMap<String, String> futureResultKeyMap = scriptSchedulerDTO.getAgentTopicNameToFutureResultKeyMap();
|
||||||
|
|
||||||
|
// 新增-定时调用Nacos中预编辑脚本的内容
|
||||||
|
String scriptType = scriptSchedulerDTO.getScriptType();
|
||||||
|
if (StringUtils.isEmpty(scriptType)) {
|
||||||
|
scriptType = "Scheduled Script";
|
||||||
|
}
|
||||||
|
|
||||||
List<String> resultKeyList = coreExecutionService.SendCommandToAgentComplete(
|
List<String> resultKeyList = coreExecutionService.SendCommandToAgentComplete(
|
||||||
targetMachineList,
|
targetMachineList,
|
||||||
"Scheduled Script",
|
scriptType,
|
||||||
completeCommandList,
|
completeCommandList,
|
||||||
futureResultKeyMap
|
futureResultKeyMap
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
. /octopus-agent/shell/lib/wdd-lib-log.sh
|
||||||
|
|
||||||
|
start_time=$(date +%s)
|
||||||
|
current_time=$(date +%s)
|
||||||
|
elapsed_time=$((current_time - start_time))
|
||||||
|
|
||||||
|
log "开始执行CPU占用任务,占用时间为 2小时!"
|
||||||
|
while [ $elapsed_time -lt 7200 ]
|
||||||
|
do
|
||||||
|
# Busy wait
|
||||||
|
for i in {1..1000000}
|
||||||
|
do
|
||||||
|
:
|
||||||
|
done
|
||||||
|
current_time=$(date +%s)
|
||||||
|
elapsed_time=$((current_time - start_time))
|
||||||
|
done
|
||||||
|
|
||||||
|
log "CPU占用任务完成!"
|
||||||
Reference in New Issue
Block a user