Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
9894cea0
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,发现更多精彩内容 >>
提交
9894cea0
编写于
7月 17, 2014
作者:
L
leon.li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add contact info when storing and sending alerts
上级
8fc07647
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
98 addition
and
19 deletion
+98
-19
cat-home/src/main/java/com/dianping/cat/build/ComponentsConfigurator.java
...n/java/com/dianping/cat/build/ComponentsConfigurator.java
+7
-7
cat-home/src/main/java/com/dianping/cat/report/task/alert/AlertResultEntity.java
...com/dianping/cat/report/task/alert/AlertResultEntity.java
+9
-5
cat-home/src/main/java/com/dianping/cat/report/task/alert/BaseAlert.java
...in/java/com/dianping/cat/report/task/alert/BaseAlert.java
+41
-1
cat-home/src/main/java/com/dianping/cat/report/task/alert/business/BusinessAlert.java
...ianping/cat/report/task/alert/business/BusinessAlert.java
+3
-1
cat-home/src/main/java/com/dianping/cat/report/task/alert/exception/AlertExceptionBuilder.java
...at/report/task/alert/exception/AlertExceptionBuilder.java
+2
-2
cat-home/src/main/java/com/dianping/cat/report/task/alert/exception/ExceptionAlert.java
...nping/cat/report/task/alert/exception/ExceptionAlert.java
+27
-3
cat-home/src/main/resources/META-INF/plexus/components.xml
cat-home/src/main/resources/META-INF/plexus/components.xml
+9
-0
未找到文件。
cat-home/src/main/java/com/dianping/cat/build/ComponentsConfigurator.java
浏览文件 @
9894cea0
...
...
@@ -192,26 +192,26 @@ public class ComponentsConfigurator extends AbstractResourceConfigurator {
all
.
add
(
C
(
BusinessAlert
.
class
).
req
(
MetricConfigManager
.
class
,
ProductLineConfigManager
.
class
,
BaselineService
.
class
,
MailSMS
.
class
,
BusinessAlertConfig
.
class
,
AlertInfo
.
class
,
AlertDao
.
class
)
//
.
req
(
RemoteMetricReportService
.
class
,
BusinessRuleConfigManager
.
class
,
DataChecker
.
class
));
.
req
(
RemoteMetricReportService
.
class
,
BusinessRuleConfigManager
.
class
,
DataChecker
.
class
,
ProjectDao
.
class
));
all
.
add
(
C
(
NetworkAlert
.
class
).
req
(
MetricConfigManager
.
class
,
ProductLineConfigManager
.
class
,
BaselineService
.
class
,
MailSMS
.
class
,
NetworkAlertConfig
.
class
,
AlertInfo
.
class
,
AlertDao
.
class
)
//
.
req
(
RemoteMetricReportService
.
class
,
NetworkRuleConfigManager
.
class
,
DataChecker
.
class
));
.
req
(
RemoteMetricReportService
.
class
,
NetworkRuleConfigManager
.
class
,
DataChecker
.
class
,
ProjectDao
.
class
));
all
.
add
(
C
(
SystemAlert
.
class
).
req
(
MetricConfigManager
.
class
,
ProductLineConfigManager
.
class
,
BaselineService
.
class
,
MailSMS
.
class
,
SystemAlertConfig
.
class
,
AlertInfo
.
class
,
AlertDao
.
class
)
//
.
req
(
RemoteMetricReportService
.
class
,
SystemRuleConfigManager
.
class
,
DataChecker
.
class
));
.
req
(
RemoteMetricReportService
.
class
,
SystemRuleConfigManager
.
class
,
DataChecker
.
class
,
ProjectDao
.
class
));
all
.
add
(
C
(
AlertExceptionBuilder
.
class
).
req
(
ExceptionConfigManager
.
class
));
all
.
add
(
C
(
ExceptionAlert
.
class
).
req
(
ProjectDao
.
class
,
ExceptionAlertConfig
.
class
,
MailSMS
.
class
,
ExceptionConfigManager
.
class
,
AlertExceptionBuilder
.
class
,
AlertDao
.
class
).
req
(
ModelService
.
class
,
TopAnalyzer
.
ID
));
ExceptionConfigManager
.
class
,
AlertExceptionBuilder
.
class
,
AlertDao
.
class
).
req
(
ModelService
.
class
,
TopAnalyzer
.
ID
));
all
.
add
(
C
(
AlertSummaryExecutor
.
class
).
req
(
AlertSummaryGenerator
.
class
,
AlertSummaryManager
.
class
,
MailSMS
.
class
)
.
req
(
AlertSummaryDecorator
.
class
,
AlertSummaryFTLDecorator
.
ID
));
all
.
add
(
C
(
AlertSummaryDecorator
.
class
,
AlertSummaryFTLDecorator
.
ID
,
AlertSummaryFTLDecorator
.
class
));
all
.
add
(
C
(
AlertSummaryDecorator
.
class
,
AlertSummaryFTLDecorator
.
ID
,
AlertSummaryFTLDecorator
.
class
));
all
.
add
(
C
(
AlertSummaryGenerator
.
class
).
req
(
AlertDao
.
class
,
TopologyGraphManager
.
class
));
...
...
cat-home/src/main/java/com/dianping/cat/report/task/alert/AlertResultEntity.java
浏览文件 @
9894cea0
...
...
@@ -11,14 +11,14 @@ public class AlertResultEntity {
private
Date
m_alertTime
;
public
AlertResultEntity
(){
public
AlertResultEntity
()
{
this
.
m_isTriggered
=
false
;
this
.
m_content
=
""
;
this
.
m_alertType
=
""
;
this
.
m_alertTime
=
new
Date
();
}
public
AlertResultEntity
(
boolean
result
,
String
content
,
String
alertType
){
public
AlertResultEntity
(
boolean
result
,
String
content
,
String
alertType
)
{
this
.
m_isTriggered
=
result
;
this
.
m_content
=
content
;
this
.
m_alertType
=
alertType
;
...
...
@@ -37,6 +37,10 @@ public class AlertResultEntity {
return
m_content
;
}
public
void
setContent
(
String
content
)
{
this
.
m_content
=
content
;
}
public
boolean
isTriggered
()
{
return
m_isTriggered
;
}
...
...
cat-home/src/main/java/com/dianping/cat/report/task/alert/BaseAlert.java
浏览文件 @
9894cea0
...
...
@@ -22,6 +22,9 @@ import com.dianping.cat.consumer.metric.ProductLineConfigManager;
import
com.dianping.cat.consumer.metric.model.entity.MetricItem
;
import
com.dianping.cat.consumer.metric.model.entity.MetricReport
;
import
com.dianping.cat.consumer.metric.model.entity.Segment
;
import
com.dianping.cat.core.dal.Project
;
import
com.dianping.cat.core.dal.ProjectDao
;
import
com.dianping.cat.core.dal.ProjectEntity
;
import
com.dianping.cat.helper.TimeUtil
;
import
com.dianping.cat.home.dal.report.Alert
;
import
com.dianping.cat.home.dal.report.AlertDao
;
...
...
@@ -32,6 +35,7 @@ import com.dianping.cat.service.ModelPeriod;
import
com.dianping.cat.service.ModelRequest
;
import
com.dianping.cat.system.config.BaseRuleConfigManager
;
import
com.dianping.cat.system.tool.MailSMS
;
import
com.site.lookup.util.StringUtils
;
public
abstract
class
BaseAlert
{
...
...
@@ -62,6 +66,9 @@ public abstract class BaseAlert {
@Inject
protected
RemoteMetricReportService
m_service
;
@Inject
private
ProjectDao
m_projectDao
;
protected
static
final
int
DATA_AREADY_MINUTE
=
1
;
protected
static
final
long
DURATION
=
TimeUtil
.
ONE_MINUTE
;
...
...
@@ -96,6 +103,37 @@ public abstract class BaseAlert {
}
}
private
String
extractDomain
(
String
metricKey
)
{
try
{
return
metricKey
.
split
(
":"
)[
0
];
}
catch
(
Exception
ex
)
{
Cat
.
logError
(
"extract domain error:"
+
metricKey
,
ex
);
return
null
;
}
}
protected
String
buildContactInfo
(
String
domainName
)
{
try
{
Project
project
=
m_projectDao
.
findByDomain
(
domainName
,
ProjectEntity
.
READSET_FULL
);
String
owners
=
project
.
getOwner
();
String
phones
=
project
.
getPhone
();
StringBuilder
builder
=
new
StringBuilder
();
if
(!
StringUtils
.
isEmpty
(
owners
))
{
builder
.
append
(
"[业务负责人: "
).
append
(
owners
).
append
(
" ]"
);
}
if
(!
StringUtils
.
isEmpty
(
phones
))
{
builder
.
append
(
"[负责人手机号码: "
).
append
(
phones
).
append
(
" ]"
);
}
return
builder
.
toString
();
}
catch
(
Exception
ex
)
{
Cat
.
logError
(
"build contact info error for doamin: "
+
domainName
,
ex
);
}
return
null
;
}
private
Long
buildMillsByString
(
String
time
)
throws
Exception
{
String
[]
times
=
time
.
split
(
":"
);
int
hour
=
Integer
.
parseInt
(
times
[
0
]);
...
...
@@ -244,6 +282,8 @@ public abstract class BaseAlert {
if
(
alertResult
!=
null
&&
alertResult
.
isTriggered
())
{
String
metricTitle
=
buildMetricTitle
(
metricKey
);
String
mailTitle
=
getAlertConfig
().
buildMailTitle
(
productLine
.
getTitle
(),
metricTitle
);
String
contactInfo
=
buildContactInfo
(
extractDomain
(
metricKey
));
alertResult
.
setContent
(
alertResult
.
getContent
()
+
contactInfo
);
m_alertInfo
.
addAlertInfo
(
metricKey
,
new
Date
().
getTime
());
storeAlert
(
productlineName
,
metricTitle
,
mailTitle
,
alertResult
);
...
...
cat-home/src/main/java/com/dianping/cat/report/task/alert/business/BusinessAlert.java
浏览文件 @
9894cea0
...
...
@@ -71,6 +71,8 @@ public class BusinessAlert extends BaseAlert implements Task, LogEnabled {
if
(
alertResult
!=
null
&&
alertResult
.
isTriggered
())
{
String
mailTitle
=
m_alertConfig
.
buildMailTitle
(
productLine
.
getTitle
(),
config
.
getTitle
());
String
contactInfo
=
buildContactInfo
(
domain
);
alertResult
.
setContent
(
alertResult
.
getContent
()
+
contactInfo
);
m_alertInfo
.
addAlertInfo
(
metricKey
,
new
Date
().
getTime
());
storeAlert
(
domain
,
metric
,
mailTitle
,
alertResult
);
...
...
cat-home/src/main/java/com/dianping/cat/report/task/alert/exception/AlertExceptionBuilder.java
浏览文件 @
9894cea0
...
...
@@ -125,10 +125,10 @@ public class AlertExceptionBuilder {
return
limits
;
}
public
String
buildMailContent
(
String
exceptions
,
String
domain
)
{
public
String
buildMailContent
(
String
exceptions
,
String
domain
,
String
contactInfo
)
{
String
content
=
buildContent
(
exceptions
,
domain
);
String
url
=
"http://cat.dianpingoa.com/cat/r/p?domain="
+
domain
;
String
mailContent
=
content
+
" <a href='"
+
url
+
"'>点击此处查看详情</a>"
;
String
mailContent
=
content
+
"
<br/>"
+
contactInfo
+
"
<a href='"
+
url
+
"'>点击此处查看详情</a>"
;
return
mailContent
;
}
...
...
cat-home/src/main/java/com/dianping/cat/report/task/alert/exception/ExceptionAlert.java
浏览文件 @
9894cea0
...
...
@@ -34,6 +34,7 @@ import com.dianping.cat.service.ModelRequest;
import
com.dianping.cat.service.ModelResponse
;
import
com.dianping.cat.system.config.ExceptionConfigManager
;
import
com.dianping.cat.system.tool.MailSMS
;
import
com.site.lookup.util.StringUtils
;
public
class
ExceptionAlert
implements
Task
,
LogEnabled
{
...
...
@@ -86,6 +87,28 @@ public class ExceptionAlert implements Task, LogEnabled {
return
topMetric
;
}
private
String
buildContactInfo
(
String
domainName
)
{
try
{
Project
project
=
m_projectDao
.
findByDomain
(
domainName
,
ProjectEntity
.
READSET_FULL
);
String
owners
=
project
.
getOwner
();
String
phones
=
project
.
getPhone
();
StringBuilder
builder
=
new
StringBuilder
();
if
(!
StringUtils
.
isEmpty
(
owners
))
{
builder
.
append
(
"[业务负责人: "
).
append
(
owners
).
append
(
" ]"
);
}
if
(!
StringUtils
.
isEmpty
(
phones
))
{
builder
.
append
(
"[负责人手机号码: "
).
append
(
phones
).
append
(
" ]"
);
}
return
builder
.
toString
();
}
catch
(
Exception
ex
)
{
Cat
.
logError
(
"build contact info error for doamin: "
+
domainName
,
ex
);
}
return
null
;
}
@Override
public
void
enableLogging
(
Logger
logger
)
{
m_logger
=
logger
;
...
...
@@ -179,7 +202,8 @@ public class ExceptionAlert implements Task, LogEnabled {
List
<
String
>
phones
=
m_alertConfig
.
buildSMSReceivers
(
project
);
String
weixins
=
m_alertConfig
.
buildWeiXinReceivers
(
project
);
String
mailTitle
=
m_alertConfig
.
buildMailTitle
(
domain
,
null
);
String
mailContent
=
m_alertBuilder
.
buildMailContent
(
exceptions
.
toString
(),
domain
);
String
contactInfo
=
buildContactInfo
(
domain
);
String
mailContent
=
m_alertBuilder
.
buildMailContent
(
exceptions
.
toString
(),
domain
,
contactInfo
);
m_mailSms
.
sendEmail
(
mailTitle
,
mailContent
,
emails
);
m_logger
.
info
(
mailTitle
+
" "
+
mailContent
+
" "
+
emails
);
...
...
cat-home/src/main/resources/META-INF/plexus/components.xml
浏览文件 @
9894cea0
...
...
@@ -1826,6 +1826,9 @@
<requirement>
<role>
com.dianping.cat.report.task.alert.DataChecker
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.core.dal.ProjectDao
</role>
</requirement>
</requirements>
</component>
<component>
...
...
@@ -1862,6 +1865,9 @@
<requirement>
<role>
com.dianping.cat.report.task.alert.DataChecker
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.core.dal.ProjectDao
</role>
</requirement>
</requirements>
</component>
<component>
...
...
@@ -1898,6 +1904,9 @@
<requirement>
<role>
com.dianping.cat.report.task.alert.DataChecker
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.core.dal.ProjectDao
</role>
</requirement>
</requirements>
</component>
<component>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录