1. 以前邮件模板从数据库读取,目前将邮件模板独立,将邮件模板从告警的配置中读取,
This commit is contained in:
parent
7341f899fc
commit
35fde12f6d
|
|
@ -5,8 +5,6 @@ public class MailInfo {
|
|||
|
||||
private String[] mailCc;
|
||||
|
||||
private String mailTemp;
|
||||
|
||||
public String[] getMailTo() {
|
||||
return mailTo;
|
||||
}
|
||||
|
|
@ -23,11 +21,4 @@ public class MailInfo {
|
|||
this.mailCc = mailCc;
|
||||
}
|
||||
|
||||
public String getMailTemp() {
|
||||
return mailTemp;
|
||||
}
|
||||
|
||||
public void setMailTemp(String mailTemp) {
|
||||
this.mailTemp = mailTemp;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package com.ai.cloud.skywalking.alarm.procesor;
|
||||
|
||||
import com.ai.cloud.skywalking.alarm.dao.AlarmMessageDao;
|
||||
import com.ai.cloud.skywalking.alarm.model.AlarmRule;
|
||||
import com.ai.cloud.skywalking.alarm.model.ApplicationInfo;
|
||||
import com.ai.cloud.skywalking.alarm.model.MailInfo;
|
||||
|
|
@ -20,13 +19,25 @@ import java.io.StringWriter;
|
|||
import java.sql.SQLException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class AlarmMessageProcessor {
|
||||
|
||||
private static Logger logger = LogManager
|
||||
.getLogger(AlarmMessageProcessor.class);
|
||||
|
||||
static String mailTemplate = "";
|
||||
|
||||
static {
|
||||
Properties properties = new Properties();
|
||||
try {
|
||||
properties.load(AlarmMessageProcessor.class.getResourceAsStream("/mail-template_new.config"));
|
||||
mailTemplate = properties.getProperty("template.default");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void process(UserInfo userInfo, AlarmRule rule) throws TemplateException, IOException, SQLException {
|
||||
Set<String> warningTracingIds = new HashSet<String>();
|
||||
Set<String> warningMessageKeys = new HashSet<String>();
|
||||
|
|
@ -63,9 +74,9 @@ public class AlarmMessageProcessor {
|
|||
rule.getPreviousFireTimeM() * 10000 * 6)));
|
||||
parameter.put("endDate", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(
|
||||
currentFireMinuteTime * 10000 * 6)));
|
||||
String mailContext = generateContent(rule
|
||||
String mailContext = generateContent(/*rule
|
||||
.getConfigArgsDescriber().getMailInfo()
|
||||
.getMailTemp(), parameter);
|
||||
.getMailTemp()*/mailTemplate, parameter);
|
||||
if (mailContext.length() > 0) {
|
||||
MailInfo mailInfo = rule.getConfigArgsDescriber()
|
||||
.getMailInfo();
|
||||
|
|
@ -142,6 +153,4 @@ public class AlarmMessageProcessor {
|
|||
t.process(parameter, out);
|
||||
return out.getBuffer().toString();
|
||||
}
|
||||
|
||||
private static Map<String, String> idCodeMapper = new ConcurrentHashMap<String, String>();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@ server.daemon_thread_wait_interval=50000
|
|||
processthread.thread_wait_interval=5000
|
||||
|
||||
#zookeeper连接地址
|
||||
zkpath.connect_str=10.1.241.18:29181,10.1.241.19:29181,10.1.241.20:29181
|
||||
#zkpath.connect_str=10.1.241.18:29181,10.1.241.19:29181,10.1.241.20:29181
|
||||
zkpath.connect_str=127.0.0.1:29181
|
||||
#zookeeper连接超时时间(单位:毫秒)
|
||||
zkpath.connect_timeout=1000
|
||||
#zookeeper重试次数
|
||||
|
|
@ -46,7 +47,8 @@ db.max_pool_size=20
|
|||
db.connect_timeout=10000
|
||||
|
||||
#告警信息存在的redis服务器地址
|
||||
alarm.redis_server=10.1.241.18:16379
|
||||
#alarm.redis_server=10.1.241.18:16379
|
||||
alarm.redis_server=127.0.0.1:6379
|
||||
#redis的最大空闲连接数
|
||||
alarm.redis_max_idle=20
|
||||
#redis的最小空闲连接数
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
template.default=<!DOCTYPE html PUBLIC\"-//W3C//DTD XHTML 1.0 Transitional//EN\"\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\"><head><meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\"><style type=\"text/css\">li{text-indent:2em}</style><title>templete1_welcome</title></head><body style=\"background:#eee;\"><table width=\"80%\"cellpadding=\"0\"cellspacing=\"0\"border=\"0\"style=\"text-align:left;font:12px/15px simsun; line-height:20px; color:#000;background:#fff; padding:30px 20px; border:20px solid #fff; margin:0 auto;\"><tbody><tr><td style=\"margin:0; padding:0;\"><div style=\"background:#f9f9f9; padding:25px; font-family: \u5fae\u8f6f\u96c5\u9ed1, \u9ed1\u4f53, Arial; font-size:14px; line-height:25px; margin:5px 0; overflow:hidden;\"><p>\u5c0a\u656c\u7684SkyWalking\u7528\u6237\u60a8\u597d:</p><p>\u81ea<b>${startDate!}</b>\u8d77\uff0c\u5230<b>${endDate!}</b>\u6b62\uff0c\u5e73\u53f0\u63a5\u6536\u5230\u76d1\u63a7\u544a\u8b66\u4fe1\u606f\u5982\u4e0b\uff1a</p><p><#if warningTracingIds??><#list warningTracingIds as traceId><li><a href=\"${(portalAddr + traceId)!}\">${traceId!}</a></li></#list></#if></p></div></td></tr></tbody></table></body></html>
|
||||
Loading…
Reference in New Issue