Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
dec8abcf
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,发现更多精彩内容 >>
提交
dec8abcf
编写于
7月 31, 2014
作者:
Y
youyong205
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #429 from jialinsun/master
js exception alert, modify system monitor,
上级
b645eaa2
4930ef23
变更
29
隐藏空白更改
内联
并排
Showing
29 changed file
with
374 addition
and
192 deletion
+374
-192
cat-agent/src/main/java/com/dianping/cat/agent/monitor/CommandUtils.java
...ain/java/com/dianping/cat/agent/monitor/CommandUtils.java
+19
-12
cat-agent/src/main/java/com/dianping/cat/agent/monitor/paas/DataBuilder.java
...java/com/dianping/cat/agent/monitor/paas/DataBuilder.java
+3
-3
cat-consumer/src/main/java/com/dianping/cat/consumer/top/TopAnalyzer.java
.../main/java/com/dianping/cat/consumer/top/TopAnalyzer.java
+2
-2
cat-core/src/main/java/com/dianping/cat/ServerConfigManager.java
...e/src/main/java/com/dianping/cat/ServerConfigManager.java
+6
-2
cat-core/src/main/resources/META-INF/dal/model/aggreation-model.xml
...rc/main/resources/META-INF/dal/model/aggreation-model.xml
+3
-1
cat-home/src/main/java/com/dianping/cat/build/ComponentsConfigurator.java
...n/java/com/dianping/cat/build/ComponentsConfigurator.java
+13
-5
cat-home/src/main/java/com/dianping/cat/report/page/dependency/ExternalInfoBuilder.java
...nping/cat/report/page/dependency/ExternalInfoBuilder.java
+7
-1
cat-home/src/main/java/com/dianping/cat/report/page/system/graph/SystemGraphCreator.java
...ping/cat/report/page/system/graph/SystemGraphCreator.java
+21
-12
cat-home/src/main/java/com/dianping/cat/report/page/top/Handler.java
...c/main/java/com/dianping/cat/report/page/top/Handler.java
+4
-1
cat-home/src/main/java/com/dianping/cat/report/page/top/TopMetric.java
...main/java/com/dianping/cat/report/page/top/TopMetric.java
+14
-2
cat-home/src/main/java/com/dianping/cat/report/task/alert/AlertConstants.java
...va/com/dianping/cat/report/task/alert/AlertConstants.java
+6
-0
cat-home/src/main/java/com/dianping/cat/report/task/alert/exception/AlertExceptionBuilder.java
...at/report/task/alert/exception/AlertExceptionBuilder.java
+31
-72
cat-home/src/main/java/com/dianping/cat/report/task/alert/exception/ExceptionAlert.java
...nping/cat/report/task/alert/exception/ExceptionAlert.java
+56
-22
cat-home/src/main/java/com/dianping/cat/report/task/alert/sender/decorator/DecoratorManager.java
.../report/task/alert/sender/decorator/DecoratorManager.java
+8
-0
cat-home/src/main/java/com/dianping/cat/report/task/alert/sender/decorator/ExceptionDecorator.java
...eport/task/alert/sender/decorator/ExceptionDecorator.java
+2
-2
cat-home/src/main/java/com/dianping/cat/report/task/alert/sender/decorator/FrontEndExceptionDecorator.java
...sk/alert/sender/decorator/FrontEndExceptionDecorator.java
+45
-0
cat-home/src/main/java/com/dianping/cat/report/task/alert/sender/receiver/ContactorManager.java
...t/report/task/alert/sender/receiver/ContactorManager.java
+8
-0
cat-home/src/main/java/com/dianping/cat/report/task/alert/sender/receiver/FrontEndExceptionContactor.java
...ask/alert/sender/receiver/FrontEndExceptionContactor.java
+49
-0
cat-home/src/main/resources/META-INF/dal/model/aggreation-codegen.xml
.../main/resources/META-INF/dal/model/aggreation-codegen.xml
+0
-15
cat-home/src/main/resources/META-INF/dal/model/aggreation-manifest.xml
...main/resources/META-INF/dal/model/aggreation-manifest.xml
+0
-6
cat-home/src/main/resources/META-INF/dal/model/aggreation-model.xml
...rc/main/resources/META-INF/dal/model/aggreation-model.xml
+0
-15
cat-home/src/main/resources/META-INF/plexus/components.xml
cat-home/src/main/resources/META-INF/plexus/components.xml
+31
-9
cat-home/src/main/resources/config/default-aggregation-config.xml
.../src/main/resources/config/default-aggregation-config.xml
+1
-1
cat-home/src/main/webapp/js/baseGraph.js
cat-home/src/main/webapp/js/baseGraph.js
+3
-3
cat-home/src/main/webapp/jsp/report/app.jsp
cat-home/src/main/webapp/jsp/report/app.jsp
+6
-3
cat-home/src/main/webapp/jsp/report/system.jsp
cat-home/src/main/webapp/jsp/report/system.jsp
+1
-0
cat-home/src/main/webapp/jsp/system/aggregation/aggregation.jsp
...me/src/main/webapp/jsp/system/aggregation/aggregation.jsp
+6
-2
cat-home/src/main/webapp/jsp/system/aggregation/aggregationUpdate.jsp
.../main/webapp/jsp/system/aggregation/aggregationUpdate.jsp
+9
-0
cat-home/src/main/webapp/jsp/system/thirdParty/thirdPartyConfig.jsp
...rc/main/webapp/jsp/system/thirdParty/thirdPartyConfig.jsp
+20
-1
未找到文件。
cat-agent/src/main/java/com/dianping/cat/agent/monitor/CommandUtils.java
浏览文件 @
dec8abcf
package
com.dianping.cat.agent.monitor
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.util.LinkedList
;
import
java.util.List
;
...
...
@@ -12,26 +11,34 @@ public class CommandUtils {
public
List
<
String
>
runShell
(
String
cmd
)
throws
Exception
{
List
<
String
>
result
=
new
LinkedList
<
String
>();
BufferedReader
reader
=
null
;
InputStreamReader
sReader
=
null
;
BufferedReader
bReader
=
null
;
Process
process
=
null
;
try
{
Process
process
=
Runtime
.
getRuntime
().
exec
(
new
String
[]
{
"/bin/sh"
,
"-c"
,
cmd
});
reader
=
new
BufferedReader
(
new
InputStreamReader
(
process
.
getInputStream
()));
process
=
Runtime
.
getRuntime
().
exec
(
new
String
[]
{
"/bin/sh"
,
"-c"
,
cmd
});
sReader
=
new
InputStreamReader
(
process
.
getInputStream
());
bReader
=
new
BufferedReader
(
sReader
);
String
line
=
null
;
while
((
line
=
r
eader
.
readLine
())
!=
null
&&
StringUtils
.
isNotEmpty
(
line
))
{
while
((
line
=
bR
eader
.
readLine
())
!=
null
&&
StringUtils
.
isNotEmpty
(
line
))
{
result
.
add
(
line
);
}
}
catch
(
Exception
e
)
{
throw
new
Exception
(
e
)
;
throw
e
;
}
finally
{
if
(
reader
!=
null
)
{
try
{
reader
.
close
();
}
catch
(
IOException
e
)
{
throw
new
Exception
(
e
);
try
{
if
(
sReader
!=
null
)
{
sReader
.
close
();
}
if
(
bReader
!=
null
)
{
bReader
.
close
();
}
if
(
process
!=
null
)
{
process
.
destroy
();
}
}
catch
(
Exception
e
)
{
throw
e
;
}
}
return
result
;
...
...
cat-agent/src/main/java/com/dianping/cat/agent/monitor/paas/DataBuilder.java
浏览文件 @
dec8abcf
...
...
@@ -152,11 +152,11 @@ public class DataBuilder {
try
{
outputs
=
m_commandUtils
.
runShell
(
cmd
);
return
convert2DataEntities
(
outputs
);
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
List
<
DataEntity
>
dataEntities
=
convert2DataEntities
(
outputs
);
return
dataEntities
;
return
new
ArrayList
<
DataEntity
>();
}
}
cat-consumer/src/main/java/com/dianping/cat/consumer/top/TopAnalyzer.java
浏览文件 @
dec8abcf
...
...
@@ -77,7 +77,7 @@ public class TopAnalyzer extends AbstractMessageAnalyzer<TopReport> implements L
for
(
String
name
:
domains
)
{
try
{
if
(
m_serverConfigManager
.
validate
Domain
(
name
)
&&
!
name
.
equals
(
Constants
.
ALL
))
{
if
(
m_serverConfigManager
.
filter
Domain
(
name
)
&&
!
name
.
equals
(
Constants
.
ALL
))
{
TransactionReport
report
=
m_transactionAnalyzer
.
getRawReport
(
name
);
transactionReportVisitor
.
visitTransactionReport
(
report
);
...
...
@@ -99,7 +99,7 @@ public class TopAnalyzer extends AbstractMessageAnalyzer<TopReport> implements L
for
(
String
name
:
domains
)
{
try
{
if
(
m_serverConfigManager
.
validate
Domain
(
name
)
&&
!
name
.
equals
(
Constants
.
ALL
))
{
if
(
m_serverConfigManager
.
filter
Domain
(
name
)
&&
!
name
.
equals
(
Constants
.
ALL
))
{
ProblemReport
report
=
m_problemAnalyzer
.
getReport
(
name
);
problemReportVisitor
.
visitProblemReport
(
report
);
...
...
cat-core/src/main/java/com/dianping/cat/ServerConfigManager.java
浏览文件 @
dec8abcf
...
...
@@ -338,9 +338,13 @@ public class ServerConfigManager implements Initializable, LogEnabled {
return
defaultValue
;
}
}
public
boolean
filterDomain
(
String
domain
)
{
return
!
domain
.
equals
(
"PhoenixAgent"
)
&&
!
domain
.
equals
(
Constants
.
ALL
);
}
public
boolean
validateDomain
(
String
domain
)
{
return
!
domain
.
equals
(
"PhoenixAgent"
)
&&
!
domain
.
equals
(
Constants
.
FRONT_END
)
&&
!
domain
.
equals
(
Constants
.
ALL
);
return
!
domain
.
equals
(
Constants
.
FRONT_END
)
&&
filterDomain
(
domain
);
}
}
cat-core/src/main/resources/META-INF/dal/model/aggreation-model.xml
浏览文件 @
dec8abcf
...
...
@@ -6,7 +6,9 @@
</entity>
<entity
name=
"aggregation-rule"
>
<attribute
name=
"pattern"
value-type=
"String"
key=
"true"
/>
<attribute
name=
"type"
value-type=
"int"
/>
<attribute
name=
"type"
value-type=
"int"
primitive=
"true"
/>
<attribute
name=
"warn"
value-type=
"int"
primitive=
"true"
default-value=
"200"
/>
<attribute
name=
"mails"
value-type=
"String"
/>
<attribute
name=
"domain"
value-type=
"String"
/>
<attribute
name=
"sample"
value-type=
"String"
/>
<attribute
name=
"display-name"
value-type=
"String"
/>
...
...
cat-home/src/main/java/com/dianping/cat/build/ComponentsConfigurator.java
浏览文件 @
dec8abcf
...
...
@@ -13,6 +13,7 @@ import org.unidal.lookup.configuration.Component;
import
com.dianping.cat.CatHomeModule
;
import
com.dianping.cat.ServerConfigManager
;
import
com.dianping.cat.config.aggregation.AggregationConfigManager
;
import
com.dianping.cat.config.app.AppDataCommandTableProvider
;
import
com.dianping.cat.config.app.AppDataService
;
import
com.dianping.cat.consumer.dependency.DependencyAnalyzer
;
...
...
@@ -70,6 +71,7 @@ import com.dianping.cat.report.task.alert.sender.decorator.BusinessDecorator;
import
com.dianping.cat.report.task.alert.sender.decorator.Decorator
;
import
com.dianping.cat.report.task.alert.sender.decorator.DecoratorManager
;
import
com.dianping.cat.report.task.alert.sender.decorator.ExceptionDecorator
;
import
com.dianping.cat.report.task.alert.sender.decorator.FrontEndExceptionDecorator
;
import
com.dianping.cat.report.task.alert.sender.decorator.NetworkDecorator
;
import
com.dianping.cat.report.task.alert.sender.decorator.SystemDecorator
;
import
com.dianping.cat.report.task.alert.sender.decorator.ThirdpartyDecorator
;
...
...
@@ -77,6 +79,7 @@ import com.dianping.cat.report.task.alert.sender.receiver.BusinessContactor;
import
com.dianping.cat.report.task.alert.sender.receiver.Contactor
;
import
com.dianping.cat.report.task.alert.sender.receiver.ContactorManager
;
import
com.dianping.cat.report.task.alert.sender.receiver.ExceptionContactor
;
import
com.dianping.cat.report.task.alert.sender.receiver.FrontEndExceptionContactor
;
import
com.dianping.cat.report.task.alert.sender.receiver.NetworkContactor
;
import
com.dianping.cat.report.task.alert.sender.receiver.SystemContactor
;
import
com.dianping.cat.report.task.alert.sender.receiver.ThirdpartyContactor
;
...
...
@@ -147,11 +150,15 @@ public class ComponentsConfigurator extends AbstractResourceConfigurator {
all
.
add
(
C
(
Contactor
.
class
,
ThirdpartyContactor
.
ID
,
ThirdpartyContactor
.
class
).
req
(
ProjectDao
.
class
,
AlertConfigManager
.
class
));
all
.
add
(
C
(
Contactor
.
class
,
FrontEndExceptionContactor
.
ID
,
FrontEndExceptionContactor
.
class
).
req
(
AggregationConfigManager
.
class
));
all
.
add
(
C
(
ContactorManager
.
class
).
req
(
Contactor
.
class
,
BusinessContactor
.
ID
,
"businessContactor"
)
.
req
(
Contactor
.
class
,
NetworkContactor
.
ID
,
"networkContactor"
)
.
req
(
Contactor
.
class
,
SystemContactor
.
ID
,
"exceptionContactor"
)
.
req
(
Contactor
.
class
,
ExceptionContactor
.
ID
,
"systemContactor"
)
.
req
(
Contactor
.
class
,
ThirdpartyContactor
.
ID
,
"thirdpartyContactor"
));
.
req
(
Contactor
.
class
,
ThirdpartyContactor
.
ID
,
"thirdpartyContactor"
)
.
req
(
Contactor
.
class
,
FrontEndExceptionContactor
.
ID
,
"frontEndExceptionContactor"
));
all
.
add
(
C
(
Decorator
.
class
,
BusinessDecorator
.
ID
,
BusinessDecorator
.
class
).
req
(
ProjectDao
.
class
));
...
...
@@ -163,11 +170,14 @@ public class ComponentsConfigurator extends AbstractResourceConfigurator {
all
.
add
(
C
(
Decorator
.
class
,
ThirdpartyDecorator
.
ID
,
ThirdpartyDecorator
.
class
).
req
(
ProjectDao
.
class
));
all
.
add
(
C
(
Decorator
.
class
,
FrontEndExceptionDecorator
.
ID
,
FrontEndExceptionDecorator
.
class
));
all
.
add
(
C
(
DecoratorManager
.
class
).
req
(
Decorator
.
class
,
BusinessDecorator
.
ID
,
"businessDecorator"
)
.
req
(
Decorator
.
class
,
NetworkDecorator
.
ID
,
"networkDecorator"
)
.
req
(
Decorator
.
class
,
ExceptionDecorator
.
ID
,
"exceptionDecorator"
)
.
req
(
Decorator
.
class
,
SystemDecorator
.
ID
,
"systemDecorator"
)
.
req
(
Decorator
.
class
,
ThirdpartyDecorator
.
ID
,
"thirdpartyDecorator"
));
.
req
(
Decorator
.
class
,
ThirdpartyDecorator
.
ID
,
"thirdpartyDecorator"
)
.
req
(
Decorator
.
class
,
FrontEndExceptionDecorator
.
ID
,
"frontEndExceptionDecorator"
));
all
.
add
(
C
(
AlertPolicyManager
.
class
).
req
(
ConfigDao
.
class
));
...
...
@@ -202,7 +212,7 @@ public class ComponentsConfigurator extends AbstractResourceConfigurator {
all
.
add
(
C
(
SystemAlert
.
class
).
req
(
ProductLineConfigManager
.
class
,
BaselineService
.
class
,
AlertInfo
.
class
).
req
(
RemoteMetricReportService
.
class
,
SystemRuleConfigManager
.
class
,
DataChecker
.
class
,
AlertManager
.
class
));
all
.
add
(
C
(
AlertExceptionBuilder
.
class
).
req
(
ExceptionConfigManager
.
class
));
all
.
add
(
C
(
AlertExceptionBuilder
.
class
).
req
(
ExceptionConfigManager
.
class
,
AggregationConfigManager
.
class
));
all
.
add
(
C
(
ExceptionAlert
.
class
)
.
req
(
ExceptionConfigManager
.
class
,
AlertExceptionBuilder
.
class
,
AlertManager
.
class
).
req
(
ModelService
.
class
,
...
...
@@ -344,8 +354,6 @@ public class ComponentsConfigurator extends AbstractResourceConfigurator {
all
.
add
(
C
(
AlertEntityService
.
class
).
req
(
AlertDao
.
class
));
all
.
add
(
C
(
AlertExceptionBuilder
.
class
).
req
(
ExceptionConfigManager
.
class
));
all
.
add
(
C
(
AlertSummaryExecutor
.
class
).
req
(
AlertSummaryGenerator
.
class
,
AlertSummaryManager
.
class
,
MailSMS
.
class
)
.
req
(
AlertSummaryDecorator
.
class
,
AlertSummaryFTLDecorator
.
ID
));
...
...
cat-home/src/main/java/com/dianping/cat/report/page/dependency/ExternalInfoBuilder.java
浏览文件 @
dec8abcf
...
...
@@ -2,6 +2,7 @@ package com.dianping.cat.report.page.dependency;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.HashSet
;
import
java.util.LinkedHashMap
;
...
...
@@ -13,6 +14,7 @@ import java.util.Set;
import
org.unidal.lookup.annotation.Inject
;
import
com.dianping.cat.Constants
;
import
com.dianping.cat.ServerConfigManager
;
import
com.dianping.cat.consumer.problem.ProblemAnalyzer
;
import
com.dianping.cat.consumer.problem.model.entity.ProblemReport
;
import
com.dianping.cat.consumer.top.TopAnalyzer
;
...
...
@@ -48,6 +50,9 @@ public class ExternalInfoBuilder {
@Inject
private
ExceptionConfigManager
m_configManager
;
@Inject
private
ServerConfigManager
m_serverConfigManager
;
private
SimpleDateFormat
m_dateFormat
=
new
SimpleDateFormat
(
"yyyyMMddHH"
);
private
SimpleDateFormat
m_sdf
=
new
SimpleDateFormat
(
"HH:mm"
);
...
...
@@ -114,7 +119,8 @@ public class ExternalInfoBuilder {
int
minuteCount
=
payload
.
getMinuteCounts
();
int
minute
=
model
.
getMinute
();
TopReport
report
=
queryTopReport
(
payload
);
TopMetric
topMetric
=
new
TopMetric
(
minuteCount
,
payload
.
getTopCounts
(),
m_configManager
);
List
<
String
>
excludeDomains
=
Arrays
.
asList
(
Constants
.
FRONT_END
);
TopMetric
topMetric
=
new
TopMetric
(
minuteCount
,
payload
.
getTopCounts
(),
m_configManager
,
excludeDomains
);
Date
end
=
new
Date
(
payload
.
getDate
()
+
TimeUtil
.
ONE_MINUTE
*
minute
);
Date
start
=
new
Date
(
end
.
getTime
()
-
TimeUtil
.
ONE_MINUTE
*
minuteCount
);
...
...
cat-home/src/main/java/com/dianping/cat/report/page/system/graph/SystemGraphCreator.java
浏览文件 @
dec8abcf
...
...
@@ -20,22 +20,30 @@ import com.dianping.cat.report.page.LineChart;
public
class
SystemGraphCreator
extends
AbstractGraphCreator
{
public
static
final
String
PAAS_SYSTEM
=
"paasSystem"
;
public
static
final
String
SYSTEM_TYPE
=
"system"
;
public
static
final
String
JVM_TYPE
=
"jvm"
;
public
static
final
String
NGINX_TYPE
=
"nginx"
;
private
static
final
List
<
String
>
SYSTEM_KEY_LIST
=
new
ArrayList
<
String
>(
Arrays
.
asList
(
"sysCpu:avg"
,
"iowaitCpu:avg"
,
"niceCpu:avg"
,
"stealCpu:avg"
,
"userCpu:avg"
,
"softirqCpu:avg"
,
"idleCpu:avg"
,
"irqCpu:avg"
,
"/-usage:avg"
,
"/-freeInodes:avg"
,
"/-read:sum"
,
"/-write:sum"
,
"/data-usage:avg"
,
"/data-freeInodes:avg"
,
"/data-read:sum"
,
"/data-write:sum"
,
"/usr-usage:avg"
,
"/usr-freeInodes:avg"
,
"/usr-read:sum"
,
"/usr-write:sum"
,
"/var-usage:avg"
,
"/var-freeInodes:avg"
,
"/var-read:sum"
,
"/var-write:sum"
,
"eth0-inFlow:sum"
,
"eth0-outFlow:sum"
,
"eth0-dropped:sum"
,
"eth0-errors:sum"
,
"eth0-collisions:sum"
,
"lo-inFlow:sum"
,
"lo-outFlow:sum"
,
"swapUsage:avg"
,
"loadAvg1:avg"
,
"loadAvg5:avg"
,
"totalMem:avg"
,
"usedMem:avg"
,
"freeMem:avg"
,
"sharedMem:avg"
,
"buffersMem:avg"
,
"cachedMem:avg"
,
"totalProcess:avg"
,
"runningProcess:avg"
,
"swapUsage:avg"
,
"establishedTcp:avg"
,
"loginUsers:avg"
,
"uptime:avg"
,
"md5Change:avg"
,
"hostNameChange:avg"
,
"hostIpChange:avg"
));
private
static
final
List
<
String
>
SYSTEM_KEY_LIST
=
Arrays
.
asList
(
"sysCpu:avg"
,
"iowaitCpu:avg"
,
"niceCpu:avg"
,
"stealCpu:avg"
,
"userCpu:avg"
,
"softirqCpu:avg"
,
"idleCpu:avg"
,
"irqCpu:avg"
,
"/-usage:avg"
,
"/-freeInodes:avg"
,
"/-read:sum"
,
"/-write:sum"
,
"/data-usage:avg"
,
"/data-freeInodes:avg"
,
"/data-read:sum"
,
"/data-write:sum"
,
"/usr-usage:avg"
,
"/usr-freeInodes:avg"
,
"/usr-read:sum"
,
"/usr-write:sum"
,
"/var-usage:avg"
,
"/var-freeInodes:avg"
,
"/var-read:sum"
,
"/var-write:sum"
,
"eth0-inFlow:sum"
,
"eth0-outFlow:sum"
,
"eth0-dropped:sum"
,
"eth0-errors:sum"
,
"eth0-collisions:sum"
,
"lo-inFlow:sum"
,
"lo-outFlow:sum"
,
"swapUsage:avg"
,
"loadAvg1:avg"
,
"loadAvg5:avg"
,
"totalMem:avg"
,
"usedMem:avg"
,
"freeMem:avg"
,
"sharedMem:avg"
,
"buffersMem:avg"
,
"cachedMem:avg"
,
"totalProcess:avg"
,
"runningProcess:avg"
,
"swapUsage:avg"
,
"establishedTcp:avg"
,
"loginUsers:avg"
);
private
static
final
List
<
String
>
PAAS_SYSTEM_KEY_LIST
=
Arrays
.
asList
(
"sysCpu:avg"
,
"userCpu:avg"
,
"cpuUsage:avg"
,
"/-usage:avg"
,
"/-freeInodes:avg"
,
"/-read:sum"
,
"/-write:sum"
,
"eth0-inFlow:sum"
,
"eth0-outFlow:sum"
,
"eth0-dropped:sum"
,
"eth0-errors:sum"
,
"eth0-collisions:sum"
,
"lo-inFlow:sum"
,
"lo-outFlow:sum"
,
"swapUsage:avg"
,
"totalMem:avg"
,
"usedMem:avg"
,
"freeMem:avg"
,
"sharedMem:avg"
,
"buffersMem:avg"
,
"cachedMem:avg"
,
"totalProcess:avg"
,
"runningProcess:avg"
,
"swapUsage:avg"
,
"establishedTcp:avg"
,
"loginUsers:avg"
);
private
static
final
List
<
String
>
JVM_KEY_LIST
=
new
ArrayList
<
String
>(
Arrays
.
asList
(
"edenUsage:avg"
,
"oldUsage:avg"
,
"permUsage:avg"
,
"catalinaLogSize:sum"
));
...
...
@@ -131,8 +139,9 @@ public class SystemGraphCreator extends AbstractGraphCreator {
}
protected
List
<
String
>
fetchExpectedKeys
(
String
type
)
{
if
(
SYSTEM_TYPE
.
equalsIgnoreCase
(
type
))
{
if
(
PAAS_SYSTEM
.
equalsIgnoreCase
(
type
))
{
return
PAAS_SYSTEM_KEY_LIST
;
}
else
if
(
SYSTEM_TYPE
.
equalsIgnoreCase
(
type
))
{
return
SYSTEM_KEY_LIST
;
}
else
if
(
JVM_TYPE
.
equalsIgnoreCase
(
type
))
{
return
JVM_KEY_LIST
;
...
...
cat-home/src/main/java/com/dianping/cat/report/page/top/Handler.java
浏览文件 @
dec8abcf
package
com.dianping.cat.report.page.top
;
import
java.io.IOException
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.List
;
import
javax.servlet.ServletException
;
...
...
@@ -79,7 +81,8 @@ public class Handler implements PageHandler<Context> {
}
else
{
minuteCount
=
payload
.
getMinuteCounts
();
}
TopMetric
displayTop
=
new
TopMetric
(
minuteCount
,
payload
.
getTopCounts
(),
m_configManager
);
List
<
String
>
excludeDomains
=
Arrays
.
asList
(
Constants
.
FRONT_END
);
TopMetric
displayTop
=
new
TopMetric
(
minuteCount
,
payload
.
getTopCounts
(),
m_configManager
,
excludeDomains
);
displayTop
.
visitTopReport
(
report
);
model
.
setTopReport
(
report
);
...
...
cat-home/src/main/java/com/dianping/cat/report/page/top/TopMetric.java
浏览文件 @
dec8abcf
...
...
@@ -24,6 +24,8 @@ public class TopMetric extends BaseVisitor {
private
ExceptionConfigManager
m_configManager
;
private
List
<
String
>
m_excludedDomains
;
private
String
m_currentDomain
;
private
Date
m_currentStart
;
...
...
@@ -60,6 +62,11 @@ public class TopMetric extends BaseVisitor {
m_cache
=
new
MetricItem
(
count
,
tops
);
}
public
TopMetric
(
int
count
,
int
tops
,
ExceptionConfigManager
configManager
,
List
<
String
>
excludedDomains
)
{
this
(
count
,
tops
,
configManager
);
m_excludedDomains
=
excludedDomains
;
}
public
MetricItem
getCache
()
{
return
m_cache
;
}
...
...
@@ -101,7 +108,12 @@ public class TopMetric extends BaseVisitor {
@Override
public
void
visitDomain
(
Domain
domain
)
{
m_currentDomain
=
domain
.
getName
();
super
.
visitDomain
(
domain
);
if
(
m_excludedDomains
==
null
)
{
super
.
visitDomain
(
domain
);
}
else
if
(!
m_excludedDomains
.
contains
(
m_currentDomain
))
{
super
.
visitDomain
(
domain
);
}
}
@Override
...
...
@@ -258,7 +270,7 @@ public class TopMetric extends BaseVisitor {
public
int
compare
(
Item
o1
,
Item
o2
)
{
int
alert
=
o2
.
getAlert
()
-
o1
.
getAlert
();
int
value
=
(
int
)
(
o2
.
getValue
()
-
o1
.
getValue
());
return
alert
==
0
?
value
:
alert
;
}
}
...
...
cat-home/src/main/java/com/dianping/cat/report/task/alert/AlertConstants.java
浏览文件 @
dec8abcf
...
...
@@ -6,6 +6,8 @@ public class AlertConstants {
public
static
final
String
EXCEPTION
=
"exception"
;
public
static
final
String
FRONT_END_EXCEPTION
=
"frontEndException"
;
public
static
final
String
NETWORK
=
"network"
;
public
static
final
String
SYSTEM
=
"system"
;
...
...
@@ -18,4 +20,8 @@ public class AlertConstants {
public
static
final
String
WEIXIN
=
"weixin"
;
public
static
final
String
WARNING_EXCEPTION
=
"warning"
;
public
static
final
String
ERROR_EXCEPTION
=
"error"
;
}
cat-home/src/main/java/com/dianping/cat/report/task/alert/exception/AlertExceptionBuilder.java
浏览文件 @
dec8abcf
package
com.dianping.cat.report.task.alert.exception
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -11,9 +9,12 @@ import java.util.Map.Entry;
import
org.unidal.lookup.annotation.Inject
;
import
org.unidal.tuple.Pair
;
import
com.dianping.cat.config.aggregation.AggregationConfigManager
;
import
com.dianping.cat.configuration.aggreation.model.entity.AggregationRule
;
import
com.dianping.cat.home.dependency.exception.entity.ExceptionExclude
;
import
com.dianping.cat.home.dependency.exception.entity.ExceptionLimit
;
import
com.dianping.cat.report.page.top.TopMetric.Item
;
import
com.dianping.cat.report.task.alert.AlertConstants
;
import
com.dianping.cat.system.config.ExceptionConfigManager
;
public
class
AlertExceptionBuilder
{
...
...
@@ -21,11 +22,14 @@ public class AlertExceptionBuilder {
@Inject
private
ExceptionConfigManager
m_exceptionConfigManager
;
@Inject
private
AggregationConfigManager
m_aggregationConfigManager
;
public
Map
<
String
,
List
<
AlertException
>>
buildAlertExceptions
(
List
<
Item
>
items
)
{
Map
<
String
,
List
<
AlertException
>>
alertExceptions
=
new
LinkedHashMap
<
String
,
List
<
AlertException
>>();
for
(
Item
item
:
items
)
{
List
<
AlertException
>
domainAlertExceptions
=
buildDomainAlertException
List
(
item
);
List
<
AlertException
>
domainAlertExceptions
=
buildDomainAlertException
s
(
item
);
if
(!
domainAlertExceptions
.
isEmpty
())
{
alertExceptions
.
put
(
item
.
getDomain
(),
domainAlertExceptions
);
...
...
@@ -34,7 +38,26 @@ public class AlertExceptionBuilder {
return
alertExceptions
;
}
private
List
<
AlertException
>
buildDomainAlertExceptionList
(
Item
item
)
{
public
List
<
AlertException
>
buildFrontEndAlertExceptions
(
Item
frontEndItem
)
{
List
<
AlertException
>
alertExceptions
=
new
ArrayList
<
AlertException
>();
for
(
Entry
<
String
,
Double
>
entry
:
frontEndItem
.
getException
().
entrySet
())
{
String
exception
=
entry
.
getKey
();
AggregationRule
rule
=
m_aggregationConfigManager
.
queryAggration
(
exception
);
if
(
rule
!=
null
)
{
int
warn
=
rule
.
getWarn
();
double
value
=
entry
.
getValue
().
doubleValue
();
if
(
value
>=
warn
)
{
alertExceptions
.
add
(
new
AlertException
(
exception
,
AlertConstants
.
WARNING_EXCEPTION
,
value
));
}
}
}
return
alertExceptions
;
}
private
List
<
AlertException
>
buildDomainAlertExceptions
(
Item
item
)
{
String
domain
=
item
.
getDomain
();
List
<
AlertException
>
alertExceptions
=
new
ArrayList
<
AlertException
>();
Pair
<
Double
,
Double
>
totalLimitPair
=
queryDomainTotalLimit
(
domain
);
...
...
@@ -54,19 +77,19 @@ public class AlertExceptionBuilder {
totalException
+=
value
;
if
(
errorLimit
>
0
&&
value
>=
errorLimit
)
{
alertExceptions
.
add
(
new
AlertException
(
exceptionName
,
Alert
Exception
.
ERROR_EXCEPTION
,
value
,
alertExceptions
.
add
(
new
AlertException
(
exceptionName
,
Alert
Constants
.
ERROR_EXCEPTION
,
value
,
needSendSms
(
domain
,
exceptionName
)));
}
else
if
(
warnLimit
>
0
&&
value
>=
warnLimit
)
{
alertExceptions
.
add
(
new
AlertException
(
exceptionName
,
Alert
Exception
.
WARN
_EXCEPTION
,
value
));
alertExceptions
.
add
(
new
AlertException
(
exceptionName
,
Alert
Constants
.
WARNING
_EXCEPTION
,
value
));
}
}
}
if
(
totalErrorLimit
>
0
&&
totalException
>=
totalErrorLimit
)
{
alertExceptions
.
add
(
new
AlertException
(
ExceptionConfigManager
.
TOTAL_STRING
,
Alert
Exception
.
ERROR_EXCEPTION
,
alertExceptions
.
add
(
new
AlertException
(
ExceptionConfigManager
.
TOTAL_STRING
,
Alert
Constants
.
ERROR_EXCEPTION
,
totalException
,
needSendSms
(
domain
,
ExceptionConfigManager
.
TOTAL_STRING
)));
}
else
if
(
totalWarnLimit
>
0
&&
totalException
>=
totalWarnLimit
)
{
alertExceptions
.
add
(
new
AlertException
(
ExceptionConfigManager
.
TOTAL_STRING
,
Alert
Exception
.
WARN
_EXCEPTION
,
alertExceptions
.
add
(
new
AlertException
(
ExceptionConfigManager
.
TOTAL_STRING
,
Alert
Constants
.
WARNING
_EXCEPTION
,
totalException
));
}
...
...
@@ -125,72 +148,8 @@ public class AlertExceptionBuilder {
return
limits
;
}
public
String
buildMailContent
(
String
exceptions
,
String
domain
,
String
contactInfo
)
{
String
content
=
buildContent
(
exceptions
,
domain
,
contactInfo
);
String
date
=
new
SimpleDateFormat
(
"yyyyMMddHH"
).
format
(
new
Date
());
String
url
=
"http://cat.dianpingoa.com/cat/r/p?domain="
+
domain
+
"&date="
+
date
;
String
mailContent
=
content
+
"<br/>"
+
" <a href='"
+
url
+
"'>点击此处查看详情</a>"
;
return
mailContent
;
}
public
String
buildDBContent
(
String
exceptions
,
String
domain
)
{
String
content
=
buildContent
(
exceptions
,
domain
);
String
url
=
"http://cat.dianpingoa.com/cat/r/p?domain="
+
domain
;
String
mailContent
=
content
+
"<br/>"
+
" <a href='"
+
url
+
"'>点击此处查看详情</a>"
;
return
mailContent
;
}
public
String
buildContent
(
String
exceptions
,
String
domain
)
{
StringBuilder
sb
=
new
StringBuilder
();
String
time
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm"
).
format
(
new
Date
());
sb
.
append
(
"[CAT异常告警] [项目: "
).
append
(
domain
).
append
(
"] : "
);
sb
.
append
(
exceptions
).
append
(
"[时间: "
).
append
(
time
).
append
(
"]"
);
return
sb
.
toString
();
}
public
String
buildContent
(
String
exceptions
,
String
domain
,
String
contactInfo
)
{
StringBuilder
sb
=
new
StringBuilder
();
String
time
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm"
).
format
(
new
Date
());
sb
.
append
(
"[CAT异常告警] [项目: "
).
append
(
domain
).
append
(
"] : "
);
sb
.
append
(
exceptions
).
append
(
"[时间: "
).
append
(
time
).
append
(
"]"
).
append
(
"\n"
);
sb
.
append
(
contactInfo
);
return
sb
.
toString
();
}
public
List
<
AlertException
>
buildErrorException
(
List
<
AlertException
>
exceptions
)
{
List
<
AlertException
>
errorExceptions
=
new
ArrayList
<
AlertException
>();
for
(
AlertException
alertException
:
exceptions
)
{
if
(
AlertException
.
ERROR_EXCEPTION
.
equals
(
alertException
.
getType
()))
{
errorExceptions
.
add
(
alertException
);
}
}
return
errorExceptions
;
}
public
List
<
AlertException
>
buildErrorAndTriggeredException
(
List
<
AlertException
>
exceptions
)
{
List
<
AlertException
>
errorExceptions
=
new
ArrayList
<
AlertException
>();
for
(
AlertException
alertException
:
exceptions
)
{
if
(
AlertException
.
ERROR_EXCEPTION
.
equals
(
alertException
.
getType
())
&&
alertException
.
isTriggered
())
{
errorExceptions
.
add
(
alertException
);
}
}
return
errorExceptions
;
}
public
class
AlertException
{
private
static
final
String
WARN_EXCEPTION
=
"warn"
;
private
static
final
String
ERROR_EXCEPTION
=
"error"
;
private
String
m_name
;
private
String
m_type
;
...
...
cat-home/src/main/java/com/dianping/cat/report/task/alert/exception/ExceptionAlert.java
浏览文件 @
dec8abcf
...
...
@@ -94,32 +94,27 @@ public class ExceptionAlert implements Task {
try
{
TopMetric
topMetric
=
buildTopMetric
(
new
Date
(
current
-
TimeUtil
.
ONE_MINUTE
*
2
));
Collection
<
List
<
Item
>>
items
=
topMetric
.
getError
().
getResult
().
values
();
List
<
Item
>
item
=
new
ArrayList
<
Item
>();
Collection
<
List
<
Item
>>
item
List
s
=
topMetric
.
getError
().
getResult
().
values
();
List
<
Item
>
item
List
=
new
ArrayList
<
Item
>();
if
(!
items
.
isEmpty
())
{
item
=
item
s
.
iterator
().
next
();
if
(!
item
List
s
.
isEmpty
())
{
item
List
=
itemList
s
.
iterator
().
next
();
}
Map
<
String
,
List
<
AlertException
>>
alertExceptions
=
m_alertBuilder
.
buildAlertExceptions
(
item
);
for
(
Entry
<
String
,
List
<
AlertException
>>
entry
:
alertExceptions
.
entrySet
())
{
try
{
String
domain
=
entry
.
getKey
();
List
<
AlertException
>
exceptions
=
entry
.
getValue
();
for
(
AlertException
exception
:
exceptions
)
{
String
metricName
=
exception
.
getName
();
AlertEntity
entity
=
new
AlertEntity
();
entity
.
setDate
(
new
Date
()).
setContent
(
exception
.
toString
()).
setLevel
(
exception
.
getType
());
entity
.
setMetric
(
metricName
).
setType
(
getName
()).
setGroup
(
domain
);
m_sendManager
.
addAlert
(
entity
);
}
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
Item
frontEndItem
=
null
;
List
<
Item
>
otherItemList
=
new
ArrayList
<
Item
>();
for
(
Item
item
:
itemList
)
{
if
(
Constants
.
FRONT_END
.
equals
(
item
.
getDomain
()))
{
frontEndItem
=
item
;
}
else
{
otherItemList
.
add
(
item
);
}
}
if
(
frontEndItem
!=
null
)
{
handleFrontEndException
(
frontEndItem
);
}
handleGeneralExceptions
(
itemList
);
t
.
setStatus
(
Transaction
.
SUCCESS
);
}
catch
(
Exception
e
)
{
t
.
setStatus
(
e
);
...
...
@@ -138,6 +133,45 @@ public class ExceptionAlert implements Task {
}
}
private
void
handleGeneralExceptions
(
List
<
Item
>
itemList
)
{
Map
<
String
,
List
<
AlertException
>>
alertExceptions
=
m_alertBuilder
.
buildAlertExceptions
(
itemList
);
for
(
Entry
<
String
,
List
<
AlertException
>>
entry
:
alertExceptions
.
entrySet
())
{
try
{
String
domain
=
entry
.
getKey
();
List
<
AlertException
>
exceptions
=
entry
.
getValue
();
for
(
AlertException
exception
:
exceptions
)
{
String
metricName
=
exception
.
getName
();
AlertEntity
entity
=
new
AlertEntity
();
entity
.
setDate
(
new
Date
()).
setContent
(
exception
.
toString
()).
setLevel
(
exception
.
getType
());
entity
.
setMetric
(
metricName
).
setType
(
getName
()).
setGroup
(
domain
);
m_sendManager
.
addAlert
(
entity
);
}
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
}
}
private
void
handleFrontEndException
(
Item
frontEndItem
)
{
List
<
AlertException
>
alertExceptions
=
m_alertBuilder
.
buildFrontEndAlertExceptions
(
frontEndItem
);
for
(
AlertException
exception
:
alertExceptions
)
{
try
{
String
metricName
=
exception
.
getName
();
AlertEntity
entity
=
new
AlertEntity
();
entity
.
setDate
(
new
Date
()).
setContent
(
exception
.
toString
()).
setLevel
(
exception
.
getType
());
entity
.
setMetric
(
metricName
).
setType
(
AlertConstants
.
FRONT_END_EXCEPTION
).
setGroup
(
metricName
);
m_sendManager
.
addAlert
(
entity
);
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
}
}
@Override
public
void
shutdown
()
{
}
...
...
cat-home/src/main/java/com/dianping/cat/report/task/alert/sender/decorator/DecoratorManager.java
浏览文件 @
dec8abcf
...
...
@@ -27,6 +27,9 @@ public class DecoratorManager implements Initializable {
@Inject
(
type
=
Decorator
.
class
,
value
=
ThirdpartyDecorator
.
ID
)
private
Decorator
m_thirdpartyDecorator
;
@Inject
(
type
=
Decorator
.
class
,
value
=
FrontEndExceptionDecorator
.
ID
)
private
Decorator
m_frontEndExceptionDecorator
;
private
Map
<
String
,
Decorator
>
m_decorators
=
new
HashMap
<
String
,
Decorator
>();
public
Pair
<
String
,
String
>
generateTitleAndContent
(
AlertEntity
alert
)
{
...
...
@@ -50,6 +53,7 @@ public class DecoratorManager implements Initializable {
m_decorators
.
put
(
m_exceptionDecorator
.
getId
(),
m_exceptionDecorator
);
m_decorators
.
put
(
m_systemDecorator
.
getId
(),
m_systemDecorator
);
m_decorators
.
put
(
m_thirdpartyDecorator
.
getId
(),
m_thirdpartyDecorator
);
m_decorators
.
put
(
m_frontEndExceptionDecorator
.
getId
(),
m_frontEndExceptionDecorator
);
}
public
void
setBusinessDecorator
(
Decorator
decorator
)
{
...
...
@@ -72,4 +76,8 @@ public class DecoratorManager implements Initializable {
m_thirdpartyDecorator
=
decorator
;
}
public
void
setFrontEndExceptionDecorator
(
Decorator
decorator
)
{
m_frontEndExceptionDecorator
=
decorator
;
}
}
cat-home/src/main/java/com/dianping/cat/report/task/alert/sender/decorator/ExceptionDecorator.java
浏览文件 @
dec8abcf
...
...
@@ -23,7 +23,7 @@ public class ExceptionDecorator extends DefaultDecorator implements Initializabl
public
static
final
String
ID
=
AlertConstants
.
EXCEPTION
;
pr
ivate
DateFormat
m_dateFormat
=
new
SimpleDateFormat
(
"yyyyMMddHH"
);
pr
otected
DateFormat
m_dateFormat
=
new
SimpleDateFormat
(
"yyyyMMddHH"
);
@Override
public
String
getId
()
{
...
...
@@ -51,7 +51,7 @@ public class ExceptionDecorator extends DefaultDecorator implements Initializabl
return
sw
.
toString
();
}
pr
ivate
Map
<
Object
,
Object
>
generateExceptionMap
(
AlertEntity
alert
)
{
pr
otected
Map
<
Object
,
Object
>
generateExceptionMap
(
AlertEntity
alert
)
{
String
domain
=
alert
.
getGroup
();
String
contactInfo
=
buildContactInfo
(
domain
);
Map
<
Object
,
Object
>
map
=
new
HashMap
<
Object
,
Object
>();
...
...
cat-home/src/main/java/com/dianping/cat/report/task/alert/sender/decorator/FrontEndExceptionDecorator.java
0 → 100644
浏览文件 @
dec8abcf
package
com.dianping.cat.report.task.alert.sender.decorator
;
import
java.util.HashMap
;
import
java.util.Map
;
import
com.dianping.cat.Constants
;
import
com.dianping.cat.report.task.alert.AlertConstants
;
import
com.dianping.cat.report.task.alert.sender.AlertEntity
;
public
class
FrontEndExceptionDecorator
extends
ExceptionDecorator
{
public
static
final
String
ID
=
AlertConstants
.
FRONT_END_EXCEPTION
;
@Override
public
String
getId
()
{
return
ID
;
}
@Override
public
String
generateTitle
(
AlertEntity
alert
)
{
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
"[CAT异常告警] [项目: "
).
append
(
Constants
.
FRONT_END
).
append
(
"]"
);
return
sb
.
toString
();
}
@Override
protected
Map
<
Object
,
Object
>
generateExceptionMap
(
AlertEntity
alert
)
{
String
domain
=
Constants
.
FRONT_END
;
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
protected
String
buildContactInfo
(
String
domainName
)
{
return
""
;
}
}
cat-home/src/main/java/com/dianping/cat/report/task/alert/sender/receiver/ContactorManager.java
浏览文件 @
dec8abcf
...
...
@@ -28,6 +28,9 @@ public class ContactorManager implements Initializable {
@Inject
(
type
=
Contactor
.
class
,
value
=
ThirdpartyContactor
.
ID
)
private
Contactor
m_thirdpartyContactor
;
@Inject
(
type
=
Contactor
.
class
,
value
=
FrontEndExceptionContactor
.
ID
)
private
Contactor
m_frontEndExceptionContactor
;
private
Map
<
String
,
Contactor
>
m_contactors
=
new
HashMap
<
String
,
Contactor
>();
public
List
<
String
>
queryReceivers
(
String
group
,
String
channel
,
String
type
)
{
...
...
@@ -51,6 +54,7 @@ public class ContactorManager implements Initializable {
m_contactors
.
put
(
m_exceptionContactor
.
getId
(),
m_exceptionContactor
);
m_contactors
.
put
(
m_systemContactor
.
getId
(),
m_systemContactor
);
m_contactors
.
put
(
m_thirdpartyContactor
.
getId
(),
m_thirdpartyContactor
);
m_contactors
.
put
(
m_frontEndExceptionContactor
.
getId
(),
m_frontEndExceptionContactor
);
}
public
void
setBusinessContactor
(
Contactor
contactor
)
{
...
...
@@ -73,4 +77,8 @@ public class ContactorManager implements Initializable {
m_thirdpartyContactor
=
thirdpartyContactor
;
}
public
void
setFrontEndExceptionContactor
(
Contactor
frontEndExceptionContactor
)
{
m_frontEndExceptionContactor
=
frontEndExceptionContactor
;
}
}
cat-home/src/main/java/com/dianping/cat/report/task/alert/sender/receiver/FrontEndExceptionContactor.java
0 → 100644
浏览文件 @
dec8abcf
package
com.dianping.cat.report.task.alert.sender.receiver
;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.unidal.helper.Splitters
;
import
org.unidal.lookup.annotation.Inject
;
import
com.dianping.cat.config.aggregation.AggregationConfigManager
;
import
com.dianping.cat.configuration.aggreation.model.entity.AggregationRule
;
import
com.dianping.cat.report.task.alert.AlertConstants
;
public
class
FrontEndExceptionContactor
implements
Contactor
{
@Inject
private
AggregationConfigManager
m_configManager
;
public
static
final
String
ID
=
AlertConstants
.
FRONT_END_EXCEPTION
;
@Override
public
String
getId
()
{
return
ID
;
}
@Override
public
List
<
String
>
queryEmailContactors
(
String
id
)
{
AggregationRule
rule
=
m_configManager
.
queryAggration
(
id
);
if
(
rule
!=
null
)
{
String
mails
=
rule
.
getMails
();
List
<
String
>
receiver
=
Splitters
.
by
(
","
).
noEmptyItem
().
split
(
mails
);
return
receiver
;
}
else
{
return
new
ArrayList
<
String
>();
}
}
@Override
public
List
<
String
>
queryWeiXinContactors
(
String
id
)
{
return
null
;
}
@Override
public
List
<
String
>
querySmsContactors
(
String
id
)
{
return
null
;
}
}
cat-home/src/main/resources/META-INF/dal/model/aggreation-codegen.xml
已删除
100644 → 0
浏览文件 @
b645eaa2
<?xml version="1.0" encoding="UTF-8"?>
<model>
<entity
name=
"aggregation"
root=
"true"
>
<entity-ref
name=
"aggregation-rule"
type=
"list"
names=
"aggregation-rules"
/>
</entity>
<entity
name=
"aggregation-rule"
>
<attribute
name=
"type"
value-type=
"int"
/>
<attribute
name=
"domain"
value-type=
"String"
/>
<attribute
name=
"pattern"
value-type=
"String"
/>
<attribute
name=
"sample"
value-type=
"String"
/>
<attribute
name=
"display-name"
value-type=
"String"
/>
<attribute
name=
"creation-date"
value-type=
"Date"
format=
"yyyy-MM-dd HH:mm:ss"
/>
</entity>
</model>
cat-home/src/main/resources/META-INF/dal/model/aggreation-manifest.xml
已删除
100644 → 0
浏览文件 @
b645eaa2
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<file
path=
"aggreation-codegen.xml"
/>
<file
path=
"aggreation-model.xml"
/>
</manifest>
cat-home/src/main/resources/META-INF/dal/model/aggreation-model.xml
已删除
100644 → 0
浏览文件 @
b645eaa2
<?xml version="1.0" encoding="UTF-8"?>
<model
model-package=
"com.dianping.cat.home.aggreation"
enable-merger=
"false"
enable-sax-parser=
"true"
enable-base-visitor=
"false"
>
<entity
name=
"aggregation"
root=
"true"
>
<entity-ref
name=
"aggregation-rule"
type=
"map"
names=
"aggregation-rules"
method-find-or-create=
"true"
/>
</entity>
<entity
name=
"aggregation-rule"
>
<attribute
name=
"pattern"
value-type=
"String"
key=
"true"
/>
<attribute
name=
"type"
value-type=
"int"
/>
<attribute
name=
"domain"
value-type=
"String"
/>
<attribute
name=
"sample"
value-type=
"String"
/>
<attribute
name=
"display-name"
value-type=
"String"
/>
<attribute
name=
"creation-date"
value-type=
"Date"
format=
"yyyy-MM-dd HH:mm:ss"
/>
</entity>
</model>
cat-home/src/main/resources/META-INF/plexus/components.xml
浏览文件 @
dec8abcf
...
...
@@ -479,15 +479,6 @@
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.report.task.alert.exception.AlertExceptionBuilder
</role>
<implementation>
com.dianping.cat.report.task.alert.exception.AlertExceptionBuilder
</implementation>
<requirements>
<requirement>
<role>
com.dianping.cat.system.config.ExceptionConfigManager
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.report.task.alert.summary.AlertSummaryExecutor
</role>
<implementation>
com.dianping.cat.report.task.alert.summary.AlertSummaryExecutor
</implementation>
...
...
@@ -628,6 +619,16 @@
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.report.task.alert.sender.receiver.Contactor
</role>
<role-hint>
frontEndException
</role-hint>
<implementation>
com.dianping.cat.report.task.alert.sender.receiver.FrontEndExceptionContactor
</implementation>
<requirements>
<requirement>
<role>
com.dianping.cat.config.aggregation.AggregationConfigManager
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.report.task.alert.sender.receiver.ContactorManager
</role>
<implementation>
com.dianping.cat.report.task.alert.sender.receiver.ContactorManager
</implementation>
...
...
@@ -657,6 +658,11 @@
<role-hint>
thirdParty
</role-hint>
<field-name>
thirdpartyContactor
</field-name>
</requirement>
<requirement>
<role>
com.dianping.cat.report.task.alert.sender.receiver.Contactor
</role>
<role-hint>
frontEndException
</role-hint>
<field-name>
frontEndExceptionContactor
</field-name>
</requirement>
</requirements>
</component>
<component>
...
...
@@ -709,6 +715,11 @@
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.report.task.alert.sender.decorator.Decorator
</role>
<role-hint>
frontEndException
</role-hint>
<implementation>
com.dianping.cat.report.task.alert.sender.decorator.FrontEndExceptionDecorator
</implementation>
</component>
<component>
<role>
com.dianping.cat.report.task.alert.sender.decorator.DecoratorManager
</role>
<implementation>
com.dianping.cat.report.task.alert.sender.decorator.DecoratorManager
</implementation>
...
...
@@ -738,6 +749,11 @@
<role-hint>
thirdParty
</role-hint>
<field-name>
thirdpartyDecorator
</field-name>
</requirement>
<requirement>
<role>
com.dianping.cat.report.task.alert.sender.decorator.Decorator
</role>
<role-hint>
frontEndException
</role-hint>
<field-name>
frontEndExceptionDecorator
</field-name>
</requirement>
</requirements>
</component>
<component>
...
...
@@ -941,6 +957,9 @@
<requirement>
<role>
com.dianping.cat.system.config.ExceptionConfigManager
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.config.aggregation.AggregationConfigManager
</role>
</requirement>
</requirements>
</component>
<component>
...
...
@@ -3591,6 +3610,9 @@
<requirement>
<role>
com.dianping.cat.system.config.ExceptionConfigManager
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.ServerConfigManager
</role>
</requirement>
</requirements>
</component>
<component>
...
...
cat-home/src/main/resources/config/default-aggregation-config.xml
浏览文件 @
dec8abcf
<?xml version="1.0" encoding="utf-8"?>
<aggregation>
<aggregation-rule
type=
"3"
domain=
"FrontEnd"
pattern=
"http://w.51ping.com/shop/{shopId}"
sample=
"http://w.51ping.com/shop/5722322"
display-name=
"http://w.51ping.com/shop/{shopId}"
creation-date=
"2013-06-05 15:42:03"
/>
<aggregation-rule
type=
"3"
domain=
"FrontEnd"
pattern=
"http://w.51ping.com/shop/{shopId}"
sample=
"http://w.51ping.com/shop/5722322"
display-name=
"http://w.51ping.com/shop/{shopId}"
warn=
"10"
email=
"jialin.sun@dianping.com"
creation-date=
"2013-06-05 15:42:03"
/>
<aggregation-rule
type=
"3"
domain=
"FrontEnd"
pattern=
"http://i{x}.dpfile.com/{*}"
sample=
"http://i1.dpfile.com/s/j"
display-name=
"http://i{x}.dpfile.com/{*}"
creation-date=
"2013-05-20 13:34:00"
/>
<aggregation-rule
type=
"3"
domain=
"FrontEnd"
pattern=
"http://www.dianping.com/{City}/food "
display-name=
"http://www.dianping.com/{City}/food "
creation-date=
"2013-05-20 13:34:00"
/>
<aggregation-rule
type=
"3"
domain=
"FrontEnd"
pattern=
"http://www.dianping.com/{City}/wedding"
display-name=
"http://www.dianping.com/{City}/wedding"
creation-date=
"2013-05-20 13:34:00"
/>
...
...
cat-home/src/main/webapp/js/baseGraph.js
浏览文件 @
dec8abcf
...
...
@@ -175,7 +175,7 @@ function parseMetricLineDataForApp(data) {
return
res
;
}
function
graphMetricChartForApp
(
container
,
data
)
{
function
graphMetricChartForApp
(
container
,
data
,
datePair
)
{
Highcharts
.
setOptions
({
global
:
{
useUTC
:
false
...
...
@@ -238,8 +238,8 @@ function graphMetricChartForApp(container, data) {
if
(
Number
(
number1
)
==
Number
(
number0
))
{
number
=
number0
;
}
return
Highcharts
.
dateFormat
(
'
%Y-%m-%d %H:%M
'
,
this
.
x
)
return
Highcharts
.
dateFormat
(
'
%Y-%m-%d %H:%M
'
,
this
.
x
*
300000
-
8
*
3600000
+
Date
.
parse
(
datePair
[
this
.
series
.
name
])
)
+
'
<br/>[
'
+
this
.
series
.
name
+
'
]
'
+
'
<b>
'
+
number
+
'
</b>
'
;
}
...
...
cat-home/src/main/webapp/jsp/report/app.jsp
浏览文件 @
dec8abcf
...
...
@@ -124,8 +124,6 @@
$
(
"
#command
"
).
val
(
words
[
1
]);
if
(
words
[
0
]
==
null
||
words
.
length
==
1
)
{
console
.
log
(
words
.
length
);
$
(
"
#time
"
).
val
(
getDate
());
}
else
{
$
(
"
#time
"
).
val
(
words
[
0
]);
...
...
@@ -139,6 +137,9 @@
$
(
"
#platform
"
).
val
(
words
[
6
]);
$
(
"
#city
"
).
val
(
words
[
7
]);
$
(
"
#operator
"
).
val
(
words
[
8
]);
var
datePair
=
{};
datePair
[
"
查询1
"
]
=
$
(
"
#time
"
).
val
();
if
(
query2
!=
null
&&
query2
!=
''
)
{
$
(
'
#history
'
).
slideDown
();
...
...
@@ -150,6 +151,8 @@
}
else
{
$
(
"
#time2
"
).
val
(
words
[
0
]);
}
datePair
[
"
查询2
"
]
=
$
(
"
#time2
"
).
val
();
$
(
"
#command2
"
).
val
(
words
[
1
]);
command2Change
();
...
...
@@ -175,7 +178,7 @@
var
data
=
$
{
model
.
lineChart
.
jsonString
};
graphMetricChartForApp
(
document
.
getElementById
(
'
${model.lineChart.id}
'
),
data
);
.
getElementById
(
'
${model.lineChart.id}
'
),
data
,
datePair
);
});
</script>
...
...
cat-home/src/main/webapp/jsp/report/system.jsp
浏览文件 @
dec8abcf
...
...
@@ -200,6 +200,7 @@
<select
style=
"width: 200px;"
name=
"domain"
id=
"domain"
></select>
查询类型
<select
style=
"width: 100px;"
name=
"type"
id=
"type"
>
<option
value=
"paasSystem"
>
Paas系统
</option>
<option
value=
"system"
>
系统
</option>
<option
value=
"jvm"
>
JVM
</option>
<option
value=
"nginx"
>
Nginx
</option>
...
...
cat-home/src/main/webapp/jsp/system/aggregation/aggregation.jsp
浏览文件 @
dec8abcf
...
...
@@ -30,7 +30,9 @@
<tr
class=
"odd"
>
<th
width=
"15%"
>
报表类型
</th>
<th
width=
"10%"
>
域名
</th>
<th
width=
"70%"
>
规则
</th>
<th
width=
"60%"
>
规则
</th>
<th
width=
"10%"
>
告警阈值
</th>
<th
width=
"15%"
>
联系邮件
</th>
<!-- <th width="15%">显示名称</th>
<th width="8%">示例</th> -->
<th
width=
"5%"
>
操作
<a
class=
'btn btn-primary btn-small'
href=
"?op=aggregationUpdate"
>
新增
</a></th>
...
...
@@ -51,7 +53,9 @@
</c:when>
</c:choose>
<td>
${item.domain}
</td>
<td>
${item.pattern}
</td>
<%--
<td>
${item.pattern}
</td>
<td>
${item.warn}
</td>
<td>
${item.mails}
</td>
<%--
<td>${item.displayName}</td>
<td>${item.sample}</td> --%>
<td><a
class=
'btn btn-small btn-primary'
href=
"?op=aggregationUpdate&pattern=${item.pattern}"
>
编辑
</a>
...
...
cat-home/src/main/webapp/jsp/system/aggregation/aggregationUpdate.jsp
浏览文件 @
dec8abcf
...
...
@@ -54,6 +54,15 @@
<td>
模板
</td>
<td><input
type=
"text"
class=
"input-xlarge"
placeholder=
"选择被聚合对象的模板"
name=
"aggregation.pattern"
required
value=
"${model.aggregationRule.pattern}"
/></td>
</tr>
<tr>
<td>
告警阈值
</td>
<td><input
type=
"text"
class=
"input-xlarge"
placeholder=
"告警阈值"
name=
"aggregation.warn"
required
value=
"${model.aggregationRule.warn}"
/></td>
</tr>
<tr>
<td>
联系邮件
</td>
<td><input
type=
"text"
class=
"input-xlarge"
placeholder=
"联系邮件"
name=
"aggregation.mails"
required
value=
"${model.aggregationRule.mails}"
/></td>
</tr>
<%-- <tr>
<td>显示名称</td>
<td><input type="text" class="input-xlarge" placeholder="聚合显示的名称" name="aggregation.displayName" required value="${model.aggregationRule.displayName}"/></td>
...
...
cat-home/src/main/webapp/jsp/system/thirdParty/thirdPartyConfig.jsp
浏览文件 @
dec8abcf
...
...
@@ -19,9 +19,28 @@
action=
"${model.pageUri}?op=thirdPartyConfigUpdate"
>
<h4
class=
"text-center text-error"
id=
"state"
>
</h4>
<h4
class=
"text-center text-error"
>
第三方监控配置
</h4>
<table
class=
"table table-striped table-bordered table-condensed table-hover"
>
<tr>
<td><textarea
name=
"content"
style=
"width:auto"
rows=
"20"
cols=
"150"
>
${model.content}
</textarea></td>
<td
style=
"width:60%"
>
<textarea
name=
"content"
style=
"width:100%"
rows=
"20"
cols=
"150"
>
${model.content}
</textarea>
</td>
<td
style=
"width:40%"
>
<h4>
1. HTTP
</h4>
<p><span
class=
"text-error"
>
[url]
</span>
:监控的对象
</p>
<p><span
class=
"text-error"
>
[type]
</span>
:
<span
class=
"text-error"
>
get
</span>
或
<span
class=
"text-error"
>
post
</span></p>
<p><span
class=
"text-error"
>
[domain]
</span>
:依赖于该第三方的项目名,会向该项目组联系人发第三方告警
</p>
<p><span
class=
"text-error"
>
[par]
</span>
:请求中包含的参数,
<span
class=
"text-error"
>
id
</span>
为参数名称,
<span
class=
"text-error"
>
value
</span>
为参数值
</p>
<p>
例如:
<xmp
style=
"width:auto"
><http
url=
"http://cat.dp:8080"
type=
"get"
domain=
"Cat"
>
<par
id=
"domain"
value=
"Cat"
/>
<par
id=
"date"
value=
"2014073111"
/>
</http>
</xmp>
</p>
<br/>
所有标红部分均为小写。
</td>
</tr>
<tr>
<td
style=
"text-align:center"
><input
class=
'btn btn-primary'
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录