Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
holmes
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
QA
holmes
Commits
60000c4c
Commit
60000c4c
authored
Jan 08, 2022
by
黎博
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增日志
parent
9fb8d9d1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
3 deletions
+9
-3
SqlMonitorTaskController.java
...g/holmes/controller/monitor/SqlMonitorTaskController.java
+3
-1
QuartzUtils.java
src/main/java/cn/qg/holmes/utils/QuartzUtils.java
+6
-2
No files found.
src/main/java/cn/qg/holmes/controller/monitor/SqlMonitorTaskController.java
View file @
60000c4c
...
...
@@ -13,6 +13,7 @@ import com.alibaba.fastjson.JSON;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.quartz.Scheduler
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -28,6 +29,7 @@ import java.util.Map;
/**
* 定时任务Controller
*/
@Slf4j
@CrossOrigin
@RestController
@RequestMapping
(
"/sql/monitor"
)
...
...
@@ -221,7 +223,7 @@ public class SqlMonitorTaskController {
}
String
markdownMsg
=
DingdingUtils
.
buildMarkdownMsg
(
"监控报警"
,
"**"
+
sqlMonitorTask
.
getTaskName
()
+
"**\n\n"
+
dingText
+
"\n\n"
+
"[请"
+
sqlMonitorTask
.
getOwner
()
+
"同学跟进,查看报警详情.]"
+
"("
+
qaPlatformHost
+
"/monitor/addSqlMonitor?id="
+
sqlMonitorTask
.
getId
()
+
")"
,
true
);
boolean
result
=
DingdingUtils
.
sendToDingding
(
markdownMsg
,
dingUrl
);
return
result
?
JsonResult
.
buildSuccessResult
(
"发送成功!"
)
:
JsonResult
.
buildErrorStateResult
(
"发送失败!"
,
false
);
return
result
?
JsonResult
.
buildSuccessResult
(
"发送成功!"
,
true
)
:
JsonResult
.
buildErrorStateResult
(
"发送失败!"
,
false
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
JsonResult
.
buildErrorStateResult
(
"发送异常!"
,
false
);
...
...
src/main/java/cn/qg/holmes/utils/QuartzUtils.java
View file @
60000c4c
package
cn
.
qg
.
holmes
.
utils
;
import
cn.qg.holmes.entity.monitor.SqlMonitorTask
;
import
com.alibaba.fastjson.JSON
;
import
lombok.extern.slf4j.Slf4j
;
import
org.quartz.*
;
...
...
@@ -38,8 +39,8 @@ public class QuartzUtils {
public
static
void
pauseScheduleJob
(
Scheduler
scheduler
,
String
jobName
)
{
JobKey
jobKey
=
JobKey
.
jobKey
(
jobName
);
try
{
log
.
info
(
"暂停定时任务:{}"
,
jobName
);
scheduler
.
pauseJob
(
jobKey
);
log
.
info
(
"暂停定时任务:{}"
,
jobName
);
}
catch
(
SchedulerException
e
)
{
log
.
info
(
"暂停定时任务出错:"
+
e
.
getMessage
());
}
...
...
@@ -54,8 +55,8 @@ public class QuartzUtils {
public
static
void
resumeScheduleJob
(
Scheduler
scheduler
,
String
jobName
)
{
JobKey
jobKey
=
JobKey
.
jobKey
(
jobName
);
try
{
log
.
info
(
"启动定时任务:{}"
,
jobName
);
scheduler
.
resumeJob
(
jobKey
);
log
.
info
(
"启动定时任务:{}"
,
jobName
);
}
catch
(
SchedulerException
e
)
{
log
.
info
(
"启动定时任务出错:"
+
e
.
getMessage
());
}
...
...
@@ -71,6 +72,7 @@ public class QuartzUtils {
JobKey
jobKey
=
JobKey
.
jobKey
(
jobName
);
try
{
scheduler
.
triggerJob
(
jobKey
);
log
.
info
(
"立即执行一次Job:{}"
,
jobName
);
}
catch
(
SchedulerException
e
)
{
log
.
info
(
"运行定时任务出错:"
+
e
.
getMessage
());
}
...
...
@@ -98,6 +100,7 @@ public class QuartzUtils {
.
build
();
//重置对应的job
scheduler
.
rescheduleJob
(
triggerKey
,
trigger
);
log
.
info
(
"更新定时任务:{}"
,
JSON
.
toJSONString
(
sqlMonitorTask
));
}
catch
(
SchedulerException
e
)
{
System
.
out
.
println
(
"更新定时任务出错:"
+
e
.
getMessage
());
}
...
...
@@ -114,6 +117,7 @@ public class QuartzUtils {
JobKey
jobKey
=
JobKey
.
jobKey
(
jobName
);
try
{
scheduler
.
deleteJob
(
jobKey
);
log
.
info
(
"删除Job:{}"
,
jobName
);
}
catch
(
SchedulerException
e
)
{
log
.
info
(
"删除定时任务出错:"
+
e
.
getMessage
());
}
...
...
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