Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
cfa40587
C
cat
项目概览
梦中观雨
/
cat
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
cat
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
cfa40587
编写于
7月 29, 2014
作者:
Y
youyong205
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #426 from leonindy/master
use ftl as alert template, add argument to receiver method
上级
f91375ea
7744564f
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
153 addition
and
81 deletion
+153
-81
cat-home/src/main/java/com/dianping/cat/build/ComponentsConfigurator.java
...n/java/com/dianping/cat/build/ComponentsConfigurator.java
+5
-5
cat-home/src/main/java/com/dianping/cat/report/task/alert/sender/decorator/ExceptionDecorator.java
...eport/task/alert/sender/decorator/ExceptionDecorator.java
+50
-15
cat-home/src/main/java/com/dianping/cat/report/task/alert/sender/decorator/ThirdpartyDecorator.java
...port/task/alert/sender/decorator/ThirdpartyDecorator.java
+45
-14
cat-home/src/main/java/com/dianping/cat/report/task/alert/sender/receiver/Contactor.java
...ping/cat/report/task/alert/sender/receiver/Contactor.java
+3
-5
cat-home/src/main/java/com/dianping/cat/report/task/alert/sender/receiver/ContactorManager.java
...t/report/task/alert/sender/receiver/ContactorManager.java
+3
-4
cat-home/src/main/java/com/dianping/cat/report/task/alert/sender/receiver/ProductlineContactor.java
...port/task/alert/sender/receiver/ProductlineContactor.java
+18
-18
cat-home/src/main/java/com/dianping/cat/report/task/alert/sender/receiver/ProjectContactor.java
...t/report/task/alert/sender/receiver/ProjectContactor.java
+20
-15
cat-home/src/main/resources/META-INF/plexus/components.xml
cat-home/src/main/resources/META-INF/plexus/components.xml
+5
-5
cat-home/src/main/resources/freemaker/exceptionAlert.ftl
cat-home/src/main/resources/freemaker/exceptionAlert.ftl
+3
-0
cat-home/src/main/resources/freemaker/thirdpartyAlert.ftl
cat-home/src/main/resources/freemaker/thirdpartyAlert.ftl
+1
-0
未找到文件。
cat-home/src/main/java/com/dianping/cat/build/ComponentsConfigurator.java
浏览文件 @
cfa40587
...
@@ -132,19 +132,19 @@ public class ComponentsConfigurator extends AbstractResourceConfigurator {
...
@@ -132,19 +132,19 @@ public class ComponentsConfigurator extends AbstractResourceConfigurator {
all
.
add
(
C
(
DataChecker
.
class
,
DefaultDataChecker
.
class
));
all
.
add
(
C
(
DataChecker
.
class
,
DefaultDataChecker
.
class
));
all
.
add
(
C
(
RemoteMetricReportService
.
class
).
req
(
ServerConfigManager
.
class
));
all
.
add
(
C
(
RemoteMetricReportService
.
class
).
req
(
ServerConfigManager
.
class
));
all
.
add
(
C
(
Contactor
.
class
,
BusinessContactor
.
ID
,
BusinessContactor
.
class
).
req
(
Pro
jectDao
.
class
,
all
.
add
(
C
(
Contactor
.
class
,
BusinessContactor
.
ID
,
BusinessContactor
.
class
).
req
(
Pro
ductLineConfigManager
.
class
,
AlertConfigManager
.
class
));
AlertConfigManager
.
class
));
all
.
add
(
C
(
Contactor
.
class
,
NetworkContactor
.
ID
,
NetworkContactor
.
class
).
req
(
Pro
jectDao
.
class
,
all
.
add
(
C
(
Contactor
.
class
,
NetworkContactor
.
ID
,
NetworkContactor
.
class
).
req
(
Pro
ductLineConfigManager
.
class
,
AlertConfigManager
.
class
));
AlertConfigManager
.
class
));
all
.
add
(
C
(
Contactor
.
class
,
SystemContactor
.
ID
,
SystemContactor
.
class
).
req
(
Pro
jectDao
.
class
,
all
.
add
(
C
(
Contactor
.
class
,
SystemContactor
.
ID
,
SystemContactor
.
class
).
req
(
Pro
ductLineConfigManager
.
class
,
AlertConfigManager
.
class
));
AlertConfigManager
.
class
));
all
.
add
(
C
(
Contactor
.
class
,
ExceptionContactor
.
ID
,
ExceptionContactor
.
class
).
req
(
Pro
ductLineConfigManager
.
class
,
all
.
add
(
C
(
Contactor
.
class
,
ExceptionContactor
.
ID
,
ExceptionContactor
.
class
).
req
(
Pro
jectDao
.
class
,
AlertConfigManager
.
class
));
AlertConfigManager
.
class
));
all
.
add
(
C
(
Contactor
.
class
,
ThirdpartyContactor
.
ID
,
ThirdpartyContactor
.
class
).
req
(
Pro
ductLineConfigManager
.
class
,
all
.
add
(
C
(
Contactor
.
class
,
ThirdpartyContactor
.
ID
,
ThirdpartyContactor
.
class
).
req
(
Pro
jectDao
.
class
,
AlertConfigManager
.
class
));
AlertConfigManager
.
class
));
all
.
add
(
C
(
ContactorManager
.
class
).
req
(
Contactor
.
class
,
BusinessContactor
.
ID
,
"businessContactor"
)
all
.
add
(
C
(
ContactorManager
.
class
).
req
(
Contactor
.
class
,
BusinessContactor
.
ID
,
"businessContactor"
)
...
...
cat-home/src/main/java/com/dianping/cat/report/task/alert/sender/decorator/ExceptionDecorator.java
浏览文件 @
cfa40587
package
com.dianping.cat.report.task.alert.sender.decorator
;
package
com.dianping.cat.report.task.alert.sender.decorator
;
import
java.io.StringWriter
;
import
java.text.DateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable
;
import
org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.report.task.alert.AlertConstants
;
import
com.dianping.cat.report.task.alert.AlertConstants
;
import
com.dianping.cat.report.task.alert.sender.AlertEntity
;
import
com.dianping.cat.report.task.alert.sender.AlertEntity
;
import
com.dianping.cat.system.notify.ReportRenderImpl
;
import
freemarker.template.Configuration
;
import
freemarker.template.Template
;
public
class
ExceptionDecorator
extends
DefaultDecorator
implements
Initializable
{
public
class
ExceptionDecorator
extends
DefaultDecorator
{
public
Configuration
m_configuration
;
public
static
final
String
ID
=
AlertConstants
.
EXCEPTION
;
public
static
final
String
ID
=
AlertConstants
.
EXCEPTION
;
private
DateFormat
m_dateFormat
=
new
SimpleDateFormat
(
"yyyyMMddHH"
);
@Override
@Override
public
String
getId
()
{
public
String
getId
()
{
return
ID
;
return
ID
;
...
@@ -22,21 +39,39 @@ public class ExceptionDecorator extends DefaultDecorator {
...
@@ -22,21 +39,39 @@ public class ExceptionDecorator extends DefaultDecorator {
@Override
@Override
public
String
generateContent
(
AlertEntity
alert
)
{
public
String
generateContent
(
AlertEntity
alert
)
{
Map
<
Object
,
Object
>
dataMap
=
generateExceptionMap
(
alert
);
StringWriter
sw
=
new
StringWriter
(
5000
);
try
{
Template
t
=
m_configuration
.
getTemplate
(
"exceptionAlert.ftl"
);
t
.
process
(
dataMap
,
sw
);
}
catch
(
Exception
e
)
{
Cat
.
logError
(
"build exception content error:"
+
alert
.
toString
(),
e
);
}
return
sw
.
toString
();
}
private
Map
<
Object
,
Object
>
generateExceptionMap
(
AlertEntity
alert
)
{
String
domain
=
alert
.
getGroup
();
String
contactInfo
=
buildContactInfo
(
domain
);
Map
<
Object
,
Object
>
map
=
new
HashMap
<
Object
,
Object
>();
map
.
put
(
"domain"
,
domain
);
map
.
put
(
"content"
,
alert
.
getContent
());
map
.
put
(
"date"
,
m_dateFormat
.
format
(
alert
.
getDate
()));
map
.
put
(
"contactInfo"
,
contactInfo
);
return
map
;
}
@Override
public
void
initialize
()
throws
InitializationException
{
m_configuration
=
new
Configuration
();
m_configuration
.
setDefaultEncoding
(
"UTF-8"
);
try
{
try
{
StringBuilder
sb
=
new
StringBuilder
();
m_configuration
.
setClassForTemplateLoading
(
ReportRenderImpl
.
class
,
"/freemaker"
);
String
domain
=
alert
.
getGroup
();
}
catch
(
Exception
e
)
{
String
date
=
m_format
.
format
(
alert
.
getDate
());
Cat
.
logError
(
e
);
sb
.
append
(
"[CAT异常告警] [项目: "
).
append
(
domain
).
append
(
"] : "
);
sb
.
append
(
alert
.
getContent
()).
append
(
"[时间: "
).
append
(
date
).
append
(
"]"
);
sb
.
append
(
" <a href='"
).
append
(
"http://cat.dianpingoa.com/cat/r/p?domain="
).
append
(
domain
).
append
(
"&date="
)
.
append
(
date
).
append
(
"'>点击此处查看详情[联系人修改请联系黄永,修改CMDB]</a>"
).
append
(
"<br/>"
);
sb
.
append
(
buildContactInfo
(
domain
));
return
sb
.
toString
();
}
catch
(
Exception
ex
)
{
Cat
.
logError
(
"build exception content error:"
+
alert
.
toString
(),
ex
);
return
null
;
}
}
}
}
...
...
cat-home/src/main/java/com/dianping/cat/report/task/alert/sender/decorator/ThirdpartyDecorator.java
浏览文件 @
cfa40587
package
com.dianping.cat.report.task.alert.sender.decorator
;
package
com.dianping.cat.report.task.alert.sender.decorator
;
import
java.util.Date
;
import
java.io.StringWriter
;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable
;
import
org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.report.task.alert.AlertConstants
;
import
com.dianping.cat.report.task.alert.AlertConstants
;
import
com.dianping.cat.report.task.alert.sender.AlertEntity
;
import
com.dianping.cat.report.task.alert.sender.AlertEntity
;
import
com.dianping.cat.system.notify.ReportRenderImpl
;
import
freemarker.template.Configuration
;
import
freemarker.template.Template
;
public
class
ThirdpartyDecorator
extends
DefaultDecorator
{
public
class
ThirdpartyDecorator
extends
DefaultDecorator
implements
Initializable
{
public
Configuration
m_configuration
;
public
static
final
String
ID
=
AlertConstants
.
THIRDPARTY
;
public
static
final
String
ID
=
AlertConstants
.
THIRDPARTY
;
...
@@ -24,19 +35,39 @@ public class ThirdpartyDecorator extends DefaultDecorator {
...
@@ -24,19 +35,39 @@ public class ThirdpartyDecorator extends DefaultDecorator {
@Override
@Override
public
String
generateContent
(
AlertEntity
alert
)
{
public
String
generateContent
(
AlertEntity
alert
)
{
Map
<
Object
,
Object
>
dataMap
=
generateExceptionMap
(
alert
);
StringWriter
sw
=
new
StringWriter
(
5000
);
try
{
Template
t
=
m_configuration
.
getTemplate
(
"exceptionAlert.ftl"
);
t
.
process
(
dataMap
,
sw
);
}
catch
(
Exception
e
)
{
Cat
.
logError
(
"build third party content error:"
+
alert
.
toString
(),
e
);
}
return
sw
.
toString
();
}
private
Map
<
Object
,
Object
>
generateExceptionMap
(
AlertEntity
alert
)
{
String
domain
=
alert
.
getGroup
();
String
contactInfo
=
buildContactInfo
(
domain
);
Map
<
Object
,
Object
>
map
=
new
HashMap
<
Object
,
Object
>();
map
.
put
(
"domain"
,
domain
);
map
.
put
(
"content"
,
alert
.
getContent
());
map
.
put
(
"date"
,
m_format
.
format
(
alert
.
getDate
()));
map
.
put
(
"contactInfo"
,
contactInfo
);
return
map
;
}
@Override
public
void
initialize
()
throws
InitializationException
{
m_configuration
=
new
Configuration
();
m_configuration
.
setDefaultEncoding
(
"UTF-8"
);
try
{
try
{
StringBuilder
sb
=
new
StringBuilder
();
m_configuration
.
setClassForTemplateLoading
(
ReportRenderImpl
.
class
,
"/freemaker"
);
String
time
=
m_format
.
format
(
new
Date
());
}
catch
(
Exception
e
)
{
String
group
=
alert
.
getGroup
();
Cat
.
logError
(
e
);
sb
.
append
(
"[CAT第三方告警] [项目: "
).
append
(
group
).
append
(
"] : "
);
sb
.
append
(
alert
.
getContent
()).
append
(
"[时间: "
).
append
(
time
).
append
(
"]"
);
sb
.
append
(
"<br/>"
).
append
(
buildContactInfo
(
group
));
return
sb
.
toString
();
}
catch
(
Exception
ex
)
{
Cat
.
logError
(
"build third party content error:"
+
alert
.
toString
(),
ex
);
return
null
;
}
}
}
}
...
...
cat-home/src/main/java/com/dianping/cat/report/task/alert/sender/receiver/Contactor.java
浏览文件 @
cfa40587
...
@@ -6,11 +6,9 @@ public interface Contactor {
...
@@ -6,11 +6,9 @@ public interface Contactor {
public
String
getId
();
public
String
getId
();
public
List
<
String
>
queryEmailContactors
();
public
List
<
String
>
queryEmailContactors
(
String
id
);
public
List
<
String
>
queryWeiXinContactors
();
public
List
<
String
>
queryWeiXinContactors
(
String
id
);
public
List
<
String
>
querySmsContactors
();
public
List
<
String
>
querySmsContactors
(
String
id
);
public
void
setModule
(
String
id
);
}
}
cat-home/src/main/java/com/dianping/cat/report/task/alert/sender/receiver/ContactorManager.java
浏览文件 @
cfa40587
...
@@ -32,14 +32,13 @@ public class ContactorManager implements Initializable {
...
@@ -32,14 +32,13 @@ public class ContactorManager implements Initializable {
public
List
<
String
>
queryReceivers
(
String
group
,
String
channel
,
String
type
)
{
public
List
<
String
>
queryReceivers
(
String
group
,
String
channel
,
String
type
)
{
Contactor
contactor
=
m_contactors
.
get
(
type
);
Contactor
contactor
=
m_contactors
.
get
(
type
);
contactor
.
setModule
(
group
);
if
(
AlertConstants
.
MAIL
.
equals
(
channel
))
{
if
(
AlertConstants
.
MAIL
.
equals
(
channel
))
{
return
contactor
.
queryEmailContactors
();
return
contactor
.
queryEmailContactors
(
group
);
}
else
if
(
AlertConstants
.
SMS
.
equals
(
channel
))
{
}
else
if
(
AlertConstants
.
SMS
.
equals
(
channel
))
{
return
contactor
.
querySmsContactors
();
return
contactor
.
querySmsContactors
(
group
);
}
else
if
(
AlertConstants
.
WEIXIN
.
equals
(
channel
))
{
}
else
if
(
AlertConstants
.
WEIXIN
.
equals
(
channel
))
{
return
contactor
.
queryWeiXinContactors
();
return
contactor
.
queryWeiXinContactors
(
group
);
}
else
{
}
else
{
return
new
ArrayList
<
String
>();
return
new
ArrayList
<
String
>();
}
}
...
...
cat-home/src/main/java/com/dianping/cat/report/task/alert/sender/receiver/ProductlineContactor.java
浏览文件 @
cfa40587
...
@@ -3,28 +3,25 @@ package com.dianping.cat.report.task.alert.sender.receiver;
...
@@ -3,28 +3,25 @@ package com.dianping.cat.report.task.alert.sender.receiver;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
org.unidal.dal.jdbc.DalException
;
import
org.unidal.lookup.annotation.Inject
;
import
org.unidal.lookup.annotation.Inject
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.core.dal.Project
;
import
com.dianping.cat.consumer.company.model.entity.ProductLine
;
import
com.dianping.cat.core.dal.ProjectDao
;
import
com.dianping.cat.consumer.metric.ProductLineConfigManager
;
import
com.dianping.cat.core.dal.ProjectEntity
;
import
com.dianping.cat.home.alert.config.entity.Receiver
;
import
com.dianping.cat.home.alert.config.entity.Receiver
;
import
com.dianping.cat.system.config.AlertConfigManager
;
import
com.dianping.cat.system.config.AlertConfigManager
;
public
abstract
class
ProductlineContactor
extends
DefaultContactor
implements
Contactor
{
public
abstract
class
ProductlineContactor
extends
DefaultContactor
implements
Contactor
{
@Inject
@Inject
protected
Pro
jectDao
m_projectDao
;
protected
Pro
ductLineConfigManager
m_productLineConfigManager
;
@Inject
@Inject
protected
AlertConfigManager
m_configManager
;
protected
AlertConfigManager
m_configManager
;
protected
Project
m_project
=
new
Project
();
@Override
@Override
public
List
<
String
>
queryEmailContactors
()
{
public
List
<
String
>
queryEmailContactors
(
String
id
)
{
ProductLine
productline
=
queryProductline
(
id
);
List
<
String
>
mailReceivers
=
new
ArrayList
<
String
>();
List
<
String
>
mailReceivers
=
new
ArrayList
<
String
>();
Receiver
receiver
=
m_configManager
.
queryReceiverById
(
getId
());
Receiver
receiver
=
m_configManager
.
queryReceiverById
(
getId
());
...
@@ -32,14 +29,15 @@ public abstract class ProductlineContactor extends DefaultContactor implements C
...
@@ -32,14 +29,15 @@ public abstract class ProductlineContactor extends DefaultContactor implements C
return
mailReceivers
;
return
mailReceivers
;
}
else
{
}
else
{
mailReceivers
.
addAll
(
buildDefaultMailReceivers
(
receiver
));
mailReceivers
.
addAll
(
buildDefaultMailReceivers
(
receiver
));
mailReceivers
.
addAll
(
split
(
m_project
.
getEmail
()));
mailReceivers
.
addAll
(
split
(
productline
.
getEmail
()));
return
mailReceivers
;
return
mailReceivers
;
}
}
}
}
@Override
@Override
public
List
<
String
>
querySmsContactors
()
{
public
List
<
String
>
querySmsContactors
(
String
id
)
{
ProductLine
productline
=
queryProductline
(
id
);
List
<
String
>
smsReceivers
=
new
ArrayList
<
String
>();
List
<
String
>
smsReceivers
=
new
ArrayList
<
String
>();
Receiver
receiver
=
m_configManager
.
queryReceiverById
(
getId
());
Receiver
receiver
=
m_configManager
.
queryReceiverById
(
getId
());
...
@@ -47,14 +45,15 @@ public abstract class ProductlineContactor extends DefaultContactor implements C
...
@@ -47,14 +45,15 @@ public abstract class ProductlineContactor extends DefaultContactor implements C
return
smsReceivers
;
return
smsReceivers
;
}
else
{
}
else
{
smsReceivers
.
addAll
(
buildDefaultSMSReceivers
(
receiver
));
smsReceivers
.
addAll
(
buildDefaultSMSReceivers
(
receiver
));
smsReceivers
.
addAll
(
split
(
m_project
.
getPhone
()));
smsReceivers
.
addAll
(
split
(
productline
.
getPhone
()));
return
smsReceivers
;
return
smsReceivers
;
}
}
}
}
@Override
@Override
public
List
<
String
>
queryWeiXinContactors
()
{
public
List
<
String
>
queryWeiXinContactors
(
String
id
)
{
ProductLine
productline
=
queryProductline
(
id
);
List
<
String
>
weixinReceivers
=
new
ArrayList
<
String
>();
List
<
String
>
weixinReceivers
=
new
ArrayList
<
String
>();
Receiver
receiver
=
m_configManager
.
queryReceiverById
(
getId
());
Receiver
receiver
=
m_configManager
.
queryReceiverById
(
getId
());
...
@@ -62,18 +61,19 @@ public abstract class ProductlineContactor extends DefaultContactor implements C
...
@@ -62,18 +61,19 @@ public abstract class ProductlineContactor extends DefaultContactor implements C
return
weixinReceivers
;
return
weixinReceivers
;
}
else
{
}
else
{
weixinReceivers
.
addAll
(
buildDefaultWeixinReceivers
(
receiver
));
weixinReceivers
.
addAll
(
buildDefaultWeixinReceivers
(
receiver
));
weixinReceivers
.
addAll
(
split
(
m_project
.
getEmail
()));
weixinReceivers
.
addAll
(
split
(
productline
.
getEmail
()));
return
weixinReceivers
;
return
weixinReceivers
;
}
}
}
}
p
ublic
void
setModule
(
String
domain
Name
)
{
p
rivate
ProductLine
queryProductline
(
String
productline
Name
)
{
try
{
try
{
m_project
=
m_projectDao
.
findByDomain
(
domainName
,
ProjectEntity
.
READSET_FULL
);
ProductLine
productline
=
m_productLineConfigManager
.
queryProductLine
(
productlineName
);
}
catch
(
DalException
e
)
{
return
productline
;
Cat
.
logError
(
"query project error:"
+
domainName
,
e
);
}
catch
(
Exception
e
)
{
Cat
.
logError
(
"query productline error:"
+
productlineName
,
e
);
return
new
ProductLine
();
}
}
}
}
}
}
cat-home/src/main/java/com/dianping/cat/report/task/alert/sender/receiver/ProjectContactor.java
浏览文件 @
cfa40587
...
@@ -3,26 +3,27 @@ package com.dianping.cat.report.task.alert.sender.receiver;
...
@@ -3,26 +3,27 @@ package com.dianping.cat.report.task.alert.sender.receiver;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
org.unidal.dal.jdbc.DalException
;
import
org.unidal.lookup.annotation.Inject
;
import
org.unidal.lookup.annotation.Inject
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.consumer.company.model.entity.ProductLine
;
import
com.dianping.cat.core.dal.Project
;
import
com.dianping.cat.consumer.metric.ProductLineConfigManager
;
import
com.dianping.cat.core.dal.ProjectDao
;
import
com.dianping.cat.core.dal.ProjectEntity
;
import
com.dianping.cat.home.alert.config.entity.Receiver
;
import
com.dianping.cat.home.alert.config.entity.Receiver
;
import
com.dianping.cat.system.config.AlertConfigManager
;
import
com.dianping.cat.system.config.AlertConfigManager
;
public
abstract
class
ProjectContactor
extends
DefaultContactor
implements
Contactor
{
public
abstract
class
ProjectContactor
extends
DefaultContactor
implements
Contactor
{
@Inject
@Inject
protected
Pro
ductLineConfigManager
m_productLineConfigManager
;
protected
Pro
jectDao
m_projectDao
;
@Inject
@Inject
protected
AlertConfigManager
m_configManager
;
protected
AlertConfigManager
m_configManager
;
protected
ProductLine
m_productline
=
new
ProductLine
();
@Override
@Override
public
List
<
String
>
queryEmailContactors
()
{
public
List
<
String
>
queryEmailContactors
(
String
id
)
{
Project
project
=
queryProject
(
id
);
List
<
String
>
mailReceivers
=
new
ArrayList
<
String
>();
List
<
String
>
mailReceivers
=
new
ArrayList
<
String
>();
Receiver
receiver
=
m_configManager
.
queryReceiverById
(
getId
());
Receiver
receiver
=
m_configManager
.
queryReceiverById
(
getId
());
...
@@ -30,14 +31,15 @@ public abstract class ProjectContactor extends DefaultContactor implements Conta
...
@@ -30,14 +31,15 @@ public abstract class ProjectContactor extends DefaultContactor implements Conta
return
mailReceivers
;
return
mailReceivers
;
}
else
{
}
else
{
mailReceivers
.
addAll
(
buildDefaultMailReceivers
(
receiver
));
mailReceivers
.
addAll
(
buildDefaultMailReceivers
(
receiver
));
mailReceivers
.
addAll
(
split
(
m_productline
.
getEmail
()));
mailReceivers
.
addAll
(
split
(
project
.
getEmail
()));
return
mailReceivers
;
return
mailReceivers
;
}
}
}
}
@Override
@Override
public
List
<
String
>
querySmsContactors
()
{
public
List
<
String
>
querySmsContactors
(
String
id
)
{
Project
project
=
queryProject
(
id
);
List
<
String
>
smsReceivers
=
new
ArrayList
<
String
>();
List
<
String
>
smsReceivers
=
new
ArrayList
<
String
>();
Receiver
receiver
=
m_configManager
.
queryReceiverById
(
getId
());
Receiver
receiver
=
m_configManager
.
queryReceiverById
(
getId
());
...
@@ -45,14 +47,15 @@ public abstract class ProjectContactor extends DefaultContactor implements Conta
...
@@ -45,14 +47,15 @@ public abstract class ProjectContactor extends DefaultContactor implements Conta
return
smsReceivers
;
return
smsReceivers
;
}
else
{
}
else
{
smsReceivers
.
addAll
(
buildDefaultSMSReceivers
(
receiver
));
smsReceivers
.
addAll
(
buildDefaultSMSReceivers
(
receiver
));
smsReceivers
.
addAll
(
split
(
m_productline
.
getPhone
()));
smsReceivers
.
addAll
(
split
(
project
.
getPhone
()));
return
smsReceivers
;
return
smsReceivers
;
}
}
}
}
@Override
@Override
public
List
<
String
>
queryWeiXinContactors
()
{
public
List
<
String
>
queryWeiXinContactors
(
String
id
)
{
Project
project
=
queryProject
(
id
);
List
<
String
>
weixinReceivers
=
new
ArrayList
<
String
>();
List
<
String
>
weixinReceivers
=
new
ArrayList
<
String
>();
Receiver
receiver
=
m_configManager
.
queryReceiverById
(
getId
());
Receiver
receiver
=
m_configManager
.
queryReceiverById
(
getId
());
...
@@ -60,17 +63,19 @@ public abstract class ProjectContactor extends DefaultContactor implements Conta
...
@@ -60,17 +63,19 @@ public abstract class ProjectContactor extends DefaultContactor implements Conta
return
weixinReceivers
;
return
weixinReceivers
;
}
else
{
}
else
{
weixinReceivers
.
addAll
(
buildDefaultWeixinReceivers
(
receiver
));
weixinReceivers
.
addAll
(
buildDefaultWeixinReceivers
(
receiver
));
weixinReceivers
.
addAll
(
split
(
m_productline
.
getEmail
()));
weixinReceivers
.
addAll
(
split
(
project
.
getEmail
()));
return
weixinReceivers
;
return
weixinReceivers
;
}
}
}
}
p
ublic
void
setModule
(
String
productline
Name
)
{
p
rivate
Project
queryProject
(
String
domain
Name
)
{
try
{
try
{
m_productline
=
m_productLineConfigManager
.
queryProductLine
(
productlineName
);
Project
project
=
m_projectDao
.
findByDomain
(
domainName
,
ProjectEntity
.
READSET_FULL
);
}
catch
(
Exception
e
)
{
return
project
;
Cat
.
logError
(
"query productline error:"
+
productlineName
,
e
);
}
catch
(
DalException
e
)
{
Cat
.
logError
(
"query project error:"
+
domainName
,
e
);
return
new
Project
();
}
}
}
}
...
...
cat-home/src/main/resources/META-INF/plexus/components.xml
浏览文件 @
cfa40587
...
@@ -569,7 +569,7 @@
...
@@ -569,7 +569,7 @@
<implementation>
com.dianping.cat.report.task.alert.sender.receiver.BusinessContactor
</implementation>
<implementation>
com.dianping.cat.report.task.alert.sender.receiver.BusinessContactor
</implementation>
<requirements>
<requirements>
<requirement>
<requirement>
<role>
com.dianping.cat.co
re.dal.ProjectDao
</role>
<role>
com.dianping.cat.co
nsumer.metric.ProductLineConfigManager
</role>
</requirement>
</requirement>
<requirement>
<requirement>
<role>
com.dianping.cat.system.config.AlertConfigManager
</role>
<role>
com.dianping.cat.system.config.AlertConfigManager
</role>
...
@@ -582,7 +582,7 @@
...
@@ -582,7 +582,7 @@
<implementation>
com.dianping.cat.report.task.alert.sender.receiver.NetworkContactor
</implementation>
<implementation>
com.dianping.cat.report.task.alert.sender.receiver.NetworkContactor
</implementation>
<requirements>
<requirements>
<requirement>
<requirement>
<role>
com.dianping.cat.co
re.dal.ProjectDao
</role>
<role>
com.dianping.cat.co
nsumer.metric.ProductLineConfigManager
</role>
</requirement>
</requirement>
<requirement>
<requirement>
<role>
com.dianping.cat.system.config.AlertConfigManager
</role>
<role>
com.dianping.cat.system.config.AlertConfigManager
</role>
...
@@ -595,7 +595,7 @@
...
@@ -595,7 +595,7 @@
<implementation>
com.dianping.cat.report.task.alert.sender.receiver.SystemContactor
</implementation>
<implementation>
com.dianping.cat.report.task.alert.sender.receiver.SystemContactor
</implementation>
<requirements>
<requirements>
<requirement>
<requirement>
<role>
com.dianping.cat.co
re.dal.ProjectDao
</role>
<role>
com.dianping.cat.co
nsumer.metric.ProductLineConfigManager
</role>
</requirement>
</requirement>
<requirement>
<requirement>
<role>
com.dianping.cat.system.config.AlertConfigManager
</role>
<role>
com.dianping.cat.system.config.AlertConfigManager
</role>
...
@@ -608,7 +608,7 @@
...
@@ -608,7 +608,7 @@
<implementation>
com.dianping.cat.report.task.alert.sender.receiver.ExceptionContactor
</implementation>
<implementation>
com.dianping.cat.report.task.alert.sender.receiver.ExceptionContactor
</implementation>
<requirements>
<requirements>
<requirement>
<requirement>
<role>
com.dianping.cat.co
nsumer.metric.ProductLineConfigManager
</role>
<role>
com.dianping.cat.co
re.dal.ProjectDao
</role>
</requirement>
</requirement>
<requirement>
<requirement>
<role>
com.dianping.cat.system.config.AlertConfigManager
</role>
<role>
com.dianping.cat.system.config.AlertConfigManager
</role>
...
@@ -621,7 +621,7 @@
...
@@ -621,7 +621,7 @@
<implementation>
com.dianping.cat.report.task.alert.sender.receiver.ThirdpartyContactor
</implementation>
<implementation>
com.dianping.cat.report.task.alert.sender.receiver.ThirdpartyContactor
</implementation>
<requirements>
<requirements>
<requirement>
<requirement>
<role>
com.dianping.cat.co
nsumer.metric.ProductLineConfigManager
</role>
<role>
com.dianping.cat.co
re.dal.ProjectDao
</role>
</requirement>
</requirement>
<requirement>
<requirement>
<role>
com.dianping.cat.system.config.AlertConfigManager
</role>
<role>
com.dianping.cat.system.config.AlertConfigManager
</role>
...
...
cat-home/src/main/resources/freemaker/exceptionAlert.ftl
0 → 100644
浏览文件 @
cfa40587
[CAT异常告警] [项目: ${domain}] : ${content}[时间: ${date}]
<a href='http://cat.dianpingoa.com/cat/r/p?domain=${domain}&date=${date}'>点击此处查看详情</a> <br/>
[联系人修改请联系黄永,修改CMDB] <br/> ${contactInfo}
\ No newline at end of file
cat-home/src/main/resources/freemaker/thirdpartyAlert.ftl
0 → 100644
浏览文件 @
cfa40587
[CAT第三方告警] [项目: ${domain}] : ${content}[时间: ${date}] <br/> [联系人修改请联系黄永,修改CMDB] <br/> ${contactInfo}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录