Merge remote-tracking branch 'origin/station' into station
This commit is contained in:
commit
6a90cfbc71
|
@ -47,6 +47,12 @@ public class AlarmLog implements Serializable {
|
|||
@TableField(value = "alarm_value")
|
||||
private String alarmValue;
|
||||
|
||||
/**
|
||||
* 当前的规则信息
|
||||
*/
|
||||
@TableField(value = "operator")
|
||||
private String operator;
|
||||
|
||||
public AlarmLog() {
|
||||
this.alarmStartDate = LocalDateTime.now();
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
l.alarm_start_date,
|
||||
l.alarm_info,
|
||||
l.alarm_value,
|
||||
r.OPERATOR,
|
||||
l.OPERATOR,
|
||||
r.source_type,
|
||||
CASE
|
||||
r.source_type
|
||||
|
|
|
@ -90,7 +90,6 @@ public class SysInfoJob implements Job {
|
|||
// 向运管查询监控项数据
|
||||
Result<ItemHistory> result = monitorSystem.itemBack(itemId, 0, start, end);
|
||||
Double current = result.getResult().getNow();
|
||||
log.error("当前CPU使用率为:{}", current);
|
||||
|
||||
// 解析预警规则,判断是否需要报警
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
|
@ -98,24 +97,27 @@ public class SysInfoJob implements Job {
|
|||
rule.setCurrent(current);
|
||||
boolean needWarn = parse(rule);
|
||||
if (needWarn){
|
||||
// 组织要发送的预警信息
|
||||
// 记录报警日志
|
||||
AlarmLog alarmLog = new AlarmLog();
|
||||
alarmLog.setRuleId(ruleId);
|
||||
alarmLog.setOperator(operator);
|
||||
alarmLog.setAlarmValue(StrUtil.toString(current));
|
||||
String ruleName = alarmRule.getName();
|
||||
Double threshold = rule.getThreshold();
|
||||
String message = "您设定的预警规则:"+ruleName+"," +
|
||||
"预警信息为:"+ operator + ",当前值为:" + current;
|
||||
alarmLog.setAlarmInfo(message);
|
||||
alarmClient.create(alarmLog);
|
||||
|
||||
// 规则触发报警后,设置该规则的沉默周期(如果有)
|
||||
// 沉默周期失效之前,该规则不会再次被触发
|
||||
Long silenceCycle = alarmRule.getSilenceCycle();
|
||||
ruleSilence(silenceKey, silenceCycle);
|
||||
|
||||
// 发送报警信息
|
||||
String groupId = alarmRule.getContactId();
|
||||
String notific = alarmRule.getNotification();
|
||||
sendMessage.send(message,groupId,notific);
|
||||
// 记录报警日志
|
||||
AlarmLog alarmLog = new AlarmLog();
|
||||
alarmLog.setAlarmStartDate(LocalDateTime.now());
|
||||
alarmLog.setAlarmValue(current.toString());
|
||||
alarmLog.setAlarmInfo(message);
|
||||
alarmClient.create(alarmLog);
|
||||
sendMessage.send(message, groupId, notific);
|
||||
}
|
||||
} catch (JsonProcessingException e) {
|
||||
log.error("预警规则{}解析失败!", operator);
|
||||
|
|
|
@ -103,8 +103,8 @@ public class JobController {
|
|||
alarmLog.setAlarmValue(StrUtil.toString(current));
|
||||
String ruleName = alarmRule.getName();
|
||||
Double threshold = rule.getThreshold();
|
||||
String message = "您设定的预警规则:"+ruleName+"," + "预警阈值为:["+
|
||||
operator+threshold+"],当前值为:"+current;
|
||||
String message = "您设定的预警规则:"+ruleName+"," +
|
||||
"预警信息为:"+ operator + ",当前值为:" + current;
|
||||
alarmLog.setAlarmInfo(message);
|
||||
alarmClient.create(alarmLog);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user