Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
c7ea21a4
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,发现更多精彩内容 >>
提交
c7ea21a4
编写于
5月 27, 2014
作者:
L
leon.li
浏览文件
操作
浏览文件
下载
差异文件
merge newest code
上级
0cbc24c1
78e815a2
变更
80
隐藏空白更改
内联
并排
Showing
80 changed file
with
1335 addition
and
564 deletion
+1335
-564
cat-broker/src/main/java/com/dianping/cat/broker/api/page/MonitorManager.java
...java/com/dianping/cat/broker/api/page/MonitorManager.java
+4
-2
cat-broker/src/main/java/com/dianping/cat/broker/api/page/RequestUtils.java
...n/java/com/dianping/cat/broker/api/page/RequestUtils.java
+1
-1
cat-consumer-advanced/src/main/java/com/dianping/cat/consumer/build/ComponentsConfigurator.java
...m/dianping/cat/consumer/build/ComponentsConfigurator.java
+1
-1
cat-consumer-advanced/src/main/java/com/dianping/cat/consumer/metric/MetricAnalyzer.java
...java/com/dianping/cat/consumer/metric/MetricAnalyzer.java
+14
-47
cat-consumer-advanced/src/main/java/com/dianping/cat/consumer/metric/MetricConfigManager.java
...com/dianping/cat/consumer/metric/MetricConfigManager.java
+34
-0
cat-consumer-advanced/src/main/java/com/dianping/cat/consumer/metric/ProductLineConfigManager.java
...ianping/cat/consumer/metric/ProductLineConfigManager.java
+41
-11
cat-consumer-advanced/src/main/resources/META-INF/dal/model/metric-report-model.xml
...main/resources/META-INF/dal/model/metric-report-model.xml
+9
-0
cat-consumer-advanced/src/main/resources/META-INF/plexus/components.xml
...dvanced/src/main/resources/META-INF/plexus/components.xml
+7
-4
cat-consumer-advanced/src/test/resources/com/dianping/cat/consumer/metric/metric_analyzer.xml
...rces/com/dianping/cat/consumer/metric/metric_analyzer.xml
+0
-46
cat-consumer/src/main/java/com/dianping/cat/consumer/heartbeat/HeartbeatAnalyzer.java
...om/dianping/cat/consumer/heartbeat/HeartbeatAnalyzer.java
+2
-1
cat-consumer/src/main/resources/META-INF/dal/model/company-model.xml
...r/src/main/resources/META-INF/dal/model/company-model.xml
+2
-0
cat-core/src/main/java/com/dianping/cat/Constants.java
cat-core/src/main/java/com/dianping/cat/Constants.java
+3
-1
cat-core/src/main/java/com/dianping/cat/Monitor.java
cat-core/src/main/java/com/dianping/cat/Monitor.java
+10
-0
cat-hadoop/src/main/java/com/dianping/cat/hadoop/hdfs/UploaderAndCleaner.java
...java/com/dianping/cat/hadoop/hdfs/UploaderAndCleaner.java
+1
-1
cat-home/pom.xml
cat-home/pom.xml
+1
-0
cat-home/src/main/java/com/dianping/cat/build/ComponentsConfigurator.java
...n/java/com/dianping/cat/build/ComponentsConfigurator.java
+9
-3
cat-home/src/main/java/com/dianping/cat/build/ServiceComponentConfigurator.java
.../com/dianping/cat/build/ServiceComponentConfigurator.java
+1
-1
cat-home/src/main/java/com/dianping/cat/build/TaskComponentConfigurator.java
...ava/com/dianping/cat/build/TaskComponentConfigurator.java
+4
-1
cat-home/src/main/java/com/dianping/cat/report/chart/AggregationGraphCreator.java
...om/dianping/cat/report/chart/AggregationGraphCreator.java
+4
-7
cat-home/src/main/java/com/dianping/cat/report/chart/BaseGraphCreator.java
.../java/com/dianping/cat/report/chart/BaseGraphCreator.java
+44
-58
cat-home/src/main/java/com/dianping/cat/report/chart/GraphCreator.java
...main/java/com/dianping/cat/report/chart/GraphCreator.java
+1
-1
cat-home/src/main/java/com/dianping/cat/report/chart/NetworkGraphCreator.java
...va/com/dianping/cat/report/chart/NetworkGraphCreator.java
+3
-4
cat-home/src/main/java/com/dianping/cat/report/page/PieChart.java
.../src/main/java/com/dianping/cat/report/page/PieChart.java
+20
-4
cat-home/src/main/java/com/dianping/cat/report/page/dependency/Handler.java
...java/com/dianping/cat/report/page/dependency/Handler.java
+1
-1
cat-home/src/main/java/com/dianping/cat/report/page/dependency/graph/TopologyGraphBuilder.java
...at/report/page/dependency/graph/TopologyGraphBuilder.java
+1
-1
cat-home/src/main/java/com/dianping/cat/report/page/dependency/graph/TopologyGraphManager.java
...at/report/page/dependency/graph/TopologyGraphManager.java
+7
-5
cat-home/src/main/java/com/dianping/cat/report/page/jsError/Handler.java
...in/java/com/dianping/cat/report/page/jsError/Handler.java
+19
-17
cat-home/src/main/java/com/dianping/cat/report/page/model/metric/MetricReportMerger.java
...ping/cat/report/page/model/metric/MetricReportMerger.java
+7
-0
cat-home/src/main/java/com/dianping/cat/report/page/network/Handler.java
...in/java/com/dianping/cat/report/page/network/Handler.java
+2
-2
cat-home/src/main/java/com/dianping/cat/report/page/network/nettopology/NetGraphBuilder.java
.../cat/report/page/network/nettopology/NetGraphBuilder.java
+20
-0
cat-home/src/main/java/com/dianping/cat/report/page/userMonitor/CityManager.java
...com/dianping/cat/report/page/userMonitor/CityManager.java
+3
-1
cat-home/src/main/java/com/dianping/cat/report/page/userMonitor/Handler.java
...ava/com/dianping/cat/report/page/userMonitor/Handler.java
+7
-2
cat-home/src/main/java/com/dianping/cat/report/page/userMonitor/Model.java
.../java/com/dianping/cat/report/page/userMonitor/Model.java
+10
-0
cat-home/src/main/java/com/dianping/cat/report/page/userMonitor/UserMonitorConvert.java
...nping/cat/report/page/userMonitor/UserMonitorConvert.java
+44
-1
cat-home/src/main/java/com/dianping/cat/report/page/userMonitor/graph/DefaultUserMonitGraphCreator.java
.../page/userMonitor/graph/DefaultUserMonitGraphCreator.java
+53
-10
cat-home/src/main/java/com/dianping/cat/report/page/userMonitor/graph/UserMonitorGraphCreator.java
...eport/page/userMonitor/graph/UserMonitorGraphCreator.java
+2
-1
cat-home/src/main/java/com/dianping/cat/report/service/CachedReportTask.java
...ava/com/dianping/cat/report/service/CachedReportTask.java
+83
-80
cat-home/src/main/java/com/dianping/cat/report/task/exceptionAlert/AlertReportBuilder.java
...ng/cat/report/task/exceptionAlert/AlertReportBuilder.java
+8
-2
cat-home/src/main/java/com/dianping/cat/report/task/exceptionAlert/ExceptionAlert.java
...anping/cat/report/task/exceptionAlert/ExceptionAlert.java
+31
-11
cat-home/src/main/java/com/dianping/cat/report/task/exceptionAlert/TopReportVisitor.java
...ping/cat/report/task/exceptionAlert/TopReportVisitor.java
+39
-15
cat-home/src/main/java/com/dianping/cat/report/task/metric/AlertInfo.java
...n/java/com/dianping/cat/report/task/metric/AlertInfo.java
+18
-6
cat-home/src/main/java/com/dianping/cat/report/task/metric/MetricAlert.java
...java/com/dianping/cat/report/task/metric/MetricAlert.java
+2
-3
cat-home/src/main/java/com/dianping/cat/report/task/metric/MetricAlertConfig.java
...om/dianping/cat/report/task/metric/MetricAlertConfig.java
+15
-9
cat-home/src/main/java/com/dianping/cat/report/task/metric/SwitchAlert.java
...java/com/dianping/cat/report/task/metric/SwitchAlert.java
+1
-2
cat-home/src/main/java/com/dianping/cat/system/config/ExceptionExcludeConfigManager.java
...ping/cat/system/config/ExceptionExcludeConfigManager.java
+125
-0
cat-home/src/main/java/com/dianping/cat/system/config/ExceptionThresholdConfigManager.java
...ng/cat/system/config/ExceptionThresholdConfigManager.java
+3
-2
cat-home/src/main/java/com/dianping/cat/system/page/config/Handler.java
...ain/java/com/dianping/cat/system/page/config/Handler.java
+16
-20
cat-home/src/main/resources/META-INF/dal/model/exception-exclude-config-codegen.xml
...s/META-INF/dal/model/exception-exclude-config-codegen.xml
+15
-0
cat-home/src/main/resources/META-INF/dal/model/exception-exclude-config-manifest.xml
.../META-INF/dal/model/exception-exclude-config-manifest.xml
+6
-0
cat-home/src/main/resources/META-INF/dal/model/exception-exclude-config-model.xml
...ces/META-INF/dal/model/exception-exclude-config-model.xml
+16
-0
cat-home/src/main/resources/META-INF/dal/model/netgraph-model.xml
.../src/main/resources/META-INF/dal/model/netgraph-model.xml
+8
-0
cat-home/src/main/resources/META-INF/plexus/components.xml
cat-home/src/main/resources/META-INF/plexus/components.xml
+52
-5
cat-home/src/main/resources/META-INF/wizard/model/wizard.xml
cat-home/src/main/resources/META-INF/wizard/model/wizard.xml
+3
-0
cat-home/src/main/resources/config/city
cat-home/src/main/resources/config/city
+1
-0
cat-home/src/main/resources/config/default-exception-exclude-config.xml
...ain/resources/config/default-exception-exclude-config.xml
+11
-0
cat-home/src/main/resources/config/default-nettopology-config.xml
.../src/main/resources/config/default-nettopology-config.xml
+22
-21
cat-home/src/main/webapp/images/networkMetric.jpeg
cat-home/src/main/webapp/images/networkMetric.jpeg
+0
-0
cat-home/src/main/webapp/js/netgraph.js
cat-home/src/main/webapp/js/netgraph.js
+31
-7
cat-home/src/main/webapp/jsp/report/home/exceptionDocument.jsp
...ome/src/main/webapp/jsp/report/home/exceptionDocument.jsp
+18
-3
cat-home/src/main/webapp/jsp/report/home/integratingBusiness.jsp
...e/src/main/webapp/jsp/report/home/integratingBusiness.jsp
+1
-1
cat-home/src/main/webapp/jsp/report/home/integratingDocument.jsp
...e/src/main/webapp/jsp/report/home/integratingDocument.jsp
+1
-1
cat-home/src/main/webapp/jsp/report/home/networkDocument.jsp
cat-home/src/main/webapp/jsp/report/home/networkDocument.jsp
+42
-17
cat-home/src/main/webapp/jsp/report/network.jsp
cat-home/src/main/webapp/jsp/report/network.jsp
+0
-5
cat-home/src/main/webapp/jsp/report/network/nettopology.jsp
cat-home/src/main/webapp/jsp/report/network/nettopology.jsp
+1
-1
cat-home/src/main/webapp/jsp/report/userMonitor.jsp
cat-home/src/main/webapp/jsp/report/userMonitor.jsp
+89
-69
cat-home/src/main/webapp/jsp/system/configTree.jsp
cat-home/src/main/webapp/jsp/system/configTree.jsp
+1
-0
cat-home/src/main/webapp/jsp/system/exceptionExclude/exceptionExclude.jsp
...n/webapp/jsp/system/exceptionExclude/exceptionExclude.jsp
+97
-0
cat-home/src/main/webapp/jsp/system/exceptionExclude/exceptionExcludeConfig.jsp
...pp/jsp/system/exceptionExclude/exceptionExcludeConfig.jsp
+65
-0
cat-home/src/main/webapp/jsp/system/exceptionThreshold/exceptionThreshold.jsp
...bapp/jsp/system/exceptionThreshold/exceptionThreshold.jsp
+0
-0
cat-home/src/main/webapp/jsp/system/exceptionThreshold/exceptionThresholdConfig.jsp
...sp/system/exceptionThreshold/exceptionThresholdConfig.jsp
+0
-0
cat-home/src/main/webapp/jsp/system/metric/metricConfigs.jsp
cat-home/src/main/webapp/jsp/system/metric/metricConfigs.jsp
+3
-1
cat-home/src/main/webapp/jsp/system/productLine/topologyProductLineAdd.jsp
.../webapp/jsp/system/productLine/topologyProductLineAdd.jsp
+15
-2
cat-home/src/main/webapp/jsp/system/productLine/topologyProductLines.jsp
...in/webapp/jsp/system/productLine/topologyProductLines.jsp
+10
-7
cat-home/src/main/webapp/jsp/system/urlPattern/urlPattern.jsp
...home/src/main/webapp/jsp/system/urlPattern/urlPattern.jsp
+1
-1
cat-home/src/main/webapp/jsp/system/urlPattern/urlPatternUpdate.jsp
...rc/main/webapp/jsp/system/urlPattern/urlPatternUpdate.jsp
+3
-2
cat-home/src/test/java/com/dianping/cat/demo/TestCode.java
cat-home/src/test/java/com/dianping/cat/demo/TestCode.java
+0
-1
cat-home/src/test/java/com/dianping/cat/report/page/metric/TestCode.java
...st/java/com/dianping/cat/report/page/metric/TestCode.java
+44
-24
cat-home/src/test/java/com/dianping/cat/report/task/exceptionAlert/TopReportVisitorTest.java
.../cat/report/task/exceptionAlert/TopReportVisitorTest.java
+33
-4
cat-home/src/test/resources/com/dianping/cat/report/page/dependency/exception-exclude-config.xml
...g/cat/report/page/dependency/exception-exclude-config.xml
+11
-0
cat-home/src/test/resources/com/dianping/cat/report/task/exceptionAlert/alertReport.xml
...m/dianping/cat/report/task/exceptionAlert/alertReport.xml
+2
-7
未找到文件。
cat-broker/src/main/java/com/dianping/cat/broker/api/page/MonitorManager.java
浏览文件 @
c7ea21a4
...
...
@@ -108,7 +108,7 @@ public class MonitorManager implements Initializable, LogEnabled {
if
(
ipInfo
!=
null
)
{
Transaction
t
=
Cat
.
newTransaction
(
"Monitor"
,
url
);
try
{
String
city
=
ipInfo
.
getProvince
()
+
"-"
+
ipInfo
.
getCity
();
String
channel
=
ipInfo
.
getChannel
();
...
...
@@ -119,10 +119,12 @@ public class MonitorManager implements Initializable, LogEnabled {
String
group
=
url
;
if
(
duration
>
0
)
{
logMetric
(
timestamp
,
duration
,
group
,
city
+
":"
+
channel
+
":"
+
Monitor
.
HIT
);
logMetric
(
timestamp
,
duration
,
group
,
city
+
":"
+
channel
+
":"
+
Monitor
.
AVG
);
}
if
(!
"200"
.
equals
(
httpCode
)
||
!
StringUtils
.
isEmpty
(
errorCode
))
{
logMetric
(
timestamp
,
duration
,
group
,
city
+
":"
+
channel
+
":"
+
Monitor
.
ERROR
);
}
else
{
logMetric
(
timestamp
,
duration
,
group
,
city
+
":"
+
channel
+
":"
+
Monitor
.
HIT
);
}
if
(!
StringUtils
.
isEmpty
(
httpCode
))
{
String
key
=
city
+
":"
+
channel
+
":"
+
Monitor
.
HTTP_STATUS
+
"|"
+
httpCode
;
...
...
cat-broker/src/main/java/com/dianping/cat/broker/api/page/RequestUtils.java
浏览文件 @
c7ea21a4
...
...
@@ -37,7 +37,7 @@ public class RequestUtils {
}
public
String
getRemoteIp
(
HttpServletRequest
request
)
{
return
filterXForwardedForIP
(
request
.
getHeader
(
"x-forwarded-for"
));
return
filterXForwardedForIP
(
request
.
get
RemoteAddr
()
+
","
+
request
.
get
Header
(
"x-forwarded-for"
));
}
}
\ No newline at end of file
cat-consumer-advanced/src/main/java/com/dianping/cat/consumer/build/ComponentsConfigurator.java
浏览文件 @
c7ea21a4
...
...
@@ -53,8 +53,8 @@ public class ComponentsConfigurator extends AbstractResourceConfigurator {
private
Collection
<
Component
>
defineMetricComponents
()
{
final
List
<
Component
>
all
=
new
ArrayList
<
Component
>();
all
.
add
(
C
(
MetricConfigManager
.
class
).
req
(
ConfigDao
.
class
));
all
.
add
(
C
(
ProductLineConfigManager
.
class
).
req
(
ConfigDao
.
class
));
all
.
add
(
C
(
MetricConfigManager
.
class
).
req
(
ConfigDao
.
class
,
ProductLineConfigManager
.
class
));
all
.
add
(
C
(
MessageAnalyzer
.
class
,
MetricAnalyzer
.
ID
,
MetricAnalyzer
.
class
).
is
(
PER_LOOKUP
)
//
.
req
(
BucketManager
.
class
,
BusinessReportDao
.
class
,
MetricConfigManager
.
class
)
//
.
req
(
ProductLineConfigManager
.
class
,
TaskManager
.
class
));
...
...
cat-consumer-advanced/src/main/java/com/dianping/cat/consumer/metric/MetricAnalyzer.java
浏览文件 @
c7ea21a4
...
...
@@ -12,7 +12,6 @@ import org.unidal.lookup.util.StringUtils;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.Constants
;
import
com.dianping.cat.advanced.metric.config.entity.MetricItemConfig
;
import
com.dianping.cat.analysis.AbstractMessageAnalyzer
;
import
com.dianping.cat.configuration.NetworkInterfaceManager
;
import
com.dianping.cat.consumer.advanced.dal.BusinessReport
;
...
...
@@ -53,6 +52,8 @@ public class MetricAnalyzer extends AbstractMessageAnalyzer<MetricReport> implem
// key is project line,such as tuangou
private
Map
<
String
,
MetricReport
>
m_reports
=
new
HashMap
<
String
,
MetricReport
>();
private
static
final
String
METRIC
=
"Metric"
;
@Override
public
void
doCheckpoint
(
boolean
atEnd
)
{
storeReports
(
atEnd
);
...
...
@@ -75,20 +76,6 @@ public class MetricAnalyzer extends AbstractMessageAnalyzer<MetricReport> implem
return
report
;
}
private
void
insertDefaultProductline
(
String
type
,
String
domain
)
{
String
group
;
group
=
type
;
boolean
userMonitor
=
false
;
boolean
networkMonitor
=
false
;
if
(
"broker-service"
.
equals
(
domain
))
{
userMonitor
=
true
;
}
else
{
networkMonitor
=
true
;
}
m_productLineConfigManager
.
insertIfNotExsit
(
group
,
domain
,
userMonitor
,
networkMonitor
);
}
protected
void
loadReports
()
{
Bucket
<
String
>
reportBucket
=
null
;
...
...
@@ -161,9 +148,6 @@ public class MetricAnalyzer extends AbstractMessageAnalyzer<MetricReport> implem
Message
message
=
tree
.
getMessage
();
if
(
message
instanceof
Transaction
)
{
processMetricOnTransaction
(
product
,
report
,
(
Transaction
)
message
,
tree
);
}
if
(
message
instanceof
Transaction
)
{
processTransaction
(
product
,
report
,
tree
,
(
Transaction
)
message
);
}
else
if
(
message
instanceof
Metric
)
{
...
...
@@ -173,54 +157,37 @@ public class MetricAnalyzer extends AbstractMessageAnalyzer<MetricReport> implem
private
int
processMetric
(
String
group
,
MetricReport
report
,
MessageTree
tree
,
Metric
metric
)
{
String
type
=
metric
.
getType
();
String
n
ame
=
metric
.
getName
();
String
metricN
ame
=
metric
.
getName
();
String
domain
=
tree
.
getDomain
();
String
data
=
(
String
)
metric
.
getData
();
String
status
=
metric
.
getStatus
();
ConfigItem
config
=
parseValue
(
status
,
data
);
if
(!
StringUtils
.
isEmpty
(
type
))
{
insertDefaultProductline
(
type
,
domain
);
m_productLineConfigManager
.
insertIfNotExsit
(
type
,
domain
);
}
if
(
config
!=
null
)
{
long
current
=
metric
.
getTimestamp
()
/
1000
/
60
;
int
min
=
(
int
)
(
current
%
(
60
));
String
key
=
m_configManager
.
buildMetricKey
(
domain
,
"Metric"
,
n
ame
);
String
key
=
m_configManager
.
buildMetricKey
(
domain
,
METRIC
,
metricN
ame
);
MetricItem
metricItem
=
report
.
findOrCreateMetricItem
(
key
);
metricItem
.
addDomain
(
domain
).
setType
(
status
);
updateMetric
(
metricItem
,
min
,
config
.
getCount
(),
config
.
getValue
());
config
.
setTitle
(
name
);
m_configManager
.
insertIfNotExist
(
domain
,
"Metric"
,
name
,
config
);
config
.
setTitle
(
metricName
);
insertDefaultConfig
(
metricName
,
domain
,
config
);
}
return
0
;
}
private
void
processMetricOnTransaction
(
String
product
,
MetricReport
report
,
Transaction
transaction
,
MessageTree
tree
)
{
String
type
=
transaction
.
getType
();
if
(
type
.
equals
(
"Service"
))
{
type
=
"PigeonService"
;
}
if
(
"URL"
.
equals
(
type
)
||
"PigeonService"
.
equals
(
type
))
{
String
domain
=
tree
.
getDomain
();
String
name
=
transaction
.
getName
();
String
key
=
m_configManager
.
buildMetricKey
(
domain
,
type
,
name
);
MetricItemConfig
config
=
m_configManager
.
queryMetricItemConfig
(
key
);
if
(
config
!=
null
)
{
long
current
=
transaction
.
getTimestamp
()
/
1000
/
60
;
int
min
=
(
int
)
(
current
%
(
60
));
double
sum
=
transaction
.
getDurationInMicros
();
MetricItem
metricItem
=
report
.
findOrCreateMetricItem
(
key
);
metricItem
.
addDomain
(
domain
).
setType
(
"C"
);
updateMetric
(
metricItem
,
min
,
1
,
sum
);
}
}
}
private
void
insertDefaultConfig
(
String
metricName
,
String
domain
,
ConfigItem
config
)
{
//外部监控Key不需要存储
if
(!
Constants
.
BROKER_SERVICE
.
equals
(
domain
))
{
m_configManager
.
insertIfNotExist
(
domain
,
METRIC
,
metricName
,
config
);
}
}
private
int
processTransaction
(
String
group
,
MetricReport
report
,
MessageTree
tree
,
Transaction
t
)
{
int
count
=
0
;
...
...
cat-consumer-advanced/src/main/java/com/dianping/cat/consumer/metric/MetricConfigManager.java
浏览文件 @
c7ea21a4
...
...
@@ -19,6 +19,7 @@ import org.unidal.lookup.annotation.Inject;
import
org.xml.sax.SAXException
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.Constants
;
import
com.dianping.cat.advanced.metric.config.entity.MetricConfig
;
import
com.dianping.cat.advanced.metric.config.entity.MetricItemConfig
;
import
com.dianping.cat.advanced.metric.config.transform.DefaultSaxParser
;
...
...
@@ -32,6 +33,9 @@ public class MetricConfigManager implements Initializable {
@Inject
protected
ConfigDao
m_configDao
;
@Inject
private
ProductLineConfigManager
m_productLineConfigManager
;
private
int
m_configId
;
private
MetricConfig
m_metricConfig
;
...
...
@@ -86,6 +90,36 @@ public class MetricConfigManager implements Initializable {
if
(
m_metricConfig
==
null
)
{
m_metricConfig
=
new
MetricConfig
();
}
deleteUnusedConfig
();
}
private
void
deleteUnusedConfig
()
{
try
{
Map
<
String
,
MetricItemConfig
>
configs
=
m_metricConfig
.
getMetricItemConfigs
();
List
<
String
>
unused
=
new
ArrayList
<
String
>();
for
(
MetricItemConfig
config
:
configs
.
values
())
{
String
domain
=
config
.
getDomain
();
String
productLine
=
m_productLineConfigManager
.
queryProductLineByDomain
(
domain
);
if
(
Constants
.
BROKER_SERVICE
.
equals
(
domain
))
{
unused
.
add
(
config
.
getId
());
}
if
(
"Default"
.
equals
(
productLine
))
{
unused
.
add
(
config
.
getId
());
}
if
(!
config
.
getId
().
contains
(
":Metric:"
))
{
unused
.
add
(
config
.
getId
());
}
}
for
(
String
id
:
unused
)
{
m_metricConfig
.
removeMetricItemConfig
(
id
);
}
storeConfig
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
public
boolean
insertIfNotExist
(
String
domain
,
String
type
,
String
metricKey
,
ConfigItem
item
)
{
...
...
cat-consumer-advanced/src/main/java/com/dianping/cat/consumer/metric/ProductLineConfigManager.java
浏览文件 @
c7ea21a4
...
...
@@ -23,6 +23,7 @@ import org.unidal.lookup.annotation.Inject;
import
org.xml.sax.SAXException
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.Constants
;
import
com.dianping.cat.consumer.company.model.entity.Company
;
import
com.dianping.cat.consumer.company.model.entity.Domain
;
import
com.dianping.cat.consumer.company.model.entity.ProductLine
;
...
...
@@ -54,7 +55,15 @@ public class ProductLineConfigManager implements Initializable, LogEnabled {
public
static
final
String
USER_MONITOR
=
"外部监控"
;
public
static
final
String
ERROR_MONITOR
=
"错误监控"
;
public
static
final
String
APPLICATION_MONITOR
=
"应用监控"
;
public
static
final
String
SYSTEM_MONITOR
=
"系统监控"
;
public
static
final
String
NETWORK_SWITCH_PREFIX
=
"switch-"
;
public
static
final
String
NETWORK_F5_PREFIX
=
"f5-"
;
public
static
final
String
SYSTEM_MONITOR_PREFIX
=
"system-"
;
private
Map
<
String
,
String
>
buildDomainToProductLines
()
{
Map
<
String
,
ProductLine
>
productLines
=
getCompany
().
getProductLines
();
...
...
@@ -118,7 +127,26 @@ public class ProductLineConfigManager implements Initializable, LogEnabled {
m_domainToProductLines
=
buildDomainToProductLines
();
}
public
boolean
insertIfNotExsit
(
String
line
,
String
domain
,
boolean
userMonitor
,
boolean
networkMonitor
)
{
public
void
buildDefaultDashboard
(
ProductLine
productLine
,
String
domain
)
{
String
line
=
productLine
.
getId
();
boolean
userMonitor
=
false
;
boolean
networkMonitor
=
false
;
boolean
systemMonitor
=
false
;
if
(
Constants
.
BROKER_SERVICE
.
equals
(
domain
))
{
userMonitor
=
true
;
}
else
if
(
line
.
toLowerCase
().
startsWith
(
NETWORK_SWITCH_PREFIX
)
||
line
.
toLowerCase
().
startsWith
(
NETWORK_F5_PREFIX
))
{
networkMonitor
=
true
;
}
else
if
(
line
.
toLowerCase
().
startsWith
(
SYSTEM_MONITOR_PREFIX
))
{
systemMonitor
=
true
;
}
productLine
.
setNetworkDashboard
(
networkMonitor
);
productLine
.
setUserMonitorDashboard
(
userMonitor
);
productLine
.
setSystemMonitorDashboard
(
systemMonitor
);
}
public
boolean
insertIfNotExsit
(
String
line
,
String
domain
)
{
Company
company
=
getCompany
();
if
(
company
!=
null
)
{
...
...
@@ -128,11 +156,9 @@ public class ProductLineConfigManager implements Initializable, LogEnabled {
productLine
=
new
ProductLine
();
productLine
.
setId
(
line
);
productLine
.
setTitle
(
line
);
buildDefaultDashboard
(
productLine
,
domain
);
productLine
.
addDomain
(
new
Domain
(
domain
));
productLine
.
setNetworkDashboard
(
networkMonitor
);
productLine
.
setUserMonitorDashboard
(
userMonitor
);
productLine
.
setMetricDashboard
(
false
);
company
.
addProductLine
(
productLine
);
return
storeConfig
();
}
else
{
...
...
@@ -146,9 +172,8 @@ public class ProductLineConfigManager implements Initializable, LogEnabled {
return
storeConfig
();
}
}
}
else
{
return
false
;
}
return
false
;
}
public
boolean
insertProductLine
(
ProductLine
line
,
String
[]
domains
)
{
...
...
@@ -219,9 +244,10 @@ public class ProductLineConfigManager implements Initializable, LogEnabled {
Map
<
String
,
List
<
ProductLine
>>
productLines
=
new
LinkedHashMap
<
String
,
List
<
ProductLine
>>();
productLines
.
put
(
METRIC_MONITOR
,
new
ArrayList
<
ProductLine
>());
productLines
.
put
(
NETWORK_MONITOR
,
new
ArrayList
<
ProductLine
>());
productLines
.
put
(
USER_MONITOR
,
new
ArrayList
<
ProductLine
>());
productLines
.
put
(
ERROR_MONITOR
,
new
ArrayList
<
ProductLine
>());
productLines
.
put
(
APPLICATION_MONITOR
,
new
ArrayList
<
ProductLine
>());
productLines
.
put
(
NETWORK_MONITOR
,
new
ArrayList
<
ProductLine
>());
productLines
.
put
(
SYSTEM_MONITOR
,
new
ArrayList
<
ProductLine
>());
for
(
ProductLine
line
:
getCompany
().
getProductLines
().
values
())
{
String
id
=
line
.
getId
();
...
...
@@ -236,8 +262,12 @@ public class ProductLineConfigManager implements Initializable, LogEnabled {
if
(
line
.
getUserMonitorDashboard
())
{
productLines
.
get
(
USER_MONITOR
).
add
(
line
);
}
if
(
line
.
getDashboard
())
{
productLines
.
get
(
ERROR_MONITOR
).
add
(
line
);
if
(
line
.
getDashboard
()
||
line
.
getApplicationDashboard
())
{
line
.
setApplicationDashboard
(
true
);
productLines
.
get
(
APPLICATION_MONITOR
).
add
(
line
);
}
if
(
line
.
getSystemMonitorDashboard
())
{
productLines
.
get
(
SYSTEM_MONITOR
).
add
(
line
);
}
}
}
...
...
cat-consumer-advanced/src/main/resources/META-INF/dal/model/metric-report-model.xml
浏览文件 @
c7ea21a4
...
...
@@ -7,6 +7,7 @@
<attribute
name=
"startTime"
value-type=
"Date"
format=
"yyyy-MM-dd HH:mm:ss"
/>
<attribute
name=
"endTime"
value-type=
"Date"
format=
"yyyy-MM-dd HH:mm:ss"
/>
<entity-ref
name=
"metric-item"
type=
"map"
names=
"metric-items"
method-find-or-create=
"true"
/>
<entity-ref
name=
"statistic"
type=
"map"
names=
"statistics"
method-find-or-create=
"true"
/>
</entity>
<entity
name=
"metric-item"
>
<attribute
name=
"id"
value-type=
"String"
key=
"true"
/>
...
...
@@ -35,4 +36,12 @@
<attribute
name=
"sum"
value-type=
"double"
primitive=
"true"
/>
<attribute
name=
"avg"
value-type=
"double"
primitive=
"true"
/>
</entity>
<entity
name=
"statistic"
>
<attribute
name=
"id"
value-type=
"String"
key=
"true"
/>
<entity-ref
name=
"statistics-item"
type=
"map"
names=
"statistics-items"
method-find-or-create=
"true"
/>
</entity>
<entity
name=
"statistics-item"
>
<attribute
name=
"id"
value-type=
"String"
key=
"true"
/>
<attribute
name=
"count"
value-type=
"int"
primitive=
"true"
/>
</entity>
</model>
\ No newline at end of file
cat-consumer-advanced/src/main/resources/META-INF/plexus/components.xml
浏览文件 @
c7ea21a4
...
...
@@ -162,8 +162,8 @@
</requirements>
</component>
<component>
<role>
com.dianping.cat.consumer.metric.
Metric
ConfigManager
</role>
<implementation>
com.dianping.cat.consumer.metric.
Metric
ConfigManager
</implementation>
<role>
com.dianping.cat.consumer.metric.
ProductLine
ConfigManager
</role>
<implementation>
com.dianping.cat.consumer.metric.
ProductLine
ConfigManager
</implementation>
<requirements>
<requirement>
<role>
com.dianping.cat.core.config.ConfigDao
</role>
...
...
@@ -171,12 +171,15 @@
</requirements>
</component>
<component>
<role>
com.dianping.cat.consumer.metric.
ProductLine
ConfigManager
</role>
<implementation>
com.dianping.cat.consumer.metric.
ProductLine
ConfigManager
</implementation>
<role>
com.dianping.cat.consumer.metric.
Metric
ConfigManager
</role>
<implementation>
com.dianping.cat.consumer.metric.
Metric
ConfigManager
</implementation>
<requirements>
<requirement>
<role>
com.dianping.cat.core.config.ConfigDao
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.consumer.metric.ProductLineConfigManager
</role>
</requirement>
</requirements>
</component>
<component>
...
...
cat-consumer-advanced/src/test/resources/com/dianping/cat/consumer/metric/metric_analyzer.xml
浏览文件 @
c7ea21a4
<?xml version="1.0" encoding="utf-8"?>
<metric-report
product=
"group"
startTime=
"2012-01-01 00:00:00"
endTime=
"2012-01-01 00:59:59"
>
<metric-item
id=
"group:PigeonService:TuanGouWeb"
type=
"C"
>
<domain>
group
</domain>
<segment
id=
"1"
count=
"1"
sum=
"2000.0"
avg=
"2000.0"
/>
<segment
id=
"4"
count=
"1"
sum=
"8000.0"
avg=
"8000.0"
/>
<segment
id=
"7"
count=
"1"
sum=
"14000.0"
avg=
"14000.0"
/>
<segment
id=
"10"
count=
"1"
sum=
"20000.0"
avg=
"20000.0"
/>
<segment
id=
"13"
count=
"1"
sum=
"26000.0"
avg=
"26000.0"
/>
<segment
id=
"16"
count=
"1"
sum=
"32000.0"
avg=
"32000.0"
/>
<segment
id=
"19"
count=
"1"
sum=
"38000.0"
avg=
"38000.0"
/>
<segment
id=
"22"
count=
"1"
sum=
"44000.0"
avg=
"44000.0"
/>
<segment
id=
"25"
count=
"1"
sum=
"50000.0"
avg=
"50000.0"
/>
<segment
id=
"28"
count=
"1"
sum=
"56000.0"
avg=
"56000.0"
/>
<segment
id=
"31"
count=
"1"
sum=
"62000.0"
avg=
"62000.0"
/>
<segment
id=
"34"
count=
"1"
sum=
"68000.0"
avg=
"68000.0"
/>
<segment
id=
"37"
count=
"1"
sum=
"74000.0"
avg=
"74000.0"
/>
<segment
id=
"40"
count=
"1"
sum=
"80000.0"
avg=
"80000.0"
/>
<segment
id=
"43"
count=
"1"
sum=
"86000.0"
avg=
"86000.0"
/>
<segment
id=
"46"
count=
"1"
sum=
"92000.0"
avg=
"92000.0"
/>
<segment
id=
"49"
count=
"1"
sum=
"98000.0"
avg=
"98000.0"
/>
<segment
id=
"52"
count=
"1"
sum=
"104000.0"
avg=
"104000.0"
/>
<segment
id=
"55"
count=
"1"
sum=
"110000.0"
avg=
"110000.0"
/>
<segment
id=
"58"
count=
"1"
sum=
"116000.0"
avg=
"116000.0"
/>
</metric-item>
<metric-item
id=
"group:Metric:/nanjing"
type=
"S,C"
>
<domain>
group
</domain>
<segment
id=
"1"
count=
"10"
sum=
"10.0"
avg=
"1.0"
/>
...
...
@@ -92,29 +69,6 @@
<segment
id=
"56"
count=
"1"
sum=
"10.0"
avg=
"10.0"
/>
<segment
id=
"59"
count=
"1"
sum=
"10.0"
avg=
"10.0"
/>
</metric-item>
<metric-item
id=
"group:URL:TuanGouWeb"
type=
"C"
>
<domain>
group
</domain>
<segment
id=
"3"
count=
"1"
sum=
"6000.0"
avg=
"6000.0"
/>
<segment
id=
"6"
count=
"1"
sum=
"12000.0"
avg=
"12000.0"
/>
<segment
id=
"9"
count=
"1"
sum=
"18000.0"
avg=
"18000.0"
/>
<segment
id=
"12"
count=
"1"
sum=
"24000.0"
avg=
"24000.0"
/>
<segment
id=
"15"
count=
"1"
sum=
"30000.0"
avg=
"30000.0"
/>
<segment
id=
"18"
count=
"1"
sum=
"36000.0"
avg=
"36000.0"
/>
<segment
id=
"21"
count=
"1"
sum=
"42000.0"
avg=
"42000.0"
/>
<segment
id=
"24"
count=
"1"
sum=
"48000.0"
avg=
"48000.0"
/>
<segment
id=
"27"
count=
"1"
sum=
"54000.0"
avg=
"54000.0"
/>
<segment
id=
"30"
count=
"1"
sum=
"60000.0"
avg=
"60000.0"
/>
<segment
id=
"33"
count=
"1"
sum=
"66000.0"
avg=
"66000.0"
/>
<segment
id=
"36"
count=
"1"
sum=
"72000.0"
avg=
"72000.0"
/>
<segment
id=
"39"
count=
"1"
sum=
"78000.0"
avg=
"78000.0"
/>
<segment
id=
"42"
count=
"1"
sum=
"84000.0"
avg=
"84000.0"
/>
<segment
id=
"45"
count=
"1"
sum=
"90000.0"
avg=
"90000.0"
/>
<segment
id=
"48"
count=
"1"
sum=
"96000.0"
avg=
"96000.0"
/>
<segment
id=
"51"
count=
"1"
sum=
"102000.0"
avg=
"102000.0"
/>
<segment
id=
"54"
count=
"1"
sum=
"108000.0"
avg=
"108000.0"
/>
<segment
id=
"57"
count=
"1"
sum=
"114000.0"
avg=
"114000.0"
/>
<segment
id=
"0"
count=
"1"
sum=
"120000.0"
avg=
"120000.0"
/>
</metric-item>
<metric-item
id=
"group:Metric:/beijing"
type=
"S"
>
<domain>
group
</domain>
<segment
id=
"3"
count=
"1"
sum=
"10.0"
avg=
"10.0"
/>
...
...
cat-consumer/src/main/java/com/dianping/cat/consumer/heartbeat/HeartbeatAnalyzer.java
浏览文件 @
c7ea21a4
...
...
@@ -57,7 +57,8 @@ public class HeartbeatAnalyzer extends AbstractMessageAnalyzer<HeartbeatReport>
try
{
info
=
com
.
dianping
.
cat
.
status
.
model
.
transform
.
DefaultSaxParser
.
parse
(
xml
);
}
catch
(
Exception
e
)
{
Cat
.
getProducer
().
logEvent
(
"HearbeatAnalyzer"
,
"ErrorXml"
,
"Error"
,
xml
);
m_logger
.
error
(
xml
);
m_logger
.
error
(
e
.
getMessage
(),
e
);
return
null
;
}
...
...
cat-consumer/src/main/resources/META-INF/dal/model/company-model.xml
浏览文件 @
c7ea21a4
...
...
@@ -14,7 +14,9 @@
<attribute
name=
"order"
value-type=
"double"
primitive=
"true"
/>
<attribute
name=
"dashboard"
value-type=
"boolean"
primitive=
"true"
/>
<attribute
name=
"metric-dashboard"
value-type=
"boolean"
primitive=
"true"
default-value=
"true"
/>
<attribute
name=
"application-dashboard"
value-type=
"boolean"
primitive=
"true"
default-value=
"false"
/>
<attribute
name=
"network-dashboard"
value-type=
"boolean"
primitive=
"true"
default-value=
"false"
/>
<attribute
name=
"system-monitor-dashboard"
value-type=
"boolean"
primitive=
"true"
default-value=
"false"
/>
<attribute
name=
"user-monitor-dashboard"
value-type=
"boolean"
primitive=
"true"
default-value=
"false"
/>
<entity-ref
name=
"domain"
type=
"map"
names=
"domains"
method-find-or-create=
"true"
/>
</entity>
...
...
cat-core/src/main/java/com/dianping/cat/Constants.java
浏览文件 @
c7ea21a4
...
...
@@ -22,9 +22,11 @@ public class Constants {
public
static
final
String
REPORT_UTILIZATION
=
"utilization"
;
public
static
final
String
REPORT_HEAVY
=
"heavy"
;
public
static
final
String
REPORT_NET_TOPOLOGY
=
"NetTopology"
;
public
static
final
String
REPORT_ALERT
=
"alert"
;
public
static
final
String
BROKER_SERVICE
=
"broker-service"
;
}
cat-core/src/main/java/com/dianping/cat/Monitor.java
浏览文件 @
c7ea21a4
...
...
@@ -4,6 +4,8 @@ public class Monitor {
public
static
final
String
HIT
=
"hit"
;
public
static
final
String
AVG
=
"avg"
;
public
static
final
String
ERROR
=
"error"
;
public
static
final
String
HTTP_STATUS
=
"httpStatus"
;
...
...
@@ -12,4 +14,12 @@ public class Monitor {
public
static
final
String
TYPE_INFO
=
"info"
;
public
static
final
String
CHANNEL
=
"按运营商"
;
public
static
final
String
CITY
=
"按城市"
;
public
static
final
String
HIT_COUNT
=
"访问量分布"
;
public
static
final
String
ERROR_COUNT
=
"错误量分布"
;
}
cat-hadoop/src/main/java/com/dianping/cat/hadoop/hdfs/UploaderAndCleaner.java
浏览文件 @
c7ea21a4
...
...
@@ -281,7 +281,7 @@ public class UploaderAndCleaner implements Initializable, Task, LogEnabled {
}
try
{
Thread
.
sleep
(
5
00
);
Thread
.
sleep
(
1
00
);
}
catch
(
InterruptedException
e
)
{
break
;
}
...
...
cat-home/pom.xml
浏览文件 @
c7ea21a4
...
...
@@ -165,6 +165,7 @@
${basedir}/src/main/resources/META-INF/dal/model/netgraph-manifest.xml,
${basedir}/src/main/resources/META-INF/dal/model/alert-report-manifest.xml,
${basedir}/src/main/resources/META-INF/dal/model/monitor-rules-manifest.xml,
${basedir}/src/main/resources/META-INF/dal/model/exception-exclude-config-manifest.xml,
</manifest>
</configuration>
</execution>
...
...
cat-home/src/main/java/com/dianping/cat/build/ComponentsConfigurator.java
浏览文件 @
c7ea21a4
...
...
@@ -26,7 +26,7 @@ import com.dianping.cat.report.baseline.BaselineService;
import
com.dianping.cat.report.chart.AggregationGraphCreator
;
import
com.dianping.cat.report.chart.CachedMetricReportService
;
import
com.dianping.cat.report.chart.DataExtractor
;
import
com.dianping.cat.report.chart.
DefaultAgg
GraphCreator
;
import
com.dianping.cat.report.chart.
Network
GraphCreator
;
import
com.dianping.cat.report.chart.GraphCreator
;
import
com.dianping.cat.report.chart.MetricDataFetcher
;
import
com.dianping.cat.report.chart.impl.CachedMetricReportServiceImpl
;
...
...
@@ -60,6 +60,7 @@ import com.dianping.cat.report.view.DomainNavManager;
import
com.dianping.cat.system.config.BugConfigManager
;
import
com.dianping.cat.system.config.ConfigReloadTask
;
import
com.dianping.cat.system.config.DomainGroupConfigManager
;
import
com.dianping.cat.system.config.ExceptionExcludeConfigManager
;
import
com.dianping.cat.system.config.ExceptionThresholdConfigManager
;
import
com.dianping.cat.system.config.MetricAggregationConfigManager
;
import
com.dianping.cat.system.config.MetricGroupConfigManager
;
...
...
@@ -99,6 +100,8 @@ public class ComponentsConfigurator extends AbstractResourceConfigurator {
all
.
add
(
C
(
ExceptionThresholdConfigManager
.
class
).
req
(
ConfigDao
.
class
));
all
.
add
(
C
(
ExceptionExcludeConfigManager
.
class
).
req
(
ConfigDao
.
class
));
all
.
add
(
C
(
DomainGroupConfigManager
.
class
).
req
(
ConfigDao
.
class
));
all
.
add
(
C
(
BugConfigManager
.
class
).
req
(
ConfigDao
.
class
));
...
...
@@ -128,6 +131,8 @@ public class ComponentsConfigurator extends AbstractResourceConfigurator {
all
.
add
(
C
(
MetricDataFetcher
.
class
,
MetricDataFetcherImpl
.
class
));
all
.
add
(
C
(
AlertInfo
.
class
).
req
(
MetricConfigManager
.
class
));
all
.
add
(
C
(
GraphCreator
.
class
).
req
(
CachedMetricReportService
.
class
,
DataExtractor
.
class
,
MetricDataFetcher
.
class
)
.
req
(
BaselineService
.
class
,
MetricConfigManager
.
class
,
ProductLineConfigManager
.
class
,
MetricGroupConfigManager
.
class
,
AlertInfo
.
class
));
...
...
@@ -140,7 +145,7 @@ public class ComponentsConfigurator extends AbstractResourceConfigurator {
DataExtractor
.
class
,
MetricDataFetcher
.
class
).
req
(
BaselineService
.
class
,
MetricConfigManager
.
class
,
ProductLineConfigManager
.
class
,
MetricGroupConfigManager
.
class
,
AlertInfo
.
class
));
all
.
add
(
C
(
DefaultAgg
GraphCreator
.
class
).
req
(
CachedMetricReportService
.
class
,
DataExtractor
.
class
,
all
.
add
(
C
(
Network
GraphCreator
.
class
).
req
(
CachedMetricReportService
.
class
,
DataExtractor
.
class
,
MetricDataFetcher
.
class
).
req
(
BaselineService
.
class
,
MetricConfigManager
.
class
,
ProductLineConfigManager
.
class
,
MetricGroupConfigManager
.
class
,
AlertInfo
.
class
));
// report serivce
...
...
@@ -170,7 +175,8 @@ public class ComponentsConfigurator extends AbstractResourceConfigurator {
.
req
(
RemoteMetricReportService
.
class
,
MetricRuleConfigManager
.
class
));
all
.
add
(
C
(
ExceptionAlert
.
class
).
req
(
ProjectDao
.
class
,
MetricAlertConfig
.
class
,
MailSMS
.
class
,
ExceptionThresholdConfigManager
.
class
).
req
(
ModelService
.
class
,
TopAnalyzer
.
ID
));
ExceptionThresholdConfigManager
.
class
,
ExceptionExcludeConfigManager
.
class
).
req
(
ModelService
.
class
,
TopAnalyzer
.
ID
));
// database
all
.
add
(
C
(
JdbcDataSourceDescriptorManager
.
class
)
//
...
...
cat-home/src/main/java/com/dianping/cat/build/ServiceComponentConfigurator.java
浏览文件 @
c7ea21a4
...
...
@@ -168,7 +168,7 @@ class ServiceComponentConfigurator extends AbstractResourceConfigurator {
.
req
(
MessageBucketManager
.
class
,
HdfsMessageBucketManager
.
ID
,
"m_hdfsBucketManager"
)
//
.
req
(
MessageCodec
.
class
,
"html"
));
all
.
add
(
C
(
CachedReportTask
.
class
).
req
(
ReportService
.
class
));
all
.
add
(
C
(
CachedReportTask
.
class
).
req
(
ReportService
.
class
,
ServerConfigManager
.
class
));
return
all
;
}
}
cat-home/src/main/java/com/dianping/cat/build/TaskComponentConfigurator.java
浏览文件 @
c7ea21a4
...
...
@@ -15,6 +15,7 @@ import com.dianping.cat.core.dal.GraphDao;
import
com.dianping.cat.core.dal.TaskDao
;
import
com.dianping.cat.home.dal.report.BaselineDao
;
import
com.dianping.cat.home.dal.report.TopologyGraphDao
;
import
com.dianping.cat.home.dependency.exceptionExclude.entity.ExceptionExcludeConfig
;
import
com.dianping.cat.report.baseline.BaselineConfigManager
;
import
com.dianping.cat.report.baseline.BaselineCreator
;
import
com.dianping.cat.report.baseline.BaselineService
;
...
...
@@ -51,6 +52,7 @@ import com.dianping.cat.report.task.transaction.TransactionGraphCreator;
import
com.dianping.cat.report.task.transaction.TransactionMerger
;
import
com.dianping.cat.report.task.transaction.TransactionReportBuilder
;
import
com.dianping.cat.report.task.utilization.UtilizationReportBuilder
;
import
com.dianping.cat.system.config.ExceptionExcludeConfigManager
;
import
com.dianping.cat.system.config.ExceptionThresholdConfigManager
;
public
class
TaskComponentConfigurator
extends
AbstractResourceConfigurator
{
...
...
@@ -105,7 +107,8 @@ public class TaskComponentConfigurator extends AbstractResourceConfigurator {
all
.
add
(
C
(
StateReportBuilder
.
class
).
req
(
ReportService
.
class
));
all
.
add
(
C
(
AlertReportBuilder
.
class
).
req
(
ReportService
.
class
,
ExceptionThresholdConfigManager
.
class
));
all
.
add
(
C
(
AlertReportBuilder
.
class
).
req
(
ReportService
.
class
,
ExceptionThresholdConfigManager
.
class
,
ExceptionExcludeConfigManager
.
class
));
all
.
add
(
C
(
HeavyReportBuilder
.
class
).
req
(
ReportService
.
class
));
...
...
cat-home/src/main/java/com/dianping/cat/report/chart/AggregationGraphCreator.java
浏览文件 @
c7ea21a4
...
...
@@ -33,7 +33,6 @@ public class AggregationGraphCreator extends BaseGraphCreator {
private
Map
<
String
,
LineChart
>
buildChartData
(
final
Map
<
String
,
double
[]>
datas
,
Date
startDate
,
Date
endDate
,
final
Map
<
String
,
double
[]>
dataWithOutFutures
)
{
MetricAggregationGroup
metricAggregationGroup
=
m_metricAggregationConfigManager
.
getMetricAggregationConfig
()
.
findMetricAggregationGroup
(
m_aggregationGroup
);
List
<
MetricAggregation
>
metricAggregations
=
metricAggregationGroup
.
getMetricAggregations
();
...
...
@@ -48,7 +47,6 @@ public class AggregationGraphCreator extends BaseGraphCreator {
}
public
void
rebuildData
(
Map
<
Long
,
Double
>
data
,
String
operation
)
{
String
op
=
null
;
for
(
Entry
<
Long
,
Double
>
entry
:
data
.
entrySet
())
{
...
...
@@ -63,10 +61,9 @@ public class AggregationGraphCreator extends BaseGraphCreator {
private
Pair
<
String
,
LineChart
>
buildAggerationChart
(
final
Map
<
String
,
double
[]>
datas
,
Date
startDate
,
Date
endDate
,
final
Map
<
String
,
double
[]>
dataWithOutFutures
,
MetricAggregation
metricAggregation
)
{
MetricAggregationGroup
metricAggregationGroup
=
m_metricAggregationConfigManager
.
getMetricAggregationConfig
()
.
findMetricAggregationGroup
(
m_aggregationGroup
);
List
<
MetricItemConfig
>
alertItems
=
m_alertInfo
.
getLastestAlarm
(
5
);
List
<
MetricItemConfig
>
alertItems
=
m_alertInfo
.
queryLastestAlarmInfo
(
5
);
String
type
=
metricAggregationGroup
.
getType
();
int
step
=
m_dataExtractor
.
getStep
();
String
id
=
metricAggregation
.
getId
();
...
...
@@ -80,7 +77,6 @@ public class AggregationGraphCreator extends BaseGraphCreator {
lineChart
.
setStep
(
step
*
TimeUtil
.
ONE_MINUTE
);
for
(
MetricAggregationItem
metricAggregationItem
:
metricAggregation
.
getMetricAggregationItems
())
{
String
domain
=
getAttribute
(
metricAggregation
.
getDomain
(),
metricAggregationItem
.
getDomain
());
String
displayType
=
getAttribute
(
metricAggregation
.
getDisplayType
(),
metricAggregationItem
.
getDisplayType
());
boolean
baseLine
=
getAttribute
(
metricAggregation
.
getBaseLine
(),
metricAggregationItem
.
getBaseLine
());
...
...
@@ -88,7 +84,7 @@ public class AggregationGraphCreator extends BaseGraphCreator {
String
itemKey
=
domain
+
":"
+
type
+
":"
+
metricAggregationItem
.
getKey
()
+
":"
+
displayType
.
toUpperCase
();
if
(
dataWithOutFutures
.
containsKey
(
itemKey
))
{
buildLineChartTitle
(
alertItems
,
lineChart
,
itemKey
,
title
);
buildLineChartTitle
(
alertItems
,
lineChart
,
itemKey
);
Map
<
Long
,
Double
>
all
=
convertToMap
(
datas
.
get
(
itemKey
),
startDate
,
1
);
Map
<
Long
,
Double
>
current
=
convertToMap
(
dataWithOutFutures
.
get
(
itemKey
),
startDate
,
step
);
...
...
@@ -131,6 +127,7 @@ public class AggregationGraphCreator extends BaseGraphCreator {
protected
boolean
isProductLineInGroup
(
String
productLine
,
List
<
MetricAggregation
>
metricAggregations
)
{
List
<
String
>
domains
=
m_productLineConfigManager
.
queryDomainsByProductLine
(
productLine
);
List
<
MetricItemConfig
>
metricConfigs
=
m_metricConfigManager
.
queryMetricItemConfigs
(
domains
);
for
(
MetricItemConfig
metricConfig
:
metricConfigs
){
String
domain
=
metricConfig
.
getDomain
();
String
type
=
metricConfig
.
getType
();
...
...
@@ -153,6 +150,7 @@ public class AggregationGraphCreator extends BaseGraphCreator {
public
Map
<
String
,
LineChart
>
buildDashboardByGroup
(
Date
start
,
Date
end
,
String
metricGroup
)
{
m_aggregationGroup
=
metricGroup
;
Map
<
String
,
LineChart
>
result
=
new
LinkedHashMap
<
String
,
LineChart
>();
MetricAggregationGroup
metricAggregationGroup
=
m_metricAggregationConfigManager
.
getMetricAggregationConfig
()
.
findMetricAggregationGroup
(
metricGroup
);
...
...
@@ -185,7 +183,6 @@ public class AggregationGraphCreator extends BaseGraphCreator {
}
protected
Map
<
String
,
double
[]>
buildGraphData
(
MetricReport
metricReport
,
List
<
MetricItemConfig
>
metricConfigs
)
{
Map
<
String
,
double
[]>
datas
=
m_pruductDataFetcher
.
buildGraphData
(
metricReport
,
metricConfigs
);
Map
<
String
,
double
[]>
values
=
new
LinkedHashMap
<
String
,
double
[]>();
...
...
cat-home/src/main/java/com/dianping/cat/report/chart/BaseGraphCreator.java
浏览文件 @
c7ea21a4
...
...
@@ -62,8 +62,10 @@ public abstract class BaseGraphCreator implements LogEnabled {
protected
void
addLastMinuteData
(
Map
<
Long
,
Double
>
current
,
Map
<
Long
,
Double
>
all
,
int
minute
,
Date
end
)
{
int
step
=
m_dataExtractor
.
getStep
();
if
(
step
==
1
)
if
(
step
==
1
)
{
return
;
}
long
endTime
=
0
;
long
currentTime
=
System
.
currentTimeMillis
();
if
(
end
.
getTime
()
>
currentTime
)
{
...
...
@@ -93,23 +95,15 @@ public abstract class BaseGraphCreator implements LogEnabled {
}
}
protected
abstract
Map
<
String
,
double
[]>
buildGraphData
(
MetricReport
metricReport
,
List
<
MetricItemConfig
>
metricConfigs
);
protected
void
buildLineChartTitle
(
List
<
MetricItemConfig
>
alertItems
,
LineChart
chart
,
String
key
)
{
int
index
=
key
.
lastIndexOf
(
":"
);
String
i
d
=
key
.
substring
(
0
,
index
);
String
metricI
d
=
key
.
substring
(
0
,
index
);
String
type
=
key
.
substring
(
index
+
1
);
MetricItemConfig
config
=
m_metricConfigManager
.
queryMetricItemConfig
(
id
);
String
metricId
=
m_metricConfigManager
.
buildMetricKey
(
config
.
getDomain
(),
config
.
getType
(),
config
.
getMetricKey
());
String
des
=
""
;
config
.
setId
(
metricId
);
if
(
MetricType
.
AVG
.
name
().
equals
(
type
))
{
des
=
Chinese
.
Suffix_AVG
;
}
else
if
(
MetricType
.
SUM
.
name
().
equals
(
type
))
{
des
=
Chinese
.
Suffix_SUM
;
}
else
if
(
MetricType
.
COUNT
.
name
().
equals
(
type
))
{
des
=
Chinese
.
Suffix_COUNT
;
}
MetricItemConfig
config
=
m_metricConfigManager
.
queryMetricItemConfig
(
metricId
);
String
des
=
queryMetricItemDes
(
type
);
String
title
=
config
.
getTitle
()
+
des
;
chart
.
setTitle
(
title
);
...
...
@@ -122,25 +116,6 @@ public abstract class BaseGraphCreator implements LogEnabled {
}
}
public
void
buildLineChartTitle
(
List
<
MetricItemConfig
>
alertItems
,
LineChart
chart
,
String
key
,
String
title
)
{
if
(
chart
.
getHtmlTitle
().
contains
(
"<span style='color:red'>"
))
{
return
;
}
int
index
=
key
.
lastIndexOf
(
":"
);
String
id
=
key
.
substring
(
0
,
index
);
MetricItemConfig
config
=
m_metricConfigManager
.
queryMetricItemConfig
(
id
);
String
metricId
=
m_metricConfigManager
.
buildMetricKey
(
config
.
getDomain
(),
config
.
getType
(),
config
.
getMetricKey
());
config
.
setId
(
metricId
);
if
(
alertItems
.
contains
(
config
))
{
chart
.
setHtmlTitle
(
"<span style='color:red'>"
+
title
+
"</span>"
);
}
else
{
chart
.
setHtmlTitle
(
title
);
}
}
protected
double
[]
convert
(
double
[]
value
,
int
removeLength
)
{
int
length
=
value
.
length
;
int
newLength
=
length
-
removeLength
;
...
...
@@ -202,13 +177,30 @@ public abstract class BaseGraphCreator implements LogEnabled {
for
(;
start
<
end
;
start
+=
TimeUtil
.
ONE_HOUR
)
{
Map
<
String
,
double
[]>
currentValues
=
queryMetricValueByDate
(
productLine
,
start
);
mergeMap
(
oldCurrentValues
,
currentValues
,
totalSize
,
index
);
index
++;
}
return
oldCurrentValues
;
}
protected
void
put
(
Map
<
String
,
LineChart
>
charts
,
Map
<
String
,
LineChart
>
result
,
String
key
)
{
LineChart
value
=
charts
.
get
(
key
);
if
(
value
!=
null
)
{
result
.
put
(
key
,
charts
.
get
(
key
));
}
}
protected
void
putKey
(
Map
<
String
,
double
[]>
datas
,
Map
<
String
,
double
[]>
values
,
String
key
)
{
double
[]
value
=
datas
.
get
(
key
);
if
(
value
==
null
)
{
value
=
new
double
[
60
];
}
values
.
put
(
key
,
value
);
}
protected
double
[]
queryBaseline
(
String
key
,
Date
start
,
Date
end
)
{
int
size
=
(
int
)
((
end
.
getTime
()
-
start
.
getTime
())
/
TimeUtil
.
ONE_MINUTE
);
double
[]
result
=
new
double
[
size
];
...
...
@@ -227,14 +219,24 @@ public abstract class BaseGraphCreator implements LogEnabled {
return
result
;
}
protected
abstract
Map
<
String
,
double
[]>
buildGraphData
(
MetricReport
metricReport
,
List
<
MetricItemConfig
>
metricConfigs
);
private
String
queryMetricItemDes
(
String
type
)
{
String
des
=
""
;
if
(
MetricType
.
AVG
.
name
().
equals
(
type
))
{
des
=
Chinese
.
Suffix_AVG
;
}
else
if
(
MetricType
.
SUM
.
name
().
equals
(
type
))
{
des
=
Chinese
.
Suffix_SUM
;
}
else
if
(
MetricType
.
COUNT
.
name
().
equals
(
type
))
{
des
=
Chinese
.
Suffix_COUNT
;
}
return
des
;
}
private
Map
<
String
,
double
[]>
queryMetricValueByDate
(
String
productLine
,
long
start
)
{
MetricReport
metricReport
=
m_metricReportService
.
queryMetricReport
(
productLine
,
new
Date
(
start
));
List
<
String
>
domains
=
m_productLineConfigManager
.
queryDomainsByProductLine
(
productLine
);
List
<
MetricItemConfig
>
metricConfigs
=
m_metricConfigManager
.
queryMetricItemConfigs
(
domains
);
Collections
.
sort
(
metricConfigs
,
new
Comparator
<
MetricItemConfig
>()
{
@Override
public
int
compare
(
MetricItemConfig
o1
,
MetricItemConfig
o2
)
{
...
...
@@ -254,7 +256,8 @@ public abstract class BaseGraphCreator implements LogEnabled {
}
// if current report is not exist, use last day value replace it.
if
(
sum
<=
0
&&
start
<
TimeUtil
.
getCurrentHour
().
getTime
())
{
MetricReport
lastMetricReport
=
m_metricReportService
.
queryMetricReport
(
productLine
,
new
Date
(
start
-
TimeUtil
.
ONE_DAY
));
MetricReport
lastMetricReport
=
m_metricReportService
.
queryMetricReport
(
productLine
,
new
Date
(
start
-
TimeUtil
.
ONE_DAY
));
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:ss"
);
m_logger
.
error
(
"Replace error value, Metric report is not exsit, productLine:"
+
productLine
+
" ,date:"
...
...
@@ -269,8 +272,8 @@ public abstract class BaseGraphCreator implements LogEnabled {
// remove the minute of future
Map
<
String
,
double
[]>
newCurrentValues
=
new
LinkedHashMap
<
String
,
double
[]>();
int
step
=
m_dataExtractor
.
getStep
();
if
(
step
<=
0
){
if
(
step
<=
0
)
{
return
allCurrentValues
;
}
int
minute
=
Calendar
.
getInstance
().
get
(
Calendar
.
MINUTE
);
...
...
@@ -286,21 +289,4 @@ public abstract class BaseGraphCreator implements LogEnabled {
}
return
allCurrentValues
;
}
protected
void
putKey
(
Map
<
String
,
double
[]>
datas
,
Map
<
String
,
double
[]>
values
,
String
key
)
{
double
[]
value
=
datas
.
get
(
key
);
if
(
value
==
null
)
{
value
=
new
double
[
60
];
}
values
.
put
(
key
,
value
);
}
protected
void
put
(
Map
<
String
,
LineChart
>
charts
,
Map
<
String
,
LineChart
>
result
,
String
key
)
{
LineChart
value
=
charts
.
get
(
key
);
if
(
value
!=
null
)
{
result
.
put
(
key
,
charts
.
get
(
key
));
}
}
}
cat-home/src/main/java/com/dianping/cat/report/chart/GraphCreator.java
浏览文件 @
c7ea21a4
...
...
@@ -24,7 +24,7 @@ public class GraphCreator extends BaseGraphCreator{
public
Map
<
String
,
LineChart
>
buildChartData
(
final
Map
<
String
,
double
[]>
datas
,
Date
startDate
,
Date
endDate
,
final
Map
<
String
,
double
[]>
dataWithOutFutures
)
{
Map
<
String
,
LineChart
>
charts
=
new
LinkedHashMap
<
String
,
LineChart
>();
List
<
MetricItemConfig
>
alertItems
=
m_alertInfo
.
getLastestAlarm
(
5
);
List
<
MetricItemConfig
>
alertItems
=
m_alertInfo
.
queryLastestAlarmInfo
(
5
);
int
step
=
m_dataExtractor
.
getStep
();
for
(
Entry
<
String
,
double
[]>
entry
:
dataWithOutFutures
.
entrySet
())
{
...
...
cat-home/src/main/java/com/dianping/cat/report/chart/
DefaultAgg
GraphCreator.java
→
cat-home/src/main/java/com/dianping/cat/report/chart/
Network
GraphCreator.java
浏览文件 @
c7ea21a4
...
...
@@ -15,7 +15,7 @@ import com.dianping.cat.helper.TimeUtil;
import
com.dianping.cat.report.page.LineChart
;
import
com.dianping.cat.report.task.metric.MetricType
;
public
class
DefaultAgg
GraphCreator
extends
GraphCreator
{
public
class
Network
GraphCreator
extends
GraphCreator
{
private
static
String
IN_KEY_SUFFIX
=
"-in"
;
...
...
@@ -36,10 +36,9 @@ public class DefaultAggGraphCreator extends GraphCreator {
@Override
public
Map
<
String
,
LineChart
>
buildChartData
(
final
Map
<
String
,
double
[]>
datas
,
Date
startDate
,
Date
endDate
,
final
Map
<
String
,
double
[]>
dataWithOutFutures
)
{
Map
<
String
,
List
<
String
>>
aggregationKeys
=
buildLineChartKeys
(
dataWithOutFutures
.
keySet
());
Map
<
String
,
LineChart
>
charts
=
new
LinkedHashMap
<
String
,
LineChart
>();
List
<
MetricItemConfig
>
alertItems
=
m_alertInfo
.
getLastestAlarm
(
5
);
List
<
MetricItemConfig
>
alertItems
=
m_alertInfo
.
queryLastestAlarmInfo
(
5
);
int
step
=
m_dataExtractor
.
getStep
();
for
(
Entry
<
String
,
List
<
String
>>
keyMapEntry
:
aggregationKeys
.
entrySet
())
{
...
...
@@ -54,7 +53,7 @@ public class DefaultAggGraphCreator extends GraphCreator {
for
(
String
key
:
keyMapEntry
.
getValue
())
{
if
(
dataWithOutFutures
.
containsKey
(
key
))
{
buildLineChartTitle
(
alertItems
,
lineChart
,
key
,
chartTitle
);
buildLineChartTitle
(
alertItems
,
lineChart
,
key
);
double
[]
baselines
=
queryBaseline
(
key
,
startDate
,
endDate
);
Map
<
Long
,
Double
>
all
=
convertToMap
(
datas
.
get
(
key
),
startDate
,
1
);
...
...
cat-home/src/main/java/com/dianping/cat/report/page/PieChart.java
浏览文件 @
c7ea21a4
...
...
@@ -7,24 +7,35 @@ import java.util.List;
public
class
PieChart
{
private
String
m_title
;
private
List
<
Item
>
m_items
=
new
ArrayList
<
Item
>();
private
transient
int
MAX_SIZE
=
10
;
private
transient
int
m_size
=
10
;
public
PieChart
setTitle
(
String
title
)
{
m_title
=
title
;
return
this
;
}
public
String
getTitle
()
{
return
m_title
;
}
public
void
addItems
(
List
<
Item
>
items
)
{
Collections
.
sort
(
items
,
new
ItemCompartor
());
int
size
=
items
.
size
();
if
(
size
<=
MAX_SIZE
)
{
if
(
size
<=
m_size
)
{
m_items
=
items
;
}
else
{
for
(
int
i
=
0
;
i
<
MAX_SIZE
;
i
++)
{
for
(
int
i
=
0
;
i
<
m_size
;
i
++)
{
m_items
.
add
(
items
.
get
(
i
));
}
Item
item
=
new
Item
().
setTitle
(
"Other"
);
double
sum
=
0
;
for
(
int
i
=
MAX_SIZE
;
i
<
size
;
i
++)
{
for
(
int
i
=
m_size
;
i
<
size
;
i
++)
{
Item
temp
=
items
.
get
(
i
);
sum
+=
temp
.
getNumber
();
...
...
@@ -41,6 +52,11 @@ public class PieChart {
return
new
JsonBuilder
().
toJson
(
this
);
}
public
PieChart
setMaxSize
(
int
size
)
{
m_size
=
size
;
return
this
;
}
public
static
class
Item
{
private
String
m_title
;
...
...
cat-home/src/main/java/com/dianping/cat/report/page/dependency/Handler.java
浏览文件 @
c7ea21a4
...
...
@@ -82,7 +82,7 @@ public class Handler implements PageHandler<Context> {
}
private
void
buildDependencyDashboard
(
Model
model
,
Payload
payload
,
Date
reportTime
)
{
ProductLinesDashboard
dashboardGraph
=
m_graphManager
.
buildD
ashboardGraph
(
reportTime
.
getTime
());
ProductLinesDashboard
dashboardGraph
=
m_graphManager
.
buildD
ependencyDashboard
(
reportTime
.
getTime
());
Map
<
String
,
List
<
TopologyNode
>>
dashboardNodes
=
dashboardGraph
.
getNodes
();
for
(
Entry
<
String
,
List
<
TopologyNode
>>
entry
:
dashboardNodes
.
entrySet
())
{
...
...
cat-home/src/main/java/com/dianping/cat/report/page/dependency/graph/TopologyGraphBuilder.java
浏览文件 @
c7ea21a4
...
...
@@ -123,7 +123,7 @@ public class TopologyGraphBuilder extends BaseVisitor {
@Override
public
void
visitDependency
(
Dependency
dependency
)
{
String
type
=
dependency
.
getType
();
// pigeonServer is no use
if
(!
m_pigeonServices
.
contains
(
type
))
{
TopologyEdge
edge
=
m_itemBuilder
.
buildEdge
(
m_domain
,
dependency
);
TopologyGraph
graph
=
findOrCreateGraph
();
...
...
cat-home/src/main/java/com/dianping/cat/report/page/dependency/graph/TopologyGraphManager.java
浏览文件 @
c7ea21a4
...
...
@@ -62,13 +62,13 @@ public class TopologyGraphManager implements Initializable, LogEnabled {
@Inject
private
DomainNavManager
m_domainNavManager
;
private
Map
<
Long
,
TopologyGraph
>
m_topologyGraphs
=
new
ConcurrentHashMap
<
Long
,
TopologyGraph
>(
120
);
private
Map
<
Long
,
TopologyGraph
>
m_topologyGraphs
=
new
ConcurrentHashMap
<
Long
,
TopologyGraph
>();
private
Logger
m_logger
;
private
static
final
String
DEPENDENCY
=
"Dependency"
;
public
ProductLinesDashboard
buildD
ashboardGraph
(
long
time
)
{
public
ProductLinesDashboard
buildD
ependencyDashboard
(
long
time
)
{
TopologyGraph
topologyGraph
=
queryTopologyGraph
(
time
);
ProductLinesDashboard
dashboardGraph
=
new
ProductLinesDashboard
();
Set
<
String
>
allDomains
=
new
HashSet
<
String
>();
...
...
@@ -166,7 +166,7 @@ public class TopologyGraphManager implements Initializable, LogEnabled {
@Override
public
void
initialize
()
throws
InitializationException
{
if
(!
m_manager
.
isLocalMode
()
&&
m_manager
.
isJobMachine
())
{
Threads
.
forGroup
(
"Cat"
).
start
(
new
DependencyReload
());
Threads
.
forGroup
(
"Cat"
).
start
(
new
DependencyReload
Task
());
}
}
...
...
@@ -174,6 +174,7 @@ public class TopologyGraphManager implements Initializable, LogEnabled {
try
{
com
.
dianping
.
cat
.
home
.
dal
.
report
.
TopologyGraph
topologyGraph
=
m_topologyGraphDao
.
findByPeriod
(
new
Date
(
time
),
TopologyGraphEntity
.
READSET_FULL
);
if
(
topologyGraph
!=
null
)
{
byte
[]
content
=
topologyGraph
.
getContent
();
...
...
@@ -210,7 +211,7 @@ public class TopologyGraphManager implements Initializable, LogEnabled {
}
}
private
class
DependencyReload
implements
Task
{
private
class
DependencyReload
Task
implements
Task
{
private
void
buildGraph
(
List
<
DependencyReport
>
reports
)
{
Transaction
t
=
Cat
.
newTransaction
(
DEPENDENCY
,
"BuildGraph"
);
...
...
@@ -224,7 +225,7 @@ public class TopologyGraphManager implements Initializable, LogEnabled {
for
(
Entry
<
Long
,
TopologyGraph
>
entry
:
graphs
.
entrySet
())
{
m_topologyGraphs
.
put
(
entry
.
getKey
(),
entry
.
getValue
());
m_topologyGraphs
.
remove
(
entry
.
getKey
()
-
TimeUtil
.
ONE_HOUR
*
3
);
m_topologyGraphs
.
remove
(
entry
.
getKey
()
-
TimeUtil
.
ONE_HOUR
*
2
);
}
t
.
setStatus
(
Message
.
SUCCESS
);
}
catch
(
Exception
e
)
{
...
...
@@ -286,6 +287,7 @@ public class TopologyGraphManager implements Initializable, LogEnabled {
long
current
=
System
.
currentTimeMillis
();
try
{
Collection
<
String
>
domains
=
queryAllDomains
();
buildGraph
(
fetchReport
(
domains
));
t
.
setStatus
(
Transaction
.
SUCCESS
);
}
catch
(
Exception
e
)
{
...
...
cat-home/src/main/java/com/dianping/cat/report/page/jsError/Handler.java
浏览文件 @
c7ea21a4
...
...
@@ -49,27 +49,29 @@ public class Handler implements PageHandler<Context> {
String
file
=
payload
.
getFile
();
String
host
=
parseHost
();
if
(
file
==
null
||
file
.
length
()
==
0
||
(!
file
.
startsWith
(
"http:"
)))
{
if
(
m_referer
!=
null
)
{
file
=
m_referer
;
}
else
{
file
=
"unknown"
;
if
(
host
.
contains
(
"dianping"
))
{
if
(
file
==
null
||
file
.
length
()
==
0
||
(!
file
.
startsWith
(
"http:"
)))
{
if
(
m_referer
!=
null
)
{
file
=
m_referer
;
}
else
{
file
=
"unknown"
;
}
}
}
int
index
=
file
.
indexOf
(
'?'
);
if
(
index
>
-
1
)
{
file
=
file
.
substring
(
0
,
index
);
}
Cat
.
logEvent
(
"Error"
,
file
,
"Error"
,
error
);
Cat
.
logEvent
(
"Agent"
,
parseValue
(
"Agent"
,
m_data
),
Message
.
SUCCESS
,
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm"
).
format
(
new
Date
(
timestamp
)));
int
index
=
file
.
indexOf
(
'?'
);
if
(
index
>
-
1
)
{
file
=
file
.
substring
(
0
,
index
);
}
Cat
.
logEvent
(
"Error"
,
file
,
"Error"
,
error
);
Cat
.
logEvent
(
"Agent"
,
parseValue
(
"Agent"
,
m_data
),
Message
.
SUCCESS
,
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm"
).
format
(
new
Date
(
timestamp
)));
MessageTree
tree
=
(
MessageTree
)
Cat
.
getManager
().
getThreadLocalMessageTree
();
MessageTree
tree
=
(
MessageTree
)
Cat
.
getManager
().
getThreadLocalMessageTree
();
tree
.
setDomain
(
Constants
.
FRONT_END
);
tree
.
setHostName
(
host
);
tree
.
setIpAddress
(
host
);
tree
.
setDomain
(
Constants
.
FRONT_END
);
tree
.
setHostName
(
host
);
tree
.
setIpAddress
(
host
);
}
model
.
setStatus
(
"SUCCESS"
);
model
.
setAction
(
Action
.
VIEW
);
model
.
setPage
(
ReportPage
.
JSERROR
);
...
...
cat-home/src/main/java/com/dianping/cat/report/page/model/metric/MetricReportMerger.java
浏览文件 @
c7ea21a4
...
...
@@ -6,6 +6,7 @@ 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.Point
;
import
com.dianping.cat.consumer.metric.model.entity.Segment
;
import
com.dianping.cat.consumer.metric.model.entity.StatisticsItem
;
import
com.dianping.cat.consumer.metric.model.transform.DefaultMerger
;
public
class
MetricReportMerger
extends
DefaultMerger
{
...
...
@@ -52,4 +53,10 @@ public class MetricReportMerger extends DefaultMerger {
old
.
setAvg
(
old
.
getSum
()
/
old
.
getCount
());
}
}
@Override
protected
void
mergeStatisticsItem
(
StatisticsItem
to
,
StatisticsItem
from
)
{
to
.
setCount
(
to
.
getCount
()
+
from
.
getCount
());
}
}
cat-home/src/main/java/com/dianping/cat/report/page/network/Handler.java
浏览文件 @
c7ea21a4
...
...
@@ -20,7 +20,7 @@ import com.dianping.cat.helper.TimeUtil;
import
com.dianping.cat.home.metricAggregation.entity.MetricAggregationGroup
;
import
com.dianping.cat.report.ReportPage
;
import
com.dianping.cat.report.chart.AggregationGraphCreator
;
import
com.dianping.cat.report.chart.
DefaultAgg
GraphCreator
;
import
com.dianping.cat.report.chart.
Network
GraphCreator
;
import
com.dianping.cat.report.page.LineChart
;
import
com.dianping.cat.report.page.PayloadNormalizer
;
import
com.dianping.cat.report.page.network.nettopology.NetGraphManager
;
...
...
@@ -44,7 +44,7 @@ public class Handler implements PageHandler<Context> {
private
AggregationGraphCreator
m_aggregationGraphCreator
;
@Inject
private
DefaultAgg
GraphCreator
m_defaultAggGraphCreator
;
private
Network
GraphCreator
m_defaultAggGraphCreator
;
@Inject
private
NetGraphManager
m_netGraphManager
;
...
...
cat-home/src/main/java/com/dianping/cat/report/page/network/nettopology/NetGraphBuilder.java
浏览文件 @
c7ea21a4
...
...
@@ -40,6 +40,10 @@ public class NetGraphBuilder implements Initializable {
try
{
double
insum
=
0
;
double
outsum
=
0
;
double
inDiscardsSum
=
0
;
double
outDiscardsSum
=
0
;
double
inErrorsSum
=
0
;
double
outErrorsSum
=
0
;
for
(
Interface
inter
:
connection
.
getInterfaces
())
{
String
group
=
inter
.
getGroup
();
...
...
@@ -48,9 +52,17 @@ public class NetGraphBuilder implements Initializable {
updateInterface
(
inter
,
report
,
i
);
insum
+=
inter
.
getIn
();
outsum
+=
inter
.
getOut
();
inDiscardsSum
+=
inter
.
getIndiscards
();
outDiscardsSum
+=
inter
.
getOutdiscards
();
inErrorsSum
+=
inter
.
getInerrors
();
outErrorsSum
+=
inter
.
getOuterrors
();
}
connection
.
setInsum
(
insum
);
connection
.
setOutsum
(
outsum
);
connection
.
setIndiscards
(
inDiscardsSum
);
connection
.
setOutdiscards
(
outDiscardsSum
);
connection
.
setInerrors
(
inErrorsSum
);
connection
.
setOuterrors
(
outErrorsSum
);
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
...
...
@@ -117,9 +129,17 @@ public class NetGraphBuilder implements Initializable {
try
{
MetricItem
inItem
=
report
.
findOrCreateMetricItem
(
domain
+
":Metric:"
+
key
+
"-in"
);
MetricItem
outItem
=
report
.
findOrCreateMetricItem
(
domain
+
":Metric:"
+
key
+
"-out"
);
MetricItem
inDiscardsItem
=
report
.
findOrCreateMetricItem
(
domain
+
":Metric:"
+
key
+
"-indiscards"
);
MetricItem
outDiscardsItem
=
report
.
findOrCreateMetricItem
(
domain
+
":Metric:"
+
key
+
"-outdiscards"
);
MetricItem
inErrorsItem
=
report
.
findOrCreateMetricItem
(
domain
+
":Metric:"
+
key
+
"-inerrors"
);
MetricItem
outErrorsItem
=
report
.
findOrCreateMetricItem
(
domain
+
":Metric:"
+
key
+
"-outerrors"
);
inter
.
setIn
(
inItem
.
findOrCreateSegment
(
minute
).
getSum
()
/
60
*
8
);
inter
.
setOut
(
outItem
.
findOrCreateSegment
(
minute
).
getSum
()
/
60
*
8
);
inter
.
setIndiscards
(
inDiscardsItem
.
findOrCreateSegment
(
minute
).
getSum
()
/
60
);
inter
.
setOutdiscards
(
outDiscardsItem
.
findOrCreateSegment
(
minute
).
getSum
()
/
60
);
inter
.
setInerrors
(
inErrorsItem
.
findOrCreateSegment
(
minute
).
getSum
()
/
60
);
inter
.
setOuterrors
(
outErrorsItem
.
findOrCreateSegment
(
minute
).
getSum
()
/
60
);
}
catch
(
Exception
e
)
{
inter
.
setIn
(
0.0
);
inter
.
setOut
(
0.0
);
...
...
cat-home/src/main/java/com/dianping/cat/report/page/userMonitor/CityManager.java
浏览文件 @
c7ea21a4
...
...
@@ -38,8 +38,10 @@ public class CityManager implements Initializable {
if
(
list
==
null
)
{
list
=
new
ArrayList
<
City
>();
list
.
add
(
new
City
(
province
,
""
));
if
(
province
.
length
()
>
0
)
{
list
.
add
(
new
City
(
province
,
""
));
}
maps
.
put
(
province
,
list
);
}
list
.
add
(
new
City
(
province
,
city
));
...
...
cat-home/src/main/java/com/dianping/cat/report/page/userMonitor/Handler.java
浏览文件 @
c7ea21a4
...
...
@@ -5,6 +5,7 @@ import java.util.ArrayList;
import
java.util.Collection
;
import
java.util.Date
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
import
javax.servlet.ServletException
;
...
...
@@ -82,9 +83,13 @@ public class Handler implements PageHandler<Context> {
if
(
url
!=
null
)
{
if
(
Monitor
.
TYPE_INFO
.
equals
(
type
))
{
Map
<
String
,
LineChart
>
charts
=
m_graphCreator
.
queryBaseInfo
(
startDate
,
endDate
,
url
,
pars
);
Pair
<
Map
<
String
,
LineChart
>,
List
<
PieChart
>>
charts
=
m_graphCreator
.
queryBaseInfo
(
startDate
,
endDate
,
url
,
pars
);
Map
<
String
,
LineChart
>
lineCharts
=
charts
.
getKey
();
List
<
PieChart
>
pieCharts
=
charts
.
getValue
();
model
.
setLineCharts
(
charts
);
model
.
setLineCharts
(
lineCharts
);
model
.
setPieCharts
(
pieCharts
);
}
else
{
Pair
<
LineChart
,
PieChart
>
pair
=
m_graphCreator
.
queryErrorInfo
(
startDate
,
endDate
,
url
,
pars
);
...
...
cat-home/src/main/java/com/dianping/cat/report/page/userMonitor/Model.java
浏览文件 @
c7ea21a4
...
...
@@ -19,6 +19,8 @@ public class Model extends AbstractReportModel<Action, Context> {
private
Map
<
String
,
LineChart
>
m_lineCharts
;
private
List
<
PieChart
>
m_pieCharts
;
private
LineChart
m_lineChart
;
private
PieChart
m_pieChart
;
...
...
@@ -80,6 +82,10 @@ public class Model extends AbstractReportModel<Action, Context> {
return
m_pieChart
;
}
public
List
<
PieChart
>
getPieCharts
()
{
return
m_pieCharts
;
}
public
Date
getStart
()
{
return
m_start
;
}
...
...
@@ -112,6 +118,10 @@ public class Model extends AbstractReportModel<Action, Context> {
m_pieChart
=
pieChart
;
}
public
void
setPieCharts
(
List
<
PieChart
>
pieCharts
)
{
m_pieCharts
=
pieCharts
;
}
public
void
setStart
(
Date
start
)
{
m_start
=
start
;
}
...
...
cat-home/src/main/java/com/dianping/cat/report/page/userMonitor/UserMonitorConvert.java
浏览文件 @
c7ea21a4
package
com.dianping.cat.report.page.userMonitor
;
import
org.hsqldb.lib.StringUtil
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.Monitor
;
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.consumer.metric.model.entity.StatisticsItem
;
import
com.dianping.cat.consumer.metric.model.transform.BaseVisitor
;
import
com.site.lookup.util.StringUtils
;
...
...
@@ -24,6 +27,44 @@ public class UserMonitorConvert extends BaseVisitor {
m_channel
=
channel
;
}
private
void
buildDetailInfo
(
MetricItem
metricItem
,
String
city
,
String
channel
,
String
info
)
{
int
total
=
0
;
for
(
Segment
segment
:
metricItem
.
getSegments
().
values
())
{
total
=
total
+
segment
.
getCount
();
}
if
(
Monitor
.
TYPE_INFO
.
equals
(
m_type
))
{
String
key
=
""
;
if
(
info
.
equals
(
Monitor
.
HIT
))
{
key
=
Monitor
.
HIT_COUNT
;
}
else
if
(
info
.
equals
(
Monitor
.
ERROR
))
{
key
=
Monitor
.
ERROR_COUNT
;
}
else
{
return
;
}
int
index
=
city
.
indexOf
(
'-'
);
if
(
StringUtil
.
isEmpty
(
m_city
))
{
StatisticsItem
tem
=
m_report
.
findOrCreateStatistic
(
Monitor
.
CITY
+
key
).
findOrCreateStatisticsItem
(
city
.
substring
(
0
,
index
));
tem
.
setCount
(
tem
.
getCount
()
+
total
);
}
else
if
(!
m_city
.
equals
(
city
))
{
StatisticsItem
tem
=
m_report
.
findOrCreateStatistic
(
Monitor
.
CITY
+
key
).
findOrCreateStatisticsItem
(
city
.
substring
(
index
+
1
));
tem
.
setCount
(
tem
.
getCount
()
+
total
);
}
if
(
StringUtil
.
isEmpty
(
m_channel
))
{
StatisticsItem
tem
=
m_report
.
findOrCreateStatistic
(
Monitor
.
CHANNEL
+
key
).
findOrCreateStatisticsItem
(
channel
);
tem
.
setCount
(
tem
.
getCount
()
+
total
);
}
}
}
public
MetricReport
getReport
()
{
return
m_report
;
}
...
...
@@ -94,7 +135,7 @@ public class UserMonitorConvert extends BaseVisitor {
}
private
boolean
validateInfo
(
String
info
)
{
if
(
Monitor
.
HIT
.
equals
(
info
)
||
Monitor
.
ERROR
.
equals
(
info
))
{
if
(
Monitor
.
AVG
.
equals
(
info
)
||
Monitor
.
HIT
.
equals
(
info
)
||
Monitor
.
ERROR
.
equals
(
info
))
{
return
true
;
}
else
{
return
false
;
...
...
@@ -114,6 +155,8 @@ public class UserMonitorConvert extends BaseVisitor {
MetricItem
item
=
m_report
.
findOrCreateMetricItem
(
info
);
mergeMetricItem
(
item
,
metricItem
);
buildDetailInfo
(
metricItem
,
city
,
channel
,
info
);
}
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
...
...
cat-home/src/main/java/com/dianping/cat/report/page/userMonitor/graph/DefaultUserMonitGraphCreator.java
浏览文件 @
c7ea21a4
...
...
@@ -13,11 +13,14 @@ import com.dianping.cat.advanced.metric.config.entity.MetricItemConfig;
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.consumer.metric.model.entity.Statistic
;
import
com.dianping.cat.consumer.metric.model.entity.StatisticsItem
;
import
com.dianping.cat.helper.TimeUtil
;
import
com.dianping.cat.report.chart.BaseGraphCreator
;
import
com.dianping.cat.report.page.LineChart
;
import
com.dianping.cat.report.page.PieChart
;
import
com.dianping.cat.report.page.PieChart.Item
;
import
com.dianping.cat.report.page.model.metric.MetricReportMerger
;
public
class
DefaultUserMonitGraphCreator
extends
BaseGraphCreator
implements
UserMonitorGraphCreator
{
...
...
@@ -27,6 +30,32 @@ public class DefaultUserMonitGraphCreator extends BaseGraphCreator implements Us
private
static
final
String
SUCESS_PERCENT
=
"调用成功率(%)"
;
private
static
final
int
MULTIPLE
=
10
;
private
List
<
PieChart
>
buildDetailPieChart
(
MetricReport
report
)
{
Map
<
String
,
Statistic
>
statics
=
report
.
getStatistics
();
List
<
PieChart
>
charts
=
new
ArrayList
<
PieChart
>();
for
(
Entry
<
String
,
Statistic
>
entry
:
statics
.
entrySet
())
{
PieChart
chart
=
new
PieChart
().
setMaxSize
(
Integer
.
MAX_VALUE
);
List
<
Item
>
items
=
new
ArrayList
<
Item
>();
Statistic
values
=
entry
.
getValue
();
Map
<
String
,
StatisticsItem
>
statisticsItems
=
values
.
getStatisticsItems
();
for
(
StatisticsItem
tmp
:
statisticsItems
.
values
())
{
Item
item
=
new
Item
();
item
.
setNumber
(
tmp
.
getCount
());
item
.
setTitle
(
tmp
.
getId
());
items
.
add
(
item
);
}
chart
.
setTitle
(
entry
.
getKey
());
chart
.
addItems
(
items
);
charts
.
add
(
chart
);
}
return
charts
;
}
public
Pair
<
LineChart
,
PieChart
>
buildErrorChartData
(
final
Map
<
String
,
double
[]>
datas
,
Date
startDate
,
Date
endDate
,
final
Map
<
String
,
double
[]>
dataWithOutFutures
)
{
LineChart
lineChart
=
new
LineChart
();
...
...
@@ -70,7 +99,7 @@ public class DefaultUserMonitGraphCreator extends BaseGraphCreator implements Us
LineChart
lineChart
=
new
LineChart
();
if
(
SUCESS_PERCENT
.
equals
(
key
))
{
lineChart
.
setMinYlable
(
9
5
);
lineChart
.
setMinYlable
(
9
0
);
}
lineChart
.
setId
(
key
);
lineChart
.
setTitle
(
key
);
...
...
@@ -113,8 +142,13 @@ public class DefaultUserMonitGraphCreator extends BaseGraphCreator implements Us
datas
.
put
(
key
,
data
);
}
for
(
Segment
segment
:
segments
.
values
())
{
int
count
=
segment
.
getCount
();
if
(
"200"
.
equals
(
key
))
{
count
=
count
*
MULTIPLE
;
}
int
minute
=
segment
.
getId
();
data
[
minute
]
=
segment
.
getCount
()
;
data
[
minute
]
=
count
;
}
}
return
datas
;
...
...
@@ -142,10 +176,11 @@ public class DefaultUserMonitGraphCreator extends BaseGraphCreator implements Us
int
id
=
segment
.
getId
();
if
(
key
.
endsWith
(
Monitor
.
HIT
))
{
count
[
id
]
=
segment
.
getCount
()
*
10
;
avg
[
id
]
=
segment
.
getAvg
();
count
[
id
]
=
segment
.
getCount
()
*
MULTIPLE
;
}
else
if
(
key
.
endsWith
(
Monitor
.
ERROR
))
{
error
[
id
]
=
segment
.
getCount
();
}
else
if
(
key
.
endsWith
(
Monitor
.
AVG
))
{
avg
[
id
]
=
segment
.
getAvg
();
}
}
}
...
...
@@ -154,7 +189,7 @@ public class DefaultUserMonitGraphCreator extends BaseGraphCreator implements Us
double
sum
=
count
[
i
]
+
error
[
i
];
if
(
sum
>
0
)
{
successPercent
[
i
]
=
count
[
i
]
*
100
/
sum
;
successPercent
[
i
]
=
count
[
i
]
/
sum
*
100.0
;
}
else
{
successPercent
[
i
]
=
100
;
}
...
...
@@ -162,12 +197,14 @@ public class DefaultUserMonitGraphCreator extends BaseGraphCreator implements Us
return
data
;
}
private
Map
<
String
,
double
[]>
prepareAllData
(
String
url
,
Map
<
String
,
String
>
pars
,
Date
startDate
,
Date
endDate
)
{
private
Map
<
String
,
double
[]>
prepareAllData
(
MetricReport
all
,
String
url
,
Map
<
String
,
String
>
pars
,
Date
startDate
,
Date
endDate
)
{
long
start
=
startDate
.
getTime
(),
end
=
endDate
.
getTime
();
int
totalSize
=
(
int
)
((
end
-
start
)
/
TimeUtil
.
ONE_MINUTE
);
Map
<
String
,
double
[]>
sourceValue
=
new
LinkedHashMap
<
String
,
double
[]>();
int
index
=
0
;
String
type
=
pars
.
get
(
"type"
);
MetricReportMerger
merger
=
new
MetricReportMerger
(
all
);
for
(;
start
<
end
;
start
+=
TimeUtil
.
ONE_HOUR
)
{
MetricReport
report
=
m_metricReportService
.
queryUserMonitorReport
(
url
,
pars
,
new
Date
(
start
));
...
...
@@ -176,6 +213,7 @@ public class DefaultUserMonitGraphCreator extends BaseGraphCreator implements Us
Map
<
String
,
double
[]>
currentValues
=
fetchMetricInfoData
(
report
);
mergeMap
(
sourceValue
,
currentValues
,
totalSize
,
index
);
report
.
accept
(
merger
);
}
else
{
Map
<
String
,
double
[]>
currentValues
=
fetchMetricCodeInfo
(
report
);
...
...
@@ -187,17 +225,22 @@ public class DefaultUserMonitGraphCreator extends BaseGraphCreator implements Us
}
@Override
public
Map
<
String
,
LineChart
>
queryBaseInfo
(
Date
startDate
,
Date
endDate
,
String
url
,
Map
<
String
,
String
>
pars
)
{
Map
<
String
,
double
[]>
oldCurrentValues
=
prepareAllData
(
url
,
pars
,
startDate
,
endDate
);
public
Pair
<
Map
<
String
,
LineChart
>,
List
<
PieChart
>>
queryBaseInfo
(
Date
startDate
,
Date
endDate
,
String
url
,
Map
<
String
,
String
>
pars
)
{
MetricReport
report
=
new
MetricReport
(
url
);
Map
<
String
,
double
[]>
oldCurrentValues
=
prepareAllData
(
report
,
url
,
pars
,
startDate
,
endDate
);
Map
<
String
,
double
[]>
allCurrentValues
=
m_dataExtractor
.
extract
(
oldCurrentValues
);
Map
<
String
,
double
[]>
dataWithOutFutures
=
removeFutureData
(
endDate
,
allCurrentValues
);
return
buildInfoChartData
(
oldCurrentValues
,
startDate
,
endDate
,
dataWithOutFutures
);
Map
<
String
,
LineChart
>
lineCharts
=
buildInfoChartData
(
oldCurrentValues
,
startDate
,
endDate
,
dataWithOutFutures
);
List
<
PieChart
>
pieCharts
=
buildDetailPieChart
(
report
);
return
new
Pair
<
Map
<
String
,
LineChart
>,
List
<
PieChart
>>(
lineCharts
,
pieCharts
);
}
@Override
public
Pair
<
LineChart
,
PieChart
>
queryErrorInfo
(
Date
startDate
,
Date
endDate
,
String
url
,
Map
<
String
,
String
>
pars
)
{
Map
<
String
,
double
[]>
oldCurrentValues
=
prepareAllData
(
url
,
pars
,
startDate
,
endDate
);
MetricReport
report
=
new
MetricReport
(
url
);
Map
<
String
,
double
[]>
oldCurrentValues
=
prepareAllData
(
report
,
url
,
pars
,
startDate
,
endDate
);
Map
<
String
,
double
[]>
allCurrentValues
=
m_dataExtractor
.
extract
(
oldCurrentValues
);
Map
<
String
,
double
[]>
dataWithOutFutures
=
removeFutureData
(
endDate
,
allCurrentValues
);
...
...
cat-home/src/main/java/com/dianping/cat/report/page/userMonitor/graph/UserMonitorGraphCreator.java
浏览文件 @
c7ea21a4
package
com.dianping.cat.report.page.userMonitor.graph
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
com.alibaba.cobar.parser.util.Pair
;
...
...
@@ -9,7 +10,7 @@ import com.dianping.cat.report.page.PieChart;
public
interface
UserMonitorGraphCreator
{
public
Map
<
String
,
LineChart
>
queryBaseInfo
(
Date
start
,
Date
end
,
String
url
,
Map
<
String
,
String
>
pars
);
public
Pair
<
Map
<
String
,
LineChart
>,
List
<
PieChart
>
>
queryBaseInfo
(
Date
start
,
Date
end
,
String
url
,
Map
<
String
,
String
>
pars
);
public
Pair
<
LineChart
,
PieChart
>
queryErrorInfo
(
Date
startDate
,
Date
endDate
,
String
url
,
Map
<
String
,
String
>
pars
);
...
...
cat-home/src/main/java/com/dianping/cat/report/service/CachedReportTask.java
浏览文件 @
c7ea21a4
package
com.dianping.cat.report.service
;
import
java.text.SimpleDateFormat
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.Set
;
import
org.codehaus.plexus.logging.LogEnabled
;
import
org.codehaus.plexus.logging.Logger
;
import
org.unidal.helper.Threads.Task
;
import
org.unidal.lookup.annotation.Inject
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.
Constants
;
import
com.dianping.cat.
ServerConfigManager
;
import
com.dianping.cat.configuration.NetworkInterfaceManager
;
import
com.dianping.cat.consumer.cross.CrossAnalyzer
;
import
com.dianping.cat.consumer.cross.model.entity.CrossReport
;
...
...
@@ -27,57 +30,19 @@ import com.dianping.cat.consumer.transaction.model.entity.TransactionReport;
import
com.dianping.cat.core.dal.MonthlyReport
;
import
com.dianping.cat.core.dal.WeeklyReport
;
import
com.dianping.cat.helper.TimeUtil
;
import
com.dianping.cat.home.bug.entity.BugReport
;
import
com.dianping.cat.home.service.entity.ServiceReport
;
import
com.dianping.cat.message.Transaction
;
public
class
CachedReportTask
implements
Task
{
public
class
CachedReportTask
implements
Task
,
LogEnabled
{
private
long
m_end
;
@Inject
private
ReportService
m_reportService
;
private
void
buildCacheReportByDuration
(
Date
start
,
Date
end
,
Set
<
String
>
domains
)
{
for
(
String
domain
:
domains
)
{
TransactionReport
transactionReport
=
m_reportService
.
queryTransactionReport
(
domain
,
start
,
end
);
new
TransactionReportUrlFilter
().
visitTransactionReport
(
transactionReport
);
m_reportService
.
insertMonthlyReport
(
buildMonthlyReport
(
domain
,
start
,
TransactionAnalyzer
.
ID
),
com
.
dianping
.
cat
.
consumer
.
transaction
.
model
.
transform
.
DefaultNativeBuilder
.
build
(
transactionReport
));
EventReport
eventReport
=
m_reportService
.
queryEventReport
(
domain
,
start
,
end
);
m_reportService
.
insertMonthlyReport
(
buildMonthlyReport
(
domain
,
start
,
EventAnalyzer
.
ID
),
com
.
dianping
.
cat
.
consumer
.
event
.
model
.
transform
.
DefaultNativeBuilder
.
build
(
eventReport
));
ProblemReport
problemReport
=
m_reportService
.
queryProblemReport
(
domain
,
start
,
end
);
m_reportService
.
insertMonthlyReport
(
buildMonthlyReport
(
domain
,
start
,
ProblemAnalyzer
.
ID
),
com
.
dianping
.
cat
.
consumer
.
problem
.
model
.
transform
.
DefaultNativeBuilder
.
build
(
problemReport
));
CrossReport
crossReport
=
m_reportService
.
queryCrossReport
(
domain
,
start
,
end
);
m_reportService
.
insertMonthlyReport
(
buildMonthlyReport
(
domain
,
start
,
CrossAnalyzer
.
ID
),
com
.
dianping
.
cat
.
consumer
.
cross
.
model
.
transform
.
DefaultNativeBuilder
.
build
(
crossReport
));
MatrixReport
matrixReport
=
m_reportService
.
queryMatrixReport
(
domain
,
start
,
end
);
new
MatrixReportFilter
().
visitMatrixReport
(
matrixReport
);
m_reportService
.
insertMonthlyReport
(
buildMonthlyReport
(
domain
,
start
,
MatrixAnalyzer
.
ID
),
com
.
dianping
.
cat
.
consumer
.
matrix
.
model
.
transform
.
DefaultNativeBuilder
.
build
(
matrixReport
));
}
String
domain
=
"Cat"
;
StateReport
stateReport
=
m_reportService
.
queryStateReport
(
domain
,
start
,
end
);
m_reportService
.
insertMonthlyReport
(
buildMonthlyReport
(
domain
,
start
,
StateAnalyzer
.
ID
),
com
.
dianping
.
cat
.
consumer
.
state
.
model
.
transform
.
DefaultNativeBuilder
.
build
(
stateReport
));
BugReport
bugReport
=
m_reportService
.
queryBugReport
(
domain
,
start
,
end
);
m_reportService
.
insertMonthlyReport
(
buildMonthlyReport
(
domain
,
start
,
Constants
.
REPORT_BUG
),
com
.
dianping
.
cat
.
home
.
bug
.
transform
.
DefaultNativeBuilder
.
build
(
bugReport
));
@Inject
private
ServerConfigManager
m_configManger
;
ServiceReport
serviceReport
=
m_reportService
.
queryServiceReport
(
domain
,
start
,
end
);
m_reportService
.
insertMonthlyReport
(
buildMonthlyReport
(
domain
,
start
,
Constants
.
REPORT_SERVICE
),
com
.
dianping
.
cat
.
home
.
service
.
transform
.
DefaultNativeBuilder
.
build
(
serviceReport
));
}
private
Logger
m_logger
;
private
MonthlyReport
buildMonthlyReport
(
String
domain
,
Date
period
,
String
name
)
{
MonthlyReport
report
=
new
MonthlyReport
();
...
...
@@ -115,7 +80,42 @@ public class CachedReportTask implements Task {
Date
end
=
TimeUtil
.
getCurrentDay
();
Set
<
String
>
domains
=
m_reportService
.
queryAllDomainNames
(
start
,
end
,
TransactionAnalyzer
.
ID
);
buildCacheReportByDuration
(
start
,
end
,
domains
);
for
(
String
domain
:
domains
)
{
if
(
m_configManger
.
validateDomain
(
domain
))
{
Transaction
t
=
Cat
.
newTransaction
(
"ReloadTask"
,
"Reload-Month-"
+
domain
);
TransactionReport
transactionReport
=
m_reportService
.
queryTransactionReport
(
domain
,
start
,
end
);
new
TransactionReportUrlFilter
().
visitTransactionReport
(
transactionReport
);
m_reportService
.
insertMonthlyReport
(
buildMonthlyReport
(
domain
,
start
,
TransactionAnalyzer
.
ID
),
com
.
dianping
.
cat
.
consumer
.
transaction
.
model
.
transform
.
DefaultNativeBuilder
.
build
(
transactionReport
));
EventReport
eventReport
=
m_reportService
.
queryEventReport
(
domain
,
start
,
end
);
m_reportService
.
insertMonthlyReport
(
buildMonthlyReport
(
domain
,
start
,
EventAnalyzer
.
ID
),
com
.
dianping
.
cat
.
consumer
.
event
.
model
.
transform
.
DefaultNativeBuilder
.
build
(
eventReport
));
ProblemReport
problemReport
=
m_reportService
.
queryProblemReport
(
domain
,
start
,
end
);
m_reportService
.
insertMonthlyReport
(
buildMonthlyReport
(
domain
,
start
,
ProblemAnalyzer
.
ID
),
com
.
dianping
.
cat
.
consumer
.
problem
.
model
.
transform
.
DefaultNativeBuilder
.
build
(
problemReport
));
CrossReport
crossReport
=
m_reportService
.
queryCrossReport
(
domain
,
start
,
end
);
m_reportService
.
insertMonthlyReport
(
buildMonthlyReport
(
domain
,
start
,
CrossAnalyzer
.
ID
),
com
.
dianping
.
cat
.
consumer
.
cross
.
model
.
transform
.
DefaultNativeBuilder
.
build
(
crossReport
));
MatrixReport
matrixReport
=
m_reportService
.
queryMatrixReport
(
domain
,
start
,
end
);
new
MatrixReportFilter
().
visitMatrixReport
(
matrixReport
);
m_reportService
.
insertMonthlyReport
(
buildMonthlyReport
(
domain
,
start
,
MatrixAnalyzer
.
ID
),
com
.
dianping
.
cat
.
consumer
.
matrix
.
model
.
transform
.
DefaultNativeBuilder
.
build
(
matrixReport
));
t
.
setStatus
(
Transaction
.
SUCCESS
);
t
.
complete
();
}
}
String
domain
=
"Cat"
;
StateReport
stateReport
=
m_reportService
.
queryStateReport
(
domain
,
start
,
end
);
m_reportService
.
insertMonthlyReport
(
buildMonthlyReport
(
domain
,
start
,
StateAnalyzer
.
ID
),
com
.
dianping
.
cat
.
consumer
.
state
.
model
.
transform
.
DefaultNativeBuilder
.
build
(
stateReport
));
}
private
void
reloadCurrentWeekly
()
{
...
...
@@ -124,43 +124,41 @@ public class CachedReportTask implements Task {
Set
<
String
>
domains
=
m_reportService
.
queryAllDomainNames
(
start
,
end
,
TransactionAnalyzer
.
ID
);
for
(
String
domain
:
domains
)
{
TransactionReport
transactionReport
=
m_reportService
.
queryTransactionReport
(
domain
,
start
,
end
);
new
TransactionReportUrlFilter
().
visitTransactionReport
(
transactionReport
);
m_reportService
.
insertWeeklyReport
(
buildWeeklyReport
(
domain
,
start
,
TransactionAnalyzer
.
ID
),
com
.
dianping
.
cat
.
consumer
.
transaction
.
model
.
transform
.
DefaultNativeBuilder
.
build
(
transactionReport
));
EventReport
eventReport
=
m_reportService
.
queryEventReport
(
domain
,
start
,
end
);
m_reportService
.
insertWeeklyReport
(
buildWeeklyReport
(
domain
,
start
,
EventAnalyzer
.
ID
),
com
.
dianping
.
cat
.
consumer
.
event
.
model
.
transform
.
DefaultNativeBuilder
.
build
(
eventReport
));
ProblemReport
problemReport
=
m_reportService
.
queryProblemReport
(
domain
,
start
,
end
);
m_reportService
.
insertWeeklyReport
(
buildWeeklyReport
(
domain
,
start
,
ProblemAnalyzer
.
ID
),
com
.
dianping
.
cat
.
consumer
.
problem
.
model
.
transform
.
DefaultNativeBuilder
.
build
(
problemReport
));
CrossReport
crossReport
=
m_reportService
.
queryCrossReport
(
domain
,
start
,
end
);
m_reportService
.
insertWeeklyReport
(
buildWeeklyReport
(
domain
,
start
,
CrossAnalyzer
.
ID
),
com
.
dianping
.
cat
.
consumer
.
cross
.
model
.
transform
.
DefaultNativeBuilder
.
build
(
crossReport
));
MatrixReport
matrixReport
=
m_reportService
.
queryMatrixReport
(
domain
,
start
,
end
);
new
MatrixReportFilter
().
visitMatrixReport
(
matrixReport
);
m_reportService
.
insertWeeklyReport
(
buildWeeklyReport
(
domain
,
start
,
MatrixAnalyzer
.
ID
),
com
.
dianping
.
cat
.
consumer
.
matrix
.
model
.
transform
.
DefaultNativeBuilder
.
build
(
matrixReport
));
if
(
m_configManger
.
validateDomain
(
domain
))
{
Transaction
t
=
Cat
.
newTransaction
(
"ReloadTask"
,
"Reload-Week-"
+
domain
);
TransactionReport
transactionReport
=
m_reportService
.
queryTransactionReport
(
domain
,
start
,
end
);
new
TransactionReportUrlFilter
().
visitTransactionReport
(
transactionReport
);
m_reportService
.
insertWeeklyReport
(
buildWeeklyReport
(
domain
,
start
,
TransactionAnalyzer
.
ID
),
com
.
dianping
.
cat
.
consumer
.
transaction
.
model
.
transform
.
DefaultNativeBuilder
.
build
(
transactionReport
));
EventReport
eventReport
=
m_reportService
.
queryEventReport
(
domain
,
start
,
end
);
m_reportService
.
insertWeeklyReport
(
buildWeeklyReport
(
domain
,
start
,
EventAnalyzer
.
ID
),
com
.
dianping
.
cat
.
consumer
.
event
.
model
.
transform
.
DefaultNativeBuilder
.
build
(
eventReport
));
ProblemReport
problemReport
=
m_reportService
.
queryProblemReport
(
domain
,
start
,
end
);
m_reportService
.
insertWeeklyReport
(
buildWeeklyReport
(
domain
,
start
,
ProblemAnalyzer
.
ID
),
com
.
dianping
.
cat
.
consumer
.
problem
.
model
.
transform
.
DefaultNativeBuilder
.
build
(
problemReport
));
CrossReport
crossReport
=
m_reportService
.
queryCrossReport
(
domain
,
start
,
end
);
m_reportService
.
insertWeeklyReport
(
buildWeeklyReport
(
domain
,
start
,
CrossAnalyzer
.
ID
),
com
.
dianping
.
cat
.
consumer
.
cross
.
model
.
transform
.
DefaultNativeBuilder
.
build
(
crossReport
));
MatrixReport
matrixReport
=
m_reportService
.
queryMatrixReport
(
domain
,
start
,
end
);
new
MatrixReportFilter
().
visitMatrixReport
(
matrixReport
);
m_reportService
.
insertWeeklyReport
(
buildWeeklyReport
(
domain
,
start
,
MatrixAnalyzer
.
ID
),
com
.
dianping
.
cat
.
consumer
.
matrix
.
model
.
transform
.
DefaultNativeBuilder
.
build
(
matrixReport
));
t
.
setStatus
(
Transaction
.
SUCCESS
);
t
.
complete
();
}
}
String
domain
=
"Cat"
;
StateReport
stateReport
=
m_reportService
.
queryStateReport
(
domain
,
start
,
end
);
m_reportService
.
insertWeeklyReport
(
buildWeeklyReport
(
domain
,
start
,
StateAnalyzer
.
ID
),
com
.
dianping
.
cat
.
consumer
.
state
.
model
.
transform
.
DefaultNativeBuilder
.
build
(
stateReport
));
BugReport
bugReport
=
m_reportService
.
queryBugReport
(
domain
,
start
,
end
);
m_reportService
.
insertWeeklyReport
(
buildWeeklyReport
(
domain
,
start
,
Constants
.
REPORT_BUG
),
com
.
dianping
.
cat
.
home
.
bug
.
transform
.
DefaultNativeBuilder
.
build
(
bugReport
));
ServiceReport
serviceReport
=
m_reportService
.
queryServiceReport
(
domain
,
start
,
end
);
m_reportService
.
insertWeeklyReport
(
buildWeeklyReport
(
domain
,
start
,
Constants
.
REPORT_SERVICE
),
com
.
dianping
.
cat
.
home
.
service
.
transform
.
DefaultNativeBuilder
.
build
(
serviceReport
));
}
@Override
...
...
@@ -174,18 +172,18 @@ public class CachedReportTask implements Task {
// assume dailyreport job has been completed in two hours.
if
(
time
>
m_end
&&
cal
.
get
(
Calendar
.
HOUR_OF_DAY
)
>=
3
)
{
Transaction
t
=
Cat
.
newTransaction
(
"System"
,
"ReportReload"
);
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm"
);
Date
start
=
new
Date
();
try
{
reloadCurrentWeekly
();
reloadCurrentMonthly
();
m_end
=
date
.
getTime
();
t
.
setStatus
(
Transaction
.
SUCCESS
);
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
t
.
setStatus
(
e
);
}
finally
{
t
.
complete
();
}
m_logger
.
info
(
String
.
format
(
"reload report start at %s, end at %s"
,
sdf
.
format
(
start
),
sdf
.
format
(
new
Date
())));
}
try
{
Thread
.
sleep
(
60
*
60
*
1000
);
...
...
@@ -199,4 +197,9 @@ public class CachedReportTask implements Task {
public
void
shutdown
()
{
}
@Override
public
void
enableLogging
(
Logger
logger
)
{
m_logger
=
logger
;
}
}
cat-home/src/main/java/com/dianping/cat/report/task/exceptionAlert/AlertReportBuilder.java
浏览文件 @
c7ea21a4
...
...
@@ -18,6 +18,7 @@ import com.dianping.cat.home.alertReport.transform.DefaultNativeBuilder;
import
com.dianping.cat.report.service.ReportService
;
import
com.dianping.cat.report.task.TaskHelper
;
import
com.dianping.cat.report.task.spi.ReportTaskBuilder
;
import
com.dianping.cat.system.config.ExceptionExcludeConfigManager
;
import
com.dianping.cat.system.config.ExceptionThresholdConfigManager
;
public
class
AlertReportBuilder
implements
ReportTaskBuilder
{
...
...
@@ -26,7 +27,10 @@ public class AlertReportBuilder implements ReportTaskBuilder {
protected
ReportService
m_reportService
;
@Inject
private
ExceptionThresholdConfigManager
m_configManager
;
private
ExceptionThresholdConfigManager
m_exceptionThresholdConfigManager
;
@Inject
private
ExceptionExcludeConfigManager
m_exceptionExcludeConfigManager
;
@Override
public
boolean
buildDailyTask
(
String
name
,
String
domain
,
Date
period
)
{
...
...
@@ -47,7 +51,9 @@ public class AlertReportBuilder implements ReportTaskBuilder {
@Override
public
boolean
buildHourlyTask
(
String
name
,
String
domain
,
Date
start
)
{
AlertReport
alertReport
=
new
AlertReport
(
Constants
.
CAT
);
TopReportVisitor
visitor
=
new
TopReportVisitor
(
m_configManager
).
setReport
(
alertReport
);
TopReportVisitor
visitor
=
new
TopReportVisitor
().
setReport
(
alertReport
)
.
setExceptionExcludeConfigManager
(
m_exceptionExcludeConfigManager
)
.
setExceptionThresholdConfigManager
(
m_exceptionThresholdConfigManager
);
Date
end
=
new
Date
(
start
.
getTime
()
+
TimeUtil
.
ONE_HOUR
);
alertReport
.
setStartTime
(
start
);
...
...
cat-home/src/main/java/com/dianping/cat/report/task/exceptionAlert/ExceptionAlert.java
浏览文件 @
c7ea21a4
package
com.dianping.cat.report.task.exceptionAlert
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.Collection
;
...
...
@@ -23,6 +24,7 @@ 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.dependency.exception.entity.ExceptionLimit
;
import
com.dianping.cat.home.dependency.exceptionExclude.entity.ExceptionExclude
;
import
com.dianping.cat.message.Event
;
import
com.dianping.cat.message.Transaction
;
import
com.dianping.cat.report.page.model.spi.ModelService
;
...
...
@@ -31,6 +33,7 @@ import com.dianping.cat.report.page.top.TopMetric.Item;
import
com.dianping.cat.report.task.metric.MetricAlertConfig
;
import
com.dianping.cat.service.ModelRequest
;
import
com.dianping.cat.service.ModelResponse
;
import
com.dianping.cat.system.config.ExceptionExcludeConfigManager
;
import
com.dianping.cat.system.config.ExceptionThresholdConfigManager
;
import
com.dianping.cat.system.tool.MailSMS
;
...
...
@@ -46,7 +49,10 @@ public class ExceptionAlert implements Task, LogEnabled {
private
MailSMS
m_mailSms
;
@Inject
private
ExceptionThresholdConfigManager
m_configManager
;
private
ExceptionThresholdConfigManager
m_exceptionThresholdConfigManager
;
@Inject
private
ExceptionExcludeConfigManager
m_exceptionExcludeConfigManager
;
@Inject
(
type
=
ModelService
.
class
,
value
=
TopAnalyzer
.
ID
)
private
ModelService
<
TopReport
>
m_topService
;
...
...
@@ -65,7 +71,7 @@ public class ExceptionAlert implements Task, LogEnabled {
private
TopMetric
buildTopMetric
(
Date
date
)
{
TopReport
topReport
=
queryTopReport
(
date
);
TopMetric
topMetric
=
new
TopMetric
(
ALERT_PERIOD
,
Integer
.
MAX_VALUE
,
m_
c
onfigManager
);
TopMetric
topMetric
=
new
TopMetric
(
ALERT_PERIOD
,
Integer
.
MAX_VALUE
,
m_
exceptionThresholdC
onfigManager
);
topMetric
.
setStart
(
date
).
setEnd
(
new
Date
(
date
.
getTime
()
+
TimeUtil
.
ONE_MINUTE
));
topMetric
.
visitTopReport
(
topReport
);
...
...
@@ -104,15 +110,16 @@ public class ExceptionAlert implements Task, LogEnabled {
}
Transaction
t
=
Cat
.
newTransaction
(
"ExceptionAlert"
,
"M"
+
minuteStr
);
long
current
=
System
.
currentTimeMillis
();
try
{
TopMetric
topMetric
=
buildTopMetric
(
new
Date
(
current
-
TimeUtil
.
ONE_MINUTE
*
2
));
Collection
<
List
<
Item
>>
items
=
topMetric
.
getError
().
getResult
().
values
();
Map
<
String
,
List
<
AlertException
>>
alertExceptions
=
getAlertExceptions
(
items
);
for
(
Entry
<
String
,
List
<
AlertException
>>
entry
:
alertExceptions
.
entrySet
())
{
try
{
sendAlertForDomain
(
entry
.
getKey
(),
entry
.
getValue
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
m_logger
.
error
(
e
.
getMessage
());
}
}
...
...
@@ -149,7 +156,7 @@ public class ExceptionAlert implements Task, LogEnabled {
for
(
List
<
Item
>
item
:
items
)
{
for
(
Item
i
:
item
)
{
String
domain
=
i
.
getDomain
();
ExceptionLimit
totalExceptionLimit
=
m_
c
onfigManager
.
queryDomainTotalLimit
(
domain
);
ExceptionLimit
totalExceptionLimit
=
m_
exceptionThresholdC
onfigManager
.
queryDomainTotalLimit
(
domain
);
int
totalWarnLimit
=
-
1
;
int
totalErrorLimit
=
-
1
;
int
totalException
=
0
;
...
...
@@ -161,10 +168,20 @@ public class ExceptionAlert implements Task, LogEnabled {
for
(
Entry
<
String
,
Double
>
entry
:
i
.
getException
().
entrySet
())
{
String
exceptionName
=
entry
.
getKey
();
ExceptionExclude
result
=
m_exceptionExcludeConfigManager
.
queryDomainExceptionExclude
(
domain
,
exceptionName
);
if
(
result
!=
null
)
{
continue
;
}
double
value
=
entry
.
getValue
().
doubleValue
();
double
warnLimit
=
-
1
;
double
errorLimit
=
-
1
;
ExceptionLimit
exceptionLimit
=
m_configManager
.
queryDomainExceptionLimit
(
domain
,
entry
.
getKey
());
ExceptionLimit
exceptionLimit
=
m_exceptionThresholdConfigManager
.
queryDomainExceptionLimit
(
domain
,
exceptionName
);
totalException
+=
entry
.
getValue
();
if
(
exceptionLimit
!=
null
)
{
warnLimit
=
exceptionLimit
.
getWarning
();
...
...
@@ -173,11 +190,9 @@ public class ExceptionAlert implements Task, LogEnabled {
if
(
errorLimit
>
0
&&
value
>
errorLimit
)
{
findOrCreateDomain
(
alertExceptions
,
domain
).
add
(
new
AlertException
(
exceptionName
,
ERROR_FLAG
,
value
));
totalException
++;
}
else
if
(
warnLimit
>
0
&&
value
>
warnLimit
)
{
findOrCreateDomain
(
alertExceptions
,
domain
).
add
(
new
AlertException
(
exceptionName
,
WARN_FLAG
,
value
));
totalException
++;
}
}
}
...
...
@@ -208,8 +223,7 @@ public class ExceptionAlert implements Task, LogEnabled {
Project
project
=
queryProjectByDomain
(
domain
);
List
<
String
>
emails
=
m_alertConfig
.
buildMailReceivers
(
project
);
StringBuilder
title
=
new
StringBuilder
();
title
.
append
(
"[异常告警] [项目组: "
).
append
(
domain
).
append
(
"] [时间: "
).
append
(
new
Date
()).
append
(
"]"
);
title
.
append
(
"[CAT异常告警] [项目: "
).
append
(
domain
).
append
(
"]"
);
List
<
String
>
errorExceptions
=
new
ArrayList
<
String
>();
List
<
String
>
warnExceptions
=
new
ArrayList
<
String
>();
...
...
@@ -220,12 +234,18 @@ public class ExceptionAlert implements Task, LogEnabled {
errorExceptions
.
add
(
exception
.
getName
());
}
}
String
mailContent
=
"[异常警告] ["
+
domain
+
"] : "
;
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
"[CAT异常告警] ["
).
append
(
domain
).
append
(
"] : "
);
sb
.
append
(
exceptions
.
toString
()).
append
(
"[时间: "
)
.
append
(
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm"
).
format
(
new
Date
())).
append
(
"]"
);
String
mailContent
=
sb
.
toString
();
m_logger
.
info
(
title
+
" "
+
mailContent
+
" "
+
emails
);
m_mailSms
.
sendEmail
(
title
.
toString
(),
mailContent
,
emails
);
Cat
.
logEvent
(
"
Metric
Alert"
,
project
.
getDomain
(),
Event
.
SUCCESS
,
title
+
" "
+
mailContent
);
Cat
.
logEvent
(
"
Exception
Alert"
,
project
.
getDomain
(),
Event
.
SUCCESS
,
title
+
" "
+
mailContent
);
}
@Override
...
...
cat-home/src/main/java/com/dianping/cat/report/task/exceptionAlert/TopReportVisitor.java
浏览文件 @
c7ea21a4
...
...
@@ -7,27 +7,40 @@ import com.dianping.cat.consumer.top.model.entity.TopReport;
import
com.dianping.cat.consumer.top.model.transform.BaseVisitor
;
import
com.dianping.cat.home.alertReport.entity.AlertReport
;
import
com.dianping.cat.home.dependency.exception.entity.ExceptionLimit
;
import
com.dianping.cat.home.dependency.exceptionExclude.entity.ExceptionExclude
;
import
com.dianping.cat.system.config.ExceptionExcludeConfigManager
;
import
com.dianping.cat.system.config.ExceptionThresholdConfigManager
;
public
class
TopReportVisitor
extends
BaseVisitor
{
private
ExceptionThresholdConfigManager
m_configManager
;
private
ExceptionThresholdConfigManager
m_exceptionThresholdConfigManager
;
private
ExceptionExcludeConfigManager
m_exceptionExcludeConfigManager
;
private
AlertReport
m_report
;
private
String
m_currentDomain
;
private
static
final
String
TOTAL_EXCEPTION_ALERT
=
"TotalExceptionAlert"
;
private
long
m_totalSegmentException
;
public
TopReportVisitor
(
ExceptionThresholdConfigManager
configManager
)
{
m_configManager
=
configManager
;
}
private
static
final
String
TOTAL_EXCEPTION_ALERT
=
"TotalExceptionAlert"
;
public
TopReportVisitor
setReport
(
AlertReport
report
)
{
m_report
=
report
;
return
this
;
}
public
TopReportVisitor
setExceptionThresholdConfigManager
(
ExceptionThresholdConfigManager
exceptionThresholdConfigManager
)
{
m_exceptionThresholdConfigManager
=
exceptionThresholdConfigManager
;
return
this
;
}
public
TopReportVisitor
setExceptionExcludeConfigManager
(
ExceptionExcludeConfigManager
exceptionExcludeConfigManager
)
{
m_exceptionExcludeConfigManager
=
exceptionExcludeConfigManager
;
return
this
;
}
@Override
public
void
visitDomain
(
Domain
domain
)
{
m_currentDomain
=
domain
.
getName
();
...
...
@@ -36,16 +49,26 @@ public class TopReportVisitor extends BaseVisitor {
@Override
public
void
visitError
(
Error
error
)
{
ExceptionExclude
exceptionExclude
=
m_exceptionExcludeConfigManager
.
queryDomainExceptionExclude
(
m_currentDomain
,
error
.
getId
());
if
(
exceptionExclude
!=
null
)
{
return
;
}
int
warnLimit
=
-
1
;
int
errorLimit
=
-
1
;
int
count
=
error
.
getCount
();
ExceptionLimit
exceptionLimit
=
m_exceptionThresholdConfigManager
.
queryDomainExceptionLimit
(
m_currentDomain
,
error
.
getId
());
ExceptionLimit
exceptionLimit
=
m_configManager
.
queryDomainExceptionLimit
(
m_currentDomain
,
error
.
getId
())
;
m_totalSegmentException
+=
count
;
if
(
exceptionLimit
!=
null
)
{
warnLimit
=
exceptionLimit
.
getWarning
();
errorLimit
=
exceptionLimit
.
getError
();
}
int
count
=
error
.
getCount
();
if
(
errorLimit
>
0
&
warnLimit
>
0
&
count
>=
Math
.
min
(
warnLimit
,
errorLimit
))
{
...
...
@@ -66,31 +89,32 @@ public class TopReportVisitor extends BaseVisitor {
@Override
public
void
visitSegment
(
Segment
segment
)
{
long
totalSegmentException
=
segment
.
getError
();
ExceptionLimit
exceptionLimit
=
m_configManager
.
queryDomainTotalLimit
(
m_currentDomain
);
m_totalSegmentException
=
0
;
super
.
visitSegment
(
segment
);
ExceptionLimit
exceptionLimit
=
m_exceptionThresholdConfigManager
.
queryDomainTotalLimit
(
m_currentDomain
);
int
warnLimit
=
-
1
;
int
errorLimit
=
-
1
;
if
(
exceptionLimit
!=
null
)
{
warnLimit
=
exceptionLimit
.
getWarning
();
errorLimit
=
exceptionLimit
.
getError
();
}
if
(
errorLimit
>
0
&
warnLimit
>
0
&
totalSegmentException
>=
Math
.
min
(
warnLimit
,
errorLimit
))
{
if
(
errorLimit
>
0
&
warnLimit
>
0
&
m_
totalSegmentException
>=
Math
.
min
(
warnLimit
,
errorLimit
))
{
com
.
dianping
.
cat
.
home
.
alertReport
.
entity
.
Domain
domain
=
m_report
.
findOrCreateDomain
(
m_currentDomain
);
com
.
dianping
.
cat
.
home
.
alertReport
.
entity
.
Exception
exception
=
domain
.
findOrCreateException
(
TOTAL_EXCEPTION_ALERT
);
if
(
totalSegmentException
>=
errorLimit
)
{
if
(
m_
totalSegmentException
>=
errorLimit
)
{
domain
.
incErrorNumber
();
exception
.
incErrorNumber
();
}
else
if
(
totalSegmentException
>=
warnLimit
)
{
}
else
if
(
m_
totalSegmentException
>=
warnLimit
)
{
domain
.
incWarnNumber
();
exception
.
incWarnNumber
();
}
}
super
.
visitSegment
(
segment
);
}
@Override
...
...
cat-home/src/main/java/com/dianping/cat/report/task/metric/AlertInfo.java
浏览文件 @
c7ea21a4
...
...
@@ -5,22 +5,30 @@ import java.util.List;
import
java.util.Map.Entry
;
import
java.util.concurrent.ConcurrentHashMap
;
import
org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable
;
import
org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException
;
import
org.unidal.lookup.annotation.Inject
;
import
com.dianping.cat.advanced.metric.config.entity.MetricItemConfig
;
import
com.dianping.cat.consumer.metric.MetricConfigManager
;
import
com.dianping.cat.helper.TimeUtil
;
public
class
AlertInfo
{
public
class
AlertInfo
implements
Initializable
{
private
ConcurrentHashMap
<
MetricItemConfig
,
Long
>
m_alertInfos
=
new
ConcurrentHashMap
<
MetricItemConfig
,
Long
>();
private
ConcurrentHashMap
<
MetricItemConfig
,
Long
>
m_alerts
=
new
ConcurrentHashMap
<
MetricItemConfig
,
Long
>();
@Inject
protected
MetricConfigManager
m_manager
;
public
void
add
Metric
(
MetricItemConfig
config
,
long
value
)
{
m_alert
s
.
putIfAbsen
t
(
config
,
value
);
public
void
add
AlertInfo
(
MetricItemConfig
config
,
long
value
)
{
m_alert
Infos
.
pu
t
(
config
,
value
);
}
public
List
<
MetricItemConfig
>
getLastestAlarm
(
int
minute
)
{
public
List
<
MetricItemConfig
>
queryLastestAlarmInfo
(
int
minute
)
{
List
<
MetricItemConfig
>
config
=
new
ArrayList
<
MetricItemConfig
>();
long
currentTimeMillis
=
System
.
currentTimeMillis
();
for
(
Entry
<
MetricItemConfig
,
Long
>
entry
:
m_alerts
.
entrySet
())
{
for
(
Entry
<
MetricItemConfig
,
Long
>
entry
:
m_alert
Info
s
.
entrySet
())
{
Long
value
=
entry
.
getValue
();
if
(
currentTimeMillis
-
value
<
TimeUtil
.
ONE_MINUTE
*
minute
)
{
...
...
@@ -30,4 +38,8 @@ public class AlertInfo {
return
config
;
}
@Override
public
void
initialize
()
throws
InitializationException
{
}
}
cat-home/src/main/java/com/dianping/cat/report/task/metric/MetricAlert.java
浏览文件 @
c7ea21a4
...
...
@@ -181,9 +181,8 @@ public class MetricAlert extends BaseAlert implements Task, LogEnabled {
}
if
(
alert
!=
null
&&
alert
.
getKey
())
{
config
.
setId
(
m_metricConfigManager
.
buildMetricKey
(
config
.
getDomain
(),
config
.
getType
(),
config
.
getMetricKey
()));
m_alertInfo
.
addMetric
(
config
,
new
Date
().
getTime
());
m_alertInfo
.
addAlertInfo
(
config
,
new
Date
().
getTime
());
sendAlertInfo
(
productLine
,
config
,
alert
.
getValue
());
}
}
...
...
cat-home/src/main/java/com/dianping/cat/report/task/metric/MetricAlertConfig.java
浏览文件 @
c7ea21a4
...
...
@@ -14,7 +14,7 @@ import com.dianping.cat.core.dal.Project;
import
com.dianping.cat.home.monitorrules.entity.Config
;
import
com.site.helper.Splitters
;
public
class
MetricAlertConfig
extends
BaseAlertConfig
{
public
class
MetricAlertConfig
extends
BaseAlertConfig
{
public
List
<
String
>
buildExceptionSMSReceivers
(
ProductLine
productLine
)
{
List
<
String
>
phones
=
new
ArrayList
<
String
>();
...
...
@@ -31,7 +31,10 @@ public class MetricAlertConfig extends BaseAlertConfig{
emails
.
add
(
"jialin.sun@dianping.com"
);
emails
.
add
(
"argus@dianping.com"
);
emails
.
add
(
"monitor@dianping.com"
);
emails
.
addAll
(
Splitters
.
by
(
","
).
noEmptyItem
().
split
(
emailList
));
if
(
emailList
!=
null
)
{
emails
.
addAll
(
Splitters
.
by
(
","
).
noEmptyItem
().
split
(
emailList
));
}
return
emails
;
}
...
...
@@ -39,9 +42,10 @@ public class MetricAlertConfig extends BaseAlertConfig{
List
<
String
>
emails
=
new
ArrayList
<
String
>();
String
emailList
=
project
.
getEmail
();
emails
.
add
(
"yong.you@dianping.com"
);
emails
.
add
(
"jialin.sun@dianping.com"
);
emails
.
addAll
(
Splitters
.
by
(
","
).
noEmptyItem
().
split
(
emailList
));
if
(
emailList
!=
null
)
{
emails
.
addAll
(
Splitters
.
by
(
","
).
noEmptyItem
().
split
(
emailList
));
}
return
emails
;
}
...
...
@@ -52,7 +56,10 @@ public class MetricAlertConfig extends BaseAlertConfig{
phones
.
add
(
"13916536843"
);
// 值班
phones
.
add
(
"18616671676"
);
// 尤勇
phones
.
add
(
"13858086694"
);
// 黄河
phones
.
addAll
(
Splitters
.
by
(
","
).
noEmptyItem
().
split
(
phonesList
));
if
(
phonesList
!=
null
)
{
phones
.
addAll
(
Splitters
.
by
(
","
).
noEmptyItem
().
split
(
phonesList
));
}
return
phones
;
}
...
...
@@ -100,16 +107,15 @@ public class MetricAlertConfig extends BaseAlertConfig{
return
new
Pair
<
Boolean
,
String
>(
true
,
sb
.
toString
());
}
public
Pair
<
Boolean
,
String
>
checkData
(
double
[]
value
,
double
[]
baseline
,
MetricType
type
,
List
<
Config
>
configs
)
{
public
Pair
<
Boolean
,
String
>
checkData
(
double
[]
value
,
double
[]
baseline
,
MetricType
type
,
List
<
Config
>
configs
)
{
for
(
Config
con
:
configs
)
{
Pair
<
Boolean
,
String
>
tmpResult
=
checkDataByConfig
(
value
,
baseline
,
type
,
con
);
if
(
tmpResult
.
getKey
()
==
true
)
{
return
tmpResult
;
}
}
return
new
Pair
<
Boolean
,
String
>(
false
,
""
);
}
}
cat-home/src/main/java/com/dianping/cat/report/task/metric/SwitchAlert.java
浏览文件 @
c7ea21a4
...
...
@@ -123,8 +123,7 @@ public class SwitchAlert extends BaseAlert implements Task, LogEnabled {
}
if
(
alert
!=
null
&&
alert
.
getKey
())
{
config
.
setId
(
m_metricConfigManager
.
buildMetricKey
(
config
.
getDomain
(),
config
.
getType
(),
config
.
getMetricKey
()));
m_alertInfo
.
addMetric
(
config
,
new
Date
().
getTime
());
m_alertInfo
.
addAlertInfo
(
config
,
new
Date
().
getTime
());
sendAlertInfo
(
productLine
,
config
,
alert
.
getValue
());
}
}
...
...
cat-home/src/main/java/com/dianping/cat/system/config/ExceptionExcludeConfigManager.java
0 → 100644
浏览文件 @
c7ea21a4
package
com.dianping.cat.system.config
;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable
;
import
org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException
;
import
org.unidal.dal.jdbc.DalNotFoundException
;
import
org.unidal.helper.Files
;
import
org.unidal.lookup.annotation.Inject
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.core.config.Config
;
import
com.dianping.cat.core.config.ConfigDao
;
import
com.dianping.cat.core.config.ConfigEntity
;
import
com.dianping.cat.home.dependency.exceptionExclude.entity.DomainConfig
;
import
com.dianping.cat.home.dependency.exceptionExclude.entity.ExceptionExclude
;
import
com.dianping.cat.home.dependency.exceptionExclude.entity.ExceptionExcludeConfig
;
import
com.dianping.cat.home.dependency.exceptionExclude.transform.DefaultSaxParser
;
public
class
ExceptionExcludeConfigManager
implements
Initializable
{
@Inject
private
ConfigDao
m_configDao
;
private
int
m_configId
;
private
ExceptionExcludeConfig
m_exceptionConfig
;
public
static
String
DEFAULT_STRING
=
"Default"
;
public
static
String
ALL_STRING
=
"All"
;
private
static
final
String
CONFIG_NAME
=
"exceptionExcludeConfig"
;
@Override
public
void
initialize
()
throws
InitializationException
{
try
{
Config
config
=
m_configDao
.
findByName
(
CONFIG_NAME
,
ConfigEntity
.
READSET_FULL
);
String
content
=
config
.
getContent
();
m_exceptionConfig
=
DefaultSaxParser
.
parse
(
content
);
m_configId
=
config
.
getId
();
}
catch
(
DalNotFoundException
e
)
{
try
{
String
content
=
Files
.
forIO
().
readFrom
(
this
.
getClass
().
getResourceAsStream
(
"/config/default-exception-exclude-config.xml"
),
"utf-8"
);
Config
config
=
m_configDao
.
createLocal
();
config
.
setName
(
CONFIG_NAME
);
config
.
setContent
(
content
);
m_configDao
.
insert
(
config
);
m_exceptionConfig
=
DefaultSaxParser
.
parse
(
content
);
m_configId
=
config
.
getId
();
}
catch
(
Exception
ex
)
{
Cat
.
logError
(
ex
);
}
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
if
(
m_exceptionConfig
==
null
)
{
m_exceptionConfig
=
new
ExceptionExcludeConfig
();
}
}
public
boolean
deleteExceptionExclude
(
String
domain
,
String
exceptionName
)
{
DomainConfig
domainConfig
=
m_exceptionConfig
.
findOrCreateDomainConfig
(
domain
);
domainConfig
.
removeExceptionExclude
(
exceptionName
);
return
storeConfig
();
}
public
boolean
insertExceptionExclude
(
ExceptionExclude
exception
)
{
DomainConfig
domainConfig
=
m_exceptionConfig
.
findOrCreateDomainConfig
(
exception
.
getDomain
());
domainConfig
.
getExceptionExcludes
().
put
(
exception
.
getId
(),
exception
);
return
storeConfig
();
}
public
List
<
ExceptionExclude
>
queryAllExceptionExcludes
()
{
List
<
ExceptionExclude
>
result
=
new
ArrayList
<
ExceptionExclude
>();
for
(
DomainConfig
domainConfig
:
m_exceptionConfig
.
getDomainConfigs
().
values
())
{
result
.
addAll
(
domainConfig
.
getExceptionExcludes
().
values
());
}
return
result
;
}
public
ExceptionExclude
queryDomainExceptionExclude
(
String
domain
,
String
exceptionName
)
{
DomainConfig
domainConfig
=
m_exceptionConfig
.
getDomainConfigs
().
get
(
domain
);
ExceptionExclude
result
=
null
;
if
(
domainConfig
==
null
)
{
domainConfig
=
m_exceptionConfig
.
getDomainConfigs
().
get
(
DEFAULT_STRING
);
}
if
(
domainConfig
!=
null
)
{
result
=
domainConfig
.
getExceptionExcludes
().
get
(
exceptionName
);
if
(
result
==
null
)
{
result
=
domainConfig
.
getExceptionExcludes
().
get
(
ALL_STRING
);
}
}
return
result
;
}
private
boolean
storeConfig
()
{
synchronized
(
this
)
{
try
{
Config
config
=
m_configDao
.
createLocal
();
config
.
setId
(
m_configId
);
config
.
setKeyId
(
m_configId
);
config
.
setName
(
CONFIG_NAME
);
config
.
setContent
(
m_exceptionConfig
.
toString
());
m_configDao
.
updateByPK
(
config
,
ConfigEntity
.
UPDATESET_FULL
);
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
return
false
;
}
}
return
true
;
}
}
cat-home/src/main/java/com/dianping/cat/system/config/ExceptionThresholdConfigManager.java
浏览文件 @
c7ea21a4
...
...
@@ -29,9 +29,9 @@ public class ExceptionThresholdConfigManager implements Initializable {
private
static
final
String
CONFIG_NAME
=
"exceptionThresholdConfig"
;
p
rivate
static
String
DEFAULT_STRING
=
"Default"
;
p
ublic
static
String
DEFAULT_STRING
=
"Default"
;
p
rivate
static
String
TOTAL_STRING
=
"Total"
;
p
ublic
static
String
TOTAL_STRING
=
"Total"
;
public
boolean
deleteExceptionLimit
(
String
domain
,
String
exceptionName
)
{
DomainConfig
domainConfig
=
m_exceptionConfig
.
findOrCreateDomainConfig
(
domain
);
...
...
@@ -98,6 +98,7 @@ public class ExceptionThresholdConfigManager implements Initializable {
public
ExceptionLimit
queryDomainTotalLimit
(
String
domain
)
{
ExceptionLimit
result
=
queryDomainExceptionLimit
(
domain
,
TOTAL_STRING
);
if
(
result
==
null
)
{
result
=
queryDomainExceptionLimit
(
DEFAULT_STRING
,
TOTAL_STRING
);
}
...
...
cat-home/src/main/java/com/dianping/cat/system/page/config/Handler.java
浏览文件 @
c7ea21a4
...
...
@@ -416,6 +416,7 @@ public class Handler implements PageHandler<Context> {
if
(!
StringUtil
.
isEmpty
(
domain
)
&&
!
StringUtil
.
isEmpty
(
type
)
&&
!
StringUtil
.
isEmpty
(
metricKey
))
{
config
.
setId
(
m_metricConfigManager
.
buildMetricKey
(
domain
,
type
,
metricKey
));
return
m_metricConfigManager
.
insertMetricItemConfig
(
config
);
}
else
{
return
false
;
...
...
@@ -428,28 +429,20 @@ public class Handler implements PageHandler<Context> {
Set
<
String
>
exists
=
new
HashSet
<
String
>();
for
(
Entry
<
String
,
ProductLine
>
entry
:
productLines
.
entrySet
())
{
Set
<
String
>
domains
=
entry
.
getValue
().
getDomains
().
keySet
();
List
<
MetricItemConfig
>
configs
=
m_metricConfigManager
.
queryMetricItemConfigs
(
domains
);
for
(
MetricItemConfig
config
:
configs
)
{
exists
.
add
(
m_metricConfigManager
.
buildMetricKey
(
config
.
getDomain
(),
config
.
getType
(),
config
.
getMetricKey
()));
ProductLine
productLine
=
entry
.
getValue
();
if
(
productLine
.
isMetricDashboard
())
{
Set
<
String
>
domains
=
productLine
.
getDomains
().
keySet
();
List
<
MetricItemConfig
>
configs
=
m_metricConfigManager
.
queryMetricItemConfigs
(
domains
);
for
(
MetricItemConfig
config
:
configs
)
{
exists
.
add
(
m_metricConfigManager
.
buildMetricKey
(
config
.
getDomain
(),
config
.
getType
(),
config
.
getMetricKey
()));
}
metricConfigs
.
put
(
productLine
,
configs
);
}
metricConfigs
.
put
(
entry
.
getValue
(),
configs
);
}
Map
<
String
,
MetricItemConfig
>
allConfigs
=
m_metricConfigManager
.
getMetricConfig
().
getMetricItemConfigs
();
Set
<
String
>
keysClone
=
new
HashSet
<
String
>(
allConfigs
.
keySet
());
List
<
MetricItemConfig
>
otherConfigs
=
new
ArrayList
<
MetricItemConfig
>();
for
(
String
key
:
exists
)
{
keysClone
.
remove
(
key
);
}
for
(
String
str
:
keysClone
)
{
otherConfigs
.
add
(
allConfigs
.
get
(
str
));
}
ProductLine
otherProductLine
=
new
ProductLine
(
"Other"
).
setTitle
(
"Other"
);
metricConfigs
.
put
(
otherProductLine
,
otherConfigs
);
model
.
setProductMetricConfigs
(
metricConfigs
);
}
...
...
@@ -468,7 +461,8 @@ public class Handler implements PageHandler<Context> {
private
List
<
String
>
queryDoaminList
()
{
List
<
String
>
result
=
new
ArrayList
<
String
>();
List
<
Project
>
projects
=
queryAllProjects
();
result
.
add
(
"Default"
);
for
(
Project
p
:
projects
)
{
result
.
add
(
p
.
getDomain
());
}
...
...
@@ -481,6 +475,8 @@ public class Handler implements PageHandler<Context> {
Date
end
=
new
Date
(
start
.
getTime
()
+
TimeUtil
.
ONE_HOUR
);
BugReport
report
=
m_reportService
.
queryBugReport
(
Constants
.
CAT
,
start
,
end
);
Set
<
String
>
exceptions
=
new
HashSet
<
String
>();
exceptions
.
add
(
"Total"
);
for
(
Entry
<
String
,
com
.
dianping
.
cat
.
home
.
bug
.
entity
.
Domain
>
domain
:
report
.
getDomains
().
entrySet
())
{
exceptions
.
addAll
(
domain
.
getValue
().
getExceptionItems
().
keySet
());
...
...
cat-home/src/main/resources/META-INF/dal/model/exception-exclude-config-codegen.xml
0 → 100644
浏览文件 @
c7ea21a4
<?xml version="1.0" encoding="UTF-8"?>
<model>
<entity
name=
"exception-exclude-config"
root=
"true"
>
<entity-ref
name=
"domain-config"
type=
"list"
names=
"domain-configs"
/>
</entity>
<entity
name=
"domain-config"
>
<attribute
name=
"id"
value-type=
"String"
/>
<entity-ref
name=
"exception-exclude"
type=
"list"
names=
"exception-excludes"
/>
</entity>
<entity
name=
"exception-exclude"
>
<attribute
name=
"domain"
value-type=
"String"
/>
<attribute
name=
"id"
value-type=
"String"
/>
</entity>
</model>
cat-home/src/main/resources/META-INF/dal/model/exception-exclude-config-manifest.xml
0 → 100644
浏览文件 @
c7ea21a4
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<file
path=
"exception-exclude-config-codegen.xml"
/>
<file
path=
"exception-exclude-config-model.xml"
/>
</manifest>
cat-home/src/main/resources/META-INF/dal/model/exception-exclude-config-model.xml
0 → 100644
浏览文件 @
c7ea21a4
<?xml version="1.0" encoding="UTF-8"?>
<model
model-package=
"com.dianping.cat.home.dependency.exceptionExclude"
enable-merger=
"false"
enable-sax-parser=
"true"
enable-base-visitor=
"false"
>
<entity
name=
"exception-exclude-config"
root=
"true"
>
<entity-ref
name=
"domain-config"
type=
"map"
names=
"domain-configs"
method-find-or-create=
"true"
/>
</entity>
<entity
name=
"domain-config"
>
<attribute
name=
"id"
value-type=
"String"
key=
"true"
/>
<entity-ref
name=
"exception-exclude"
type=
"map"
names=
"exception-excludes"
method-find-or-create=
"true"
/>
</entity>
<entity
name=
"exception-exclude"
>
<attribute
name=
"domain"
value-type=
"String"
/>
<attribute
name=
"id"
value-type=
"String"
key=
"true"
/>
</entity>
</model>
cat-home/src/main/resources/META-INF/dal/model/netgraph-model.xml
浏览文件 @
c7ea21a4
...
...
@@ -33,6 +33,10 @@
<entity-ref
name=
"interface"
type=
"list"
names=
"interfaces"
/>
<attribute
name=
"insum"
value-type=
"double"
/>
<attribute
name=
"outsum"
value-type=
"double"
/>
<attribute
name=
"indiscards"
value-type=
"double"
/>
<attribute
name=
"outdiscards"
value-type=
"double"
/>
<attribute
name=
"inerrors"
value-type=
"double"
/>
<attribute
name=
"outerrors"
value-type=
"double"
/>
</entity>
<entity
name=
"interface"
>
<attribute
name=
"group"
value-type=
"String"
/>
...
...
@@ -41,5 +45,9 @@
<attribute
name=
"state"
value-type=
"int"
/>
<attribute
name=
"in"
value-type=
"double"
/>
<attribute
name=
"out"
value-type=
"double"
/>
<attribute
name=
"indiscards"
value-type=
"double"
/>
<attribute
name=
"outdiscards"
value-type=
"double"
/>
<attribute
name=
"inerrors"
value-type=
"double"
/>
<attribute
name=
"outerrors"
value-type=
"double"
/>
</entity>
</model>
cat-home/src/main/resources/META-INF/plexus/components.xml
浏览文件 @
c7ea21a4
...
...
@@ -86,6 +86,15 @@
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.system.config.ExceptionExcludeConfigManager
</role>
<implementation>
com.dianping.cat.system.config.ExceptionExcludeConfigManager
</implementation>
<requirements>
<requirement>
<role>
com.dianping.cat.core.config.ConfigDao
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.system.config.DomainGroupConfigManager
</role>
<implementation>
com.dianping.cat.system.config.DomainGroupConfigManager
</implementation>
...
...
@@ -217,6 +226,15 @@
<role>
com.dianping.cat.report.chart.MetricDataFetcher
</role>
<implementation>
com.dianping.cat.report.chart.impl.MetricDataFetcherImpl
</implementation>
</component>
<component>
<role>
com.dianping.cat.report.task.metric.AlertInfo
</role>
<implementation>
com.dianping.cat.report.task.metric.AlertInfo
</implementation>
<requirements>
<requirement>
<role>
com.dianping.cat.consumer.metric.MetricConfigManager
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.report.chart.GraphCreator
</role>
<implementation>
com.dianping.cat.report.chart.GraphCreator
</implementation>
...
...
@@ -311,8 +329,8 @@
</requirements>
</component>
<component>
<role>
com.dianping.cat.report.chart.
DefaultAgg
GraphCreator
</role>
<implementation>
com.dianping.cat.report.chart.
DefaultAgg
GraphCreator
</implementation>
<role>
com.dianping.cat.report.chart.
Network
GraphCreator
</role>
<implementation>
com.dianping.cat.report.chart.
Network
GraphCreator
</implementation>
<requirements>
<requirement>
<role>
com.dianping.cat.report.chart.CachedMetricReportService
</role>
...
...
@@ -1050,6 +1068,9 @@
<requirement>
<role>
com.dianping.cat.system.config.ExceptionThresholdConfigManager
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.system.config.ExceptionExcludeConfigManager
</role>
</requirement>
</requirements>
</component>
<component>
...
...
@@ -1673,6 +1694,9 @@
<requirement>
<role>
com.dianping.cat.report.service.ReportService
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.ServerConfigManager
</role>
</requirement>
</requirements>
</component>
<component>
...
...
@@ -1778,6 +1802,9 @@
<requirement>
<role>
com.dianping.cat.system.config.ExceptionThresholdConfigManager
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.system.config.ExceptionExcludeConfigManager
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.report.page.model.spi.ModelService
</role>
<role-hint>
top
</role-hint>
...
...
@@ -2941,11 +2968,19 @@
<requirement>
<role>
com.dianping.cat.core.config.ConfigDao
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.consumer.metric.ProductLineConfigManager
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.report.task.metric.AlertInfo
</role>
<implementation>
com.dianping.cat.report.task.metric.AlertInfo
</implementation>
<requirements>
<requirement>
<role>
com.dianping.cat.consumer.metric.MetricConfigManager
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.report.page.jsError.Handler
</role>
...
...
@@ -3222,7 +3257,7 @@
<role>
com.dianping.cat.report.chart.AggregationGraphCreator
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.report.chart.
DefaultAgg
GraphCreator
</role>
<role>
com.dianping.cat.report.chart.
Network
GraphCreator
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.report.page.network.nettopology.NetGraphManager
</role>
...
...
@@ -3281,8 +3316,8 @@
</requirements>
</component>
<component>
<role>
com.dianping.cat.report.chart.
DefaultAgg
GraphCreator
</role>
<implementation>
com.dianping.cat.report.chart.
DefaultAgg
GraphCreator
</implementation>
<role>
com.dianping.cat.report.chart.
Network
GraphCreator
</role>
<implementation>
com.dianping.cat.report.chart.
Network
GraphCreator
</implementation>
<requirements>
<requirement>
<role>
com.dianping.cat.report.baseline.BaselineService
</role>
...
...
@@ -3565,6 +3600,9 @@
<requirement>
<role>
com.dianping.cat.system.config.ExceptionThresholdConfigManager
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.system.config.ExceptionExcludeConfigManager
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.system.config.UtilizationConfigManager
</role>
</requirement>
...
...
@@ -3612,6 +3650,15 @@
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.system.config.ExceptionExcludeConfigManager
</role>
<implementation>
com.dianping.cat.system.config.ExceptionExcludeConfigManager
</implementation>
<requirements>
<requirement>
<role>
com.dianping.cat.core.config.ConfigDao
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.system.config.UtilizationConfigManager
</role>
<implementation>
com.dianping.cat.system.config.UtilizationConfigManager
</implementation>
...
...
cat-home/src/main/resources/META-INF/wizard/model/wizard.xml
浏览文件 @
c7ea21a4
...
...
@@ -48,4 +48,7 @@
<model
package=
"com.dianping.cat.home.alertReport"
name=
"alert-report"
>
<sample-model>
src/test/resources/com/dianping/cat/report/task/exceptionAlert/alert-report.xml
</sample-model>
</model>
<model
package=
"com.dianping.cat.home.exception-exclude-config"
name=
"exception-exclude-config"
>
<sample-model>
src/test/resources/com/dianping/cat/report/page/dependency/exception-exclude-config.xml
</sample-model>
</model>
</wizard>
cat-home/src/main/resources/config/city
浏览文件 @
c7ea21a4
中国|||0
中国|安徽省|安庆市|28799
中国|安徽省|蚌埠市|21408
中国|安徽省|亳州市|28794
...
...
cat-home/src/main/resources/config/default-exception-exclude-config.xml
0 → 100644
浏览文件 @
c7ea21a4
<?xml version="1.0" encoding="utf-8"?>
<exception-exclude-config>
<domain-config
id =
"Default"
>
<exception-exclude
domain=
"Default"
id=
"java.lang.IllegalArgumentException"
></exception-exclude>
</domain-config>
<domain-config
id =
"jlsun"
>
<exception-exclude
domain=
"jlsun"
id=
"java.lang.IllegalArgumentException"
></exception-exclude>
</domain-config>
</exception-exclude-config>
cat-home/src/main/resources/config/default-nettopology-config.xml
浏览文件 @
c7ea21a4
...
...
@@ -3,20 +3,20 @@
<netGraph
minute=
"0"
>
<netTopology
name=
"南汇机房"
>
<anchors>
<anchor
name=
"CTC"
x=
"3
2
0"
y=
"20"
/>
<anchor
name=
"CNC"
x=
"1
30"
y=
"2
0"
/>
<anchor
name=
"HM"
x=
"4
60"
y=
"40
0"
/>
<anchor
name=
"CTC"
x=
"3
4
0"
y=
"20"
/>
<anchor
name=
"CNC"
x=
"1
50"
y=
"6
0"
/>
<anchor
name=
"HM"
x=
"4
80"
y=
"48
0"
/>
</anchors>
<switchs>
<switch
name=
"QW-E8030"
x=
"3
20"
y=
"10
0"
state=
"1"
/>
<switch
name=
"C3750-CTC"
x=
"3
20"
y=
"20
0"
/>
<switch
name=
"C3750-CNC"
x=
"1
30"
y=
"20
0"
/>
<switch
name=
"F5v2400-1"
x=
"3
20"
y=
"30
0"
/>
<switch
name=
"F5v2400-2"
x=
"1
30"
y=
"30
0"
/>
<switch
name=
"N7K-1"
x=
"3
20"
y=
"40
0"
/>
<switch
name=
"N7K-2"
x=
"1
30"
y=
"40
0"
/>
<switch
name=
"N5K-1"
x=
"3
20"
y=
"5
00"
/>
<switch
name=
"N5K-2"
x=
"1
30"
y=
"5
00"
/>
<switch
name=
"QW-E8030"
x=
"3
40"
y=
"12
0"
state=
"1"
/>
<switch
name=
"C3750-CTC"
x=
"3
40"
y=
"24
0"
/>
<switch
name=
"C3750-CNC"
x=
"1
50"
y=
"24
0"
/>
<switch
name=
"F5v2400-1"
x=
"3
40"
y=
"36
0"
/>
<switch
name=
"F5v2400-2"
x=
"1
50"
y=
"36
0"
/>
<switch
name=
"N7K-1"
x=
"3
40"
y=
"48
0"
/>
<switch
name=
"N7K-2"
x=
"1
50"
y=
"48
0"
/>
<switch
name=
"N5K-1"
x=
"3
40"
y=
"6
00"
/>
<switch
name=
"N5K-2"
x=
"1
50"
y=
"6
00"
/>
</switchs>
<connections>
<connection
from=
"QW-E8030"
to=
"CTC"
state=
"1"
>
...
...
@@ -245,17 +245,18 @@
<netTopology
name=
"宝山机房"
>
<anchors>
<anchor
name=
"CTC"
x=
"160"
y=
"70"
/>
<anchor
name=
"NH1"
x=
"20"
y=
"350"
/>
<anchor
name=
"NH2"
x=
"490"
y=
"350"
/>
<anchor
name=
"NH1"
x=
"20"
y=
"410"
/>
<anchor
name=
"NH2"
x=
"490"
y=
"410"
/>
<anchor
name=
""
x=
"20"
y=
"550"
/>
</anchors>
<switchs>
<switch
name=
"C3750G"
x=
"160"
y=
"1
5
0"
/>
<switch
name=
"F5S3600-1"
x=
"160"
y=
"2
5
0"
/>
<switch
name=
"F5S3600-2"
x=
"350"
y=
"2
5
0"
/>
<switch
name=
"H12508-1"
x=
"160"
y=
"
35
0"
/>
<switch
name=
"H12508-2"
x=
"350"
y=
"
35
0"
/>
<switch
name=
"Hadoop1"
x=
"160"
y=
"
45
0"
/>
<switch
name=
"Hadoop2"
x=
"350"
y=
"
45
0"
/>
<switch
name=
"C3750G"
x=
"160"
y=
"1
7
0"
/>
<switch
name=
"F5S3600-1"
x=
"160"
y=
"2
9
0"
/>
<switch
name=
"F5S3600-2"
x=
"350"
y=
"2
9
0"
/>
<switch
name=
"H12508-1"
x=
"160"
y=
"
41
0"
/>
<switch
name=
"H12508-2"
x=
"350"
y=
"
41
0"
/>
<switch
name=
"Hadoop1"
x=
"160"
y=
"
53
0"
/>
<switch
name=
"Hadoop2"
x=
"350"
y=
"
53
0"
/>
</switchs>
<connections>
<connection
from=
"C3750G"
to=
"CTC"
>
...
...
cat-home/src/main/webapp/images/networkMetric.jpeg
查看替换文件 @
0cbc24c1
浏览文件 @
c7ea21a4
282.2 KB
|
W:
|
H:
423.7 KB
|
W:
|
H:
2-up
Swipe
Onion skin
cat-home/src/main/webapp/js/netgraph.js
浏览文件 @
c7ea21a4
...
...
@@ -24,14 +24,14 @@ var $_netgraph = {
'
warnning
'
:
'
rgb(255,255,0)
'
,
'
serious
'
:
'
rgb(255,0,0)
'
,
},
'
conn_tooltip_offset
'
:
2
0
,
'
conn_tooltip_offset
'
:
1
0
,
'
anchor_text_size
'
:
16
,
'
anchor_text_color
'
:
'
rgb(100,100,100)
'
,
'
focus_scale
'
:
2
,
'
tooltip_width
'
:
2
20
,
'
tooltip_width
'
:
2
75
,
},
topos
:
{
...
...
@@ -121,10 +121,14 @@ var $_netgraph = {
continue
;
}
var
inData
,
outData
,
state
,
fill
;
var
inData
,
outData
,
state
,
fill
,
indiscards
,
outdiscards
,
inerrors
,
outerrors
;
inData
=
cn
[
'
insum
'
];
outData
=
cn
[
'
outsum
'
];
state
=
cn
[
'
state
'
];
indiscards
=
cn
[
'
indiscards
'
];
outdiscards
=
cn
[
'
outdiscards
'
];
inerrors
=
cn
[
'
inerrors
'
];
outerrors
=
cn
[
'
outerrors
'
];
if
(
inData
==
undefined
)
{
inData
=
0
;
}
...
...
@@ -140,6 +144,18 @@ var $_netgraph = {
else
{
fill
=
this
.
setting
.
conn_color
.
normal
;
}
if
(
indiscards
==
undefined
)
{
indiscards
=
0
;
}
if
(
outdiscards
==
undefined
)
{
outdiscards
=
0
;
}
if
(
inerrors
==
undefined
)
{
inerrors
=
0
;
}
if
(
outerrors
==
undefined
)
{
outerrors
=
0
;
}
var
f_anchor
=
0
;
var
t_anchor
=
0
;
...
...
@@ -164,11 +180,11 @@ var $_netgraph = {
}
if
(
!
f_anchor
&&
!
t_anchor
)
{
conn
[
id
]
=
{
'
x1
'
:
x1
,
'
y1
'
:
y1
,
'
x2
'
:(
x1
+
x2
)
/
2
,
'
y2
'
:(
y1
+
y2
)
/
2
,
'
data
'
:[
inData
,
outData
],
'
name
'
:
to
,
'
fill
'
:
fill
};
conn
[
id
]
=
{
'
x1
'
:
x1
,
'
y1
'
:
y1
,
'
x2
'
:(
x1
+
x2
)
/
2
,
'
y2
'
:(
y1
+
y2
)
/
2
,
'
data
'
:[
inData
,
outData
,
indiscards
,
outdiscards
,
inerrors
,
outerrors
],
'
name
'
:
to
,
'
fill
'
:
fill
};
sw
[
from
][
'
conn
'
].
push
(
id
);
}
else
if
(
!
f_anchor
)
{
conn
[
id
]
=
{
'
x1
'
:
x1
,
'
y1
'
:
y1
,
'
x2
'
:(
x1
+
x2
*
2
)
/
3
,
'
y2
'
:(
y1
+
y2
*
2
)
/
3
,
'
data
'
:[
inData
,
outData
],
'
name
'
:
to
,
'
fill
'
:
fill
};
conn
[
id
]
=
{
'
x1
'
:
x1
,
'
y1
'
:
y1
,
'
x2
'
:(
x1
+
x2
*
2
)
/
3
,
'
y2
'
:(
y1
+
y2
*
2
)
/
3
,
'
data
'
:[
inData
,
outData
,
indiscards
,
outdiscards
,
inerrors
,
outerrors
],
'
name
'
:
to
,
'
fill
'
:
fill
};
sw
[
from
][
'
conn
'
].
push
(
id
);
}
}
...
...
@@ -182,14 +198,16 @@ var $_netgraph = {
var
mx
=
(
d
.
x1
+
d
.
x2
)
/
2
;
var
my
=
(
d
.
y1
+
d
.
y2
)
/
2
;
var
x
,
y
;
if
(
mx
<=
300
)
if
(
mx
<=
this
.
setting
.
tooltip_width
)
x
=
mx
+
this
.
setting
.
conn_tooltip_offset
;
else
x
=
mx
-
this
.
setting
.
tooltip_width
-
this
.
setting
.
conn_tooltip_offset
;
y
=
my
+
this
.
setting
.
conn_tooltip_offset
;
y
=
my
-
this
.
setting
.
conn_tooltip_offset
;
var
tip
=
[];
tip
.
push
(
'
[from
'
+
d
[
'
name
'
]
+
'
]-[in]:
'
+
this
.
decorateNumber
(
d
[
'
data
'
][
0
]));
tip
.
push
(
'
[from
'
+
d
[
'
name
'
]
+
'
]-[in-discard-err]:
'
+
this
.
decorateNumber
(
d
[
'
data
'
][
2
])
+
'
,
'
+
this
.
decorateNumber
(
d
[
'
data
'
][
4
]));
tip
.
push
(
'
[to
'
+
d
[
'
name
'
]
+
'
]-[out]:
'
+
this
.
decorateNumber
(
d
[
'
data
'
][
1
]));
tip
.
push
(
'
[to
'
+
d
[
'
name
'
]
+
'
]-[out-discard-err]:
'
+
this
.
decorateNumber
(
d
[
'
data
'
][
3
])
+
'
,
'
+
this
.
decorateNumber
(
d
[
'
data
'
][
5
]));
this
.
show_tooltip
(
wrapper
,
x
,
y
,
tip
);
var
conn
=
document
.
getElementById
(
wrapper
+
'
-
'
+
id
);
...
...
@@ -211,7 +229,9 @@ var $_netgraph = {
for
(
var
i
in
topo
.
data
[
'
switchs
'
][
id
].
conn
)
{
conn
=
topo
.
data
[
'
conn
'
][
topo
.
data
[
'
switchs
'
][
id
].
conn
[
i
]];
tip
.
push
(
'
[from
'
+
conn
[
'
name
'
]
+
'
]-[in]:
'
+
this
.
decorateNumber
(
conn
[
'
data
'
][
0
]));
tip
.
push
(
'
[from
'
+
conn
[
'
name
'
]
+
'
]-[in-discard-err]:
'
+
this
.
decorateNumber
(
conn
[
'
data
'
][
2
])
+
'
,
'
+
this
.
decorateNumber
(
conn
[
'
data
'
][
4
]));
tip
.
push
(
'
[to
'
+
conn
[
'
name
'
]
+
'
]-[out]:
'
+
this
.
decorateNumber
(
conn
[
'
data
'
][
1
]));
tip
.
push
(
'
[to
'
+
conn
[
'
name
'
]
+
'
]-[out-discard-err]:
'
+
this
.
decorateNumber
(
conn
[
'
data
'
][
3
])
+
'
,
'
+
this
.
decorateNumber
(
conn
[
'
data
'
][
5
]));
}
this
.
show_tooltip
(
wrapper
,
x
,
y
,
tip
);
...
...
@@ -296,6 +316,10 @@ var $_netgraph = {
ty
+=
20
;
}
if
(
y
>
height
)
{
y
-=
height
;
}
this
.
setAttrValues
(
g
,
{
'
visibility
'
:
'
visible
'
,
'
transform
'
:
'
translate(
'
+
x
+
'
,
'
+
y
+
'
)
'
,
'
opacity
'
:
1
});
},
...
...
cat-home/src/main/webapp/jsp/report/home/exceptionDocument.jsp
浏览文件 @
c7ea21a4
...
...
@@ -22,8 +22,21 @@
<td>
认定为Error级别的阈值,
<span
class=
"text-error"
>
必需,
</span>
当异常数超过该阈值,做Error状态设置,做相应警Error告警
</td>
</tr>
</table>
<br/>
<h4
class=
"text-success"
>
2. 异常过滤
<a
href=
"/cat/s/config?op=exceptionExcludes"
>
配置
</a></h4>
<p>
对于不想进行异常告警的异常,可以在异常过滤配置里进行设置
</p>
<table
style=
"width:90%"
class=
"table table-striped table-bordered table-condensed"
>
<tr><th
width=
"20%"
>
参数
</th><th>
说明
</th></tr>
<tr>
<td>
域名
</td>
<td>
项目组名称,
<span
class=
"text-error"
>
必需,
</span>
当设置为“Default”时,适用于所有项目组。
</td>
<tr>
<td>
异常名称
</td>
<td>
具体异常名称,
<span
class=
"text-error"
>
必需,
</span>
当设置为“All”时,是过滤当前项目组所有异常;当设置为特定异常名称时,仅过滤当前项目组所有同名的异常
</td>
</tr>
</table>
</br>
<h4
class=
"text-success"
>
2
. 异常告警
</h4>
<h4
class=
"text-success"
>
3
. 异常告警
</h4>
<h5>
(1) 实时监测当前的应用异常情况,对于超过阈值设置的异常,Warning级别的仅发送邮件,Error级别的同时发送邮件和短信。
</h5>
<h5>
(2) 监测异常并发送警报的周期为:
<span
class=
"text-error"
>
一分钟
</span></h5>
<h5>
(3) 异常判定规则
</h5>
...
...
@@ -37,8 +50,10 @@ b) 当监测到特定异常总数,达到该项目组设定的该异常阈值
如果特定异常在一个周期内出现多次超过阈值的情况,不会立即告警,而是周期结束时根据异常总和大小来判定并告警,故一个周期内最多只发送该告警一次。
</xmp>
</br>
<h4
class=
"text-success"
>
3
. 异常告警统计
<a
href=
"/cat/r/statistics?domain=Cat&op=alert"
>
报表
</a></h4>
<h4
class=
"text-success"
>
4
. 异常告警统计
<a
href=
"/cat/r/statistics?domain=Cat&op=alert"
>
报表
</a></h4>
<p>
a) 将异常告警的情况进行统计,按Error警告的次数从大到小进行排序,呈现出错警告及排行的详细情况。
</p>
<p/>
<p>
b) 点击“
<a
href=
"/cat/r/statistics?domain=Cat&op=alert"
>
Detail
</a>
”查看详细异常情况
</p>
</br>
\ No newline at end of file
<br/>
<h4
class=
"text-success"
>
5. 异常告警
<a
href=
"/cat/s/config?op=projects"
>
邮件配置
</a></h4>
<p>
针对每个项目组,可以进行组邮件和联系人的配置,CAT将根据此配置进行邮件的发送。
</p>
cat-home/src/main/webapp/jsp/report/home/integratingBusiness.jsp
浏览文件 @
c7ea21a4
...
...
@@ -43,7 +43,7 @@
<p>
接口调用请求说明
</p>
<pre>
http请求方式: GET(请使用http协议)
http://cat.dianpingoa.com/cat/r/
systemM
onitor?
http://cat.dianpingoa.com/cat/r/
m
onitor?
</pre>
<p>
参数说明
</p>
<table
style=
"width:90%"
class=
"table table-striped table-bordered table-condensed"
>
...
...
cat-home/src/main/webapp/jsp/report/home/integratingDocument.jsp
浏览文件 @
c7ea21a4
...
...
@@ -5,7 +5,7 @@
<dl>
<dt><h5
class=
"text-success"
>
1.Web.xml中新增filter
</h5></dt>
<dd><p
class=
"detailContent"
>
注:如果项目是对外不提供URL访问,比如GroupService,仅仅提供Pigeon服务,则不需要。
</p>
<
p
class=
"text-error detailContent"
><strong>
Filter放在url-rewrite-filter 之后的第一个。
</strong></p
>
<
h5
class=
"text-error detailContent"
><strong>
Filter放在url-rewrite-filter 之后的第一个,如果不是会导致URL的个数无限多,比如search/1/2,search/2/3等等,无法监控,后端存储压力也变大。
</strong></h5
>
<xmp
class=
"well"
>
<filter>
<filter-name>
cat-filter
</filter-name>
...
...
cat-home/src/main/webapp/jsp/report/home/networkDocument.jsp
浏览文件 @
c7ea21a4
...
...
@@ -18,13 +18,30 @@
<img
class=
"img-polaroid"
width=
'60%'
src=
"${model.webapp}/images/networkMetric.jpeg"
/>
<p/>
<p>
(1) 关于网络监控的监控指标的确定以及产品线配置请参考业务监控文档
</p>
<p>
(2) 对于网络监控中的指标选取及Key格式规定
</p>
<xmp
class=
"well"
>
a) 每个端口的进出流量汇总
[端口名字] + [-in] --> 进端口流量KEY
[端口名字] + [-out] --> 出端口流量KEY
b) 每个端口的错包丢包情况汇总
[端口名字] + [-inerrors] --> 进端口错包数KEY
[端口名字] + [-outerrors] --> 出端口错包数KEY
[端口名字] + [-indiscards] --> 进端口丢包数KEY
[端口名字] + [-outdiscards] --> 出端口丢包数KEY
</xmp>
<p>
(2) 对于网络的监控代码埋点,仅支持业务监控代码埋点中的HTTP API调用方式。
</p>
<p>
(3) 对于需要在网络监控显示的指标,需对产品线做显示到网络大盘配置,如下图
</p>
<p
class=
"text-error"
>
注意:url中项目组名字(group)必须以"switch-"或"f5-"作为开头
</p>
<xmp
class=
"well"
>
如:http://cat.dianpingoa.com/cat/r/monitor?group=f5-2400
&
domain=2400-1-dianping-com
&
key=Ethernet1/1-1-in
&
op=sum
&
sum=100
</xmp>
<p>
(3) 对于需要在网络监控显示的指标,需对产品线做显示到
<a
href=
"/cat/s/config?op=topologyProductLines"
>
网络大盘配置
</a>
,如下图
</p>
<img
class=
"img-polaroid"
width=
'40%'
src=
"${model.webapp}/images/networkProductLine.jpeg"
/>
</br>
</br>
<h4
class=
"text-success"
>
3. 监控汇总定制
</h4>
<p>
除了默认汇总展示之外,用户可以根据不同需求对网络指标进行汇总定制,在
业务指标汇总
中填写配置信息。
</p>
<p>
除了默认汇总展示之外,用户可以根据不同需求对网络指标进行汇总定制,在
<a
href=
"/cat/s/config?op=metricAggregationConfigUpdate"
>
业务指标汇总
</a>
中填写配置信息。
</p>
<h5>
(1) 配置说明
</h5>
<table
style=
"width:90%"
class=
"table table-striped table-bordered table-condensed"
>
<tr><th
width=
"20%"
>
节点
</th><th
width=
"20%"
>
属性
</th><th>
说明
</th></tr>
...
...
@@ -94,35 +111,43 @@
<td>
是否显示基线,
<span
class=
"text-error"
>
非必需,
</span>
,可选项为true、false,默认继承自父节点的base-line值
</td>
</tr>
</table>
<h5>
(2)
指标汇总配置
实例如下:
</h5>
<h5>
(2)
<a
href=
"/cat/s/config?op=metricAggregationConfigUpdate"
>
指标汇总配置
</a>
实例如下:
</h5>
<xmp
class=
"well"
>
<metric-aggregation-config>
<metric-aggregation-group
id=
"f5-2400-1-dianping-com"
type=
"Metric"
display=
"network"
>
<metric-aggregation
id=
"f5-2400-1-in"
display-type=
"count"
base-line=
"false"
operation=
"{data}*60+100"
>
<metric-aggregation-group
id=
"f5-2400-1-dianping-com
-flow
"
type=
"Metric"
display=
"network"
>
<metric-aggregation
id=
"f5-2400-1-in
-flow
"
display-type=
"count"
base-line=
"false"
operation=
"{data}*60+100"
>
<metric-aggregation-item
domain=
"Domain1"
key=
"1/1-1-in"
operation=
"{data}*60/100+100"
/>
<metric-aggregation-item
domain=
"Domain2"
key=
"1/1-2-in"
/>
<metric-aggregation-item
domain=
"Domain3"
key=
"1/1-3-in"
/>
<metric-aggregation-item
domain=
"Domain4"
key=
"1/1-4-in"
/>
</metric-aggregation>
<metric-aggregation
id=
"f5-2400-1-out"
domain=
"Domain"
display=
"sum"
base-line=
"true"
>
<metric-aggregation
id=
"f5-2400-1-out
-flow
"
domain=
"Domain"
display=
"sum"
base-line=
"true"
>
<metric-aggregation-item
domain=
"Domain2"
key=
"1/1-1-out"
display-type=
"count"
base-line=
"false"
/>
<metric-aggregation-item
key=
"1/1-2-out"
/>
<metric-aggregation-item
key=
"1/1-3-out"
/>
<metric-aggregation-item
key=
"1/1-4-out"
/>
</metric-aggregation>
</metric-aggregation-group>
<metric-aggregation-group
id=
"f5-2500-1-dianping-com"
domain=
"DmainAll"
type=
"Metric"
display=
"network"
>
<metric-aggregation
id=
"f5-2500-1-in"
display-type=
"sum"
title=
"switch"
>
<metric-aggregation-item
key=
"1/1-1-in"
/>
<metric-aggregation-item
key=
"1/1-2-in"
/>
<metric-aggregation-item
key=
"1/1-3-in"
/>
<metric-aggregation-item
key=
"1/1-4-in"
/>
<metric-aggregation-group
id=
"f5-2400-1-dianping-com-packages"
domain=
"DmainAll"
type=
"Metric"
display=
"network"
>
<metric-aggregation
id=
"f5-2400-1-in-packages"
display-type=
"sum"
title=
"switch"
>
<metric-aggregation-item
key=
"1/1-1-inerrors"
/>
<metric-aggregation-item
key=
"1/1-2-inerrors"
/>
<metric-aggregation-item
key=
"1/1-3-inerrors"
/>
<metric-aggregation-item
key=
"1/1-4-inerrors"
/>
<metric-aggregation-item
key=
"1/1-1-indiscards"
/>
<metric-aggregation-item
key=
"1/1-2-indiscards"
/>
<metric-aggregation-item
key=
"1/1-3-indiscards"
/>
<metric-aggregation-item
key=
"1/1-4-indiscards"
/>
</metric-aggregation>
<metric-aggregation
id=
"f5-2500-1-out"
display-type=
"sum"
>
<metric-aggregation-item
key=
"1/1-1-out"
/>
<metric-aggregation-item
key=
"1/1-2-out"
/>
<metric-aggregation-item
key=
"1/1-3-out"
/>
<metric-aggregation-item
key=
"1/1-4-out"
/>
<metric-aggregation
id=
"f5-2400-1-out-packages"
display-type=
"sum"
>
<metric-aggregation-item
key=
"1/1-1-outerrors"
/>
<metric-aggregation-item
key=
"1/1-2-outerrors"
/>
<metric-aggregation-item
key=
"1/1-3-outerrors"
/>
<metric-aggregation-item
key=
"1/1-4-outerrors"
/>
<metric-aggregation-item
key=
"1/1-1-outdiscards"
/>
<metric-aggregation-item
key=
"1/1-2-outdiscards"
/>
<metric-aggregation-item
key=
"1/1-3-outdiscards"
/>
<metric-aggregation-item
key=
"1/1-4-outdiscards"
/>
</metric-aggregation>
</metric-aggregation-group>
</metric-aggregation-config>
...
...
cat-home/src/main/webapp/jsp/report/network.jsp
已删除
100644 → 0
浏览文件 @
0cbc24c1
<%@ page
contentType=
"text/html; charset=utf-8"
%>
<jsp:useBean
id=
"ctx"
type=
"com.dianping.cat.report.page.network.Context"
scope=
"request"
/>
<jsp:useBean
id=
"payload"
type=
"com.dianping.cat.report.page.network.Payload"
scope=
"request"
/>
<jsp:useBean
id=
"model"
type=
"com.dianping.cat.report.page.network.Model"
scope=
"request"
/>
View of network page under report
\ No newline at end of file
cat-home/src/main/webapp/jsp/report/network/nettopology.jsp
浏览文件 @
c7ea21a4
...
...
@@ -125,7 +125,7 @@
.topology
{
text-align
:
center
;
margin
:
20px
0
;
height
:
6
40px
;
height
:
8
40px
;
float
:
left
;
}
...
...
cat-home/src/main/webapp/jsp/report/userMonitor.jsp
浏览文件 @
c7ea21a4
<%@ page
contentType=
"text/html; charset=utf-8"
%>
<%@ page
contentType=
"text/html; charset=utf-8"
%>
<%@ taglib
prefix=
"a"
uri=
"/WEB-INF/app.tld"
%>
<%@ taglib
prefix=
"w"
uri=
"http://www.unidal.org/web/core"
%>
<%@ taglib
prefix=
"c"
uri=
"http://java.sun.com/jsp/jstl/core"
%>
<%@ taglib
prefix=
"res"
uri=
"http://www.unidal.org/webres"
%>
<jsp:useBean
id=
"ctx"
type=
"com.dianping.cat.report.page.userMonitor.Context"
scope=
"request"
/>
<jsp:useBean
id=
"payload"
type=
"com.dianping.cat.report.page.userMonitor.Payload"
scope=
"request"
/>
<jsp:useBean
id=
"model"
type=
"com.dianping.cat.report.page.userMonitor.Model"
scope=
"request"
/>
<jsp:useBean
id=
"ctx"
type=
"com.dianping.cat.report.page.userMonitor.Context"
scope=
"request"
/>
<jsp:useBean
id=
"payload"
type=
"com.dianping.cat.report.page.userMonitor.Payload"
scope=
"request"
/>
<jsp:useBean
id=
"model"
type=
"com.dianping.cat.report.page.userMonitor.Model"
scope=
"request"
/>
<a:body>
<res:useCss
value=
"
${
res
.
css
.
local
[
'select2.css'
]
}
"
target=
"head-css"
/>
<res:useJs
value=
"
${
res
.
js
.
local
[
'select2.min.js'
]
}
"
target=
"head-js"
/>
<res:useJs
value=
"
${
res
.
js
.
local
[
'bootstrap-datetimepicker.min.js'
]
}
"
target=
"head-js"
/>
<res:useJs
value=
"
${
res
.
js
.
local
[
'baseGraph.js'
]
}
"
target=
"head-js"
/>
<res:useJs
value=
"
${
res
.
js
.
local
[
'bootstrap-datetimepicker.min.js'
]
}
"
target=
"head-js"
/>
<res:useJs
value=
"
${
res
.
js
.
local
[
'baseGraph.js'
]
}
"
target=
"head-js"
/>
<script
type=
"text/javascript"
>
function
query
(){
var
url
=
$
(
"
#url
"
).
val
();
...
...
@@ -50,7 +54,11 @@
}
else
{
opt
.
html
(
value
[
prop
].
city
);
}
opt
.
val
(
value
[
prop
].
province
+
'
-
'
+
value
[
prop
].
city
);
if
(
value
[
prop
].
province
==
''
){
opt
.
val
(
''
);
}
else
{
opt
.
val
(
value
[
prop
].
province
+
'
-
'
+
value
[
prop
].
city
);
}
opt
.
appendTo
(
select
);
}
}
...
...
@@ -59,8 +67,13 @@
for
(
var
prop
in
cityData
)
{
if
(
cityData
.
hasOwnProperty
(
prop
))
{
var
opt
=
$
(
'
<option />
'
);
if
(
prop
==
''
){
opt
.
html
(
'
ALL
'
);
}
else
{
opt
.
html
(
prop
);
}
opt
.
val
(
prop
);
opt
.
html
(
prop
);
opt
.
appendTo
(
select
);
}
}
...
...
@@ -68,7 +81,6 @@
var
city
=
'
${payload.city}
'
;
var
array
=
city
.
split
(
'
-
'
);
console
.
log
(
array
[
0
]
+
"
====
"
+
array
[
1
]
+
"
====
"
+
array
.
length
);
$
(
'
#province
'
).
val
(
array
[
0
]);
change
();
...
...
@@ -82,6 +94,10 @@
var
data
=
$
{
item
.
jsonString
};
graphMetricChart
(
document
.
getElementById
(
'
${item.id}
'
),
data
);
</c:forEach>
<c:forEach
var=
"item"
items=
"
${
model
.
pieCharts
}
"
varStatus=
"status"
>
var
data
=
$
{
item
.
jsonString
};
graphPieChart
(
document
.
getElementById
(
'
${item.title}
'
),
data
);
</c:forEach>
</c:when>
<c:otherwise>
graphMetricChart
(
document
.
getElementById
(
'
lineChart
'
),
$
{
model
.
lineChart
.
jsonString
});
...
...
@@ -93,77 +109,81 @@
<div
class=
"report"
>
<table>
<tr>
<th
class=
"left"
>
URL:
<select
name=
"url"
id=
"url"
style=
"width:400px;"
>
<c:forEach
var=
"item"
items=
"
${
model
.
pattermItems
}
"
>
<option
value=
"${item.name}"
>
${item.pattern}
</option>
</c:forEach>
</select>
省份
<select
style=
"width:100px;"
name=
"province"
id=
"province"
>
</select>
城市
<select
style=
"width:100px;"
name=
"city"
id=
"city"
>
</select>
运营商
<select
style=
"width:120px;"
name=
"channel"
id=
"channel"
>
<option
value=
""
>
ALL
</option>
<option
value=
"中国电信"
>
中国电信
</option>
<option
value=
"中国移动"
>
中国移动
</option>
<option
value=
"中国联通"
>
中国联通
</option>
<option
value=
"中国铁通"
>
中国铁通
</option>
<option
value=
"其他"
>
其他
</option>
</select>
查询类型
<select
style=
"width:120px;"
name=
"type"
id=
"type"
>
<option
value=
"info"
>
访问情况
</option>
<option
value=
"httpStatus"
>
HttpStatus
</option>
<option
value=
"errorCode"
>
ErrorCode
</option>
</select>
</th>
</tr>
<tr><th
class=
"right"
>
开始时间
<div
id=
"datetimepicker1"
class=
"input-append date"
style=
"margin-bottom:0px;"
>
<input
id=
"startTime"
name=
"startTime"
style=
"height:30px;width:150px;"
data-format=
"yyyy-MM-dd hh:mm"
type=
"text"
></input>
<span
class=
"add-on"
>
<i
data-time-icon=
"icon-time"
data-date-icon=
"icon-calendar"
>
</i>
</span>
</div>
结束时间
<div
id=
"datetimepicker2"
class=
"input-append date"
style=
"margin-bottom:0px;"
>
<input
id=
"endTime"
name=
"endTime"
style=
"height:30px;width:150px;"
data-format=
"yyyy-MM-dd hh:mm"
type=
"text"
></input>
<span
class=
"add-on"
>
<i
data-time-icon=
"icon-time"
data-date-icon=
"icon-calendar"
>
</i>
</span>
</div>
<input
class=
"btn btn-primary "
value=
" 查询 "
onclick=
"query()"
type=
"submit"
></div>
<th
class=
"left"
>
URL:
<select
name=
"url"
id=
"url"
style=
"width: 400px;"
>
<c:forEach
var=
"item"
items=
"
${
model
.
pattermItems
}
"
>
<option
value=
"${item.name}"
>
${item.pattern}
</option>
</c:forEach>
</select>
省份
<select
style=
"width: 100px;"
name=
"province"
id=
"province"
>
</select>
城市
<select
style=
"width: 100px;"
name=
"city"
id=
"city"
>
</select>
运营商
<select
style=
"width: 120px;"
name=
"channel"
id=
"channel"
>
<option
value=
""
>
ALL
</option>
<option
value=
"中国电信"
>
中国电信
</option>
<option
value=
"中国移动"
>
中国移动
</option>
<option
value=
"中国联通"
>
中国联通
</option>
<option
value=
"中国铁通"
>
中国铁通
</option>
<option
value=
"其他"
>
其他
</option>
</select>
查询类型
<select
style=
"width: 120px;"
name=
"type"
id=
"type"
>
<option
value=
"info"
>
访问情况
</option>
<option
value=
"httpStatus"
>
HttpStatus
</option>
<option
value=
"errorCode"
>
ErrorCode
</option>
</select>
</th>
</tr>
<tr>
<th
class=
"right"
>
开始时间
<div
id=
"datetimepicker1"
class=
"input-append date"
style=
"margin-bottom: 0px;"
>
<input
id=
"startTime"
name=
"startTime"
style=
"height: 30px; width: 150px;"
data-format=
"yyyy-MM-dd hh:mm"
type=
"text"
></input>
<span
class=
"add-on"
>
<i
data-time-icon=
"icon-time"
data-date-icon=
"icon-calendar"
>
</i>
</span>
</div>
结束时间
<div
id=
"datetimepicker2"
class=
"input-append date"
style=
"margin-bottom: 0px;"
>
<input
id=
"endTime"
name=
"endTime"
style=
"height: 30px; width: 150px;"
data-format=
"yyyy-MM-dd hh:mm"
type=
"text"
></input>
<span
class=
"add-on"
>
<i
data-time-icon=
"icon-time"
data-date-icon=
"icon-calendar"
>
</i>
</span>
</div>
<input
class=
"btn btn-primary "
value=
" 查询 "
onclick=
"query()"
type=
"submit"
>
</div>
</th>
</tr>
</table>
<c:choose>
<c:when
test=
"
${
payload
.
type
eq
'info'
}
"
>
<div>
<c:forEach
var=
"item"
items=
"
${
model
.
lineCharts
}
"
varStatus=
"status"
>
<div
style=
"float:left;"
>
<div
id=
"${item.id}"
style=
"width:450px;height:380px;"
></div>
</div>
</c:forEach>
<div
style=
"float: left;"
>
<div
id=
"${item.id}"
style=
"width:450px; height:380px;"
></div>
</div>
</c:forEach></div>
<div>
<c:forEach
var=
"item"
items=
"
${
model
.
pieCharts
}
"
varStatus=
"status"
>
<div
style=
"float: left;"
>
<h5
class=
"text-center"
>
${item.title}
</h5>
<div
id=
"${item.title}"
style=
"width:600px; height:450px;"
></div>
</div>
</c:forEach></div>
</c:when>
<c:otherwise>
<div
class=
"row-fluid"
>
<div
class=
"span6"
>
<div
id=
"lineChart"
style=
"width:550px;height:400px;"
></div>
<div
class=
"row-fluid"
>
<div
class=
"span6"
>
<div
id=
"lineChart"
style=
"width:550px; height:400px;"
></div>
</div>
<div
class=
"span6"
>
<div
id=
"pieChart"
style=
"width:550px; height:400px;"
></div>
</div>
</div>
<div
class=
"span6"
>
<div
id=
"pieChart"
style=
"width:550px;height:400px;"
></div>
</div>
</div>
</c:otherwise>
</c:choose>
<table
class=
"footer"
>
<tr>
<td>
[ end ]
</td>
...
...
cat-home/src/main/webapp/jsp/system/configTree.jsp
浏览文件 @
c7ea21a4
...
...
@@ -8,6 +8,7 @@
<li
class=
"text-right"
id=
"topylogyNodeConfigList"
><a
href=
"?op=topologyGraphNodeConfigList"
><strong>
拓扑节点阀值
</strong></a></li>
<li
class=
"text-right"
id=
"topylogyEdgeConfigList"
><a
href=
"?op=topologyGraphEdgeConfigList"
><strong>
拓扑依赖阀值
</strong></a></li>
<li
class=
"text-right"
id=
"exceptionConfigList"
><a
href=
"?op=exceptionThresholds"
><strong>
异常阀值配置
</strong></a></li>
<li
class=
"text-right"
id=
"exceptionExcludeConfigList"
><a
href=
"?op=exceptionExcludes"
><strong>
异常过滤配置
</strong></a></li>
<li
class=
'nav-header'
><h4>
外部监控配置
</h4></li>
<li
class=
"text-right"
id=
"urlPatternList"
><a
href=
"?op=urlPatterns"
><strong>
URL合并规则
</strong></a></li>
<li
class=
"text-right"
id=
"aggregationList"
><a
href=
"?op=aggregations"
><strong>
JS合并规则
</strong></a></li>
...
...
cat-home/src/main/webapp/jsp/system/exceptionExclude/exceptionExclude.jsp
0 → 100644
浏览文件 @
c7ea21a4
<%@ page
contentType=
"text/html; charset=utf-8"
%>
<%@ taglib
prefix=
"a"
uri=
"/WEB-INF/app.tld"
%>
<%@ taglib
prefix=
"c"
uri=
"http://java.sun.com/jsp/jstl/core"
%>
<%@ taglib
prefix=
"res"
uri=
"http://www.unidal.org/webres"
%>
<%@ taglib
prefix=
"w"
uri=
"http://www.unidal.org/web/core"
%>
<jsp:useBean
id=
"ctx"
type=
"com.dianping.cat.system.page.config.Context"
scope=
"request"
/>
<jsp:useBean
id=
"payload"
type=
"com.dianping.cat.system.page.config.Payload"
scope=
"request"
/>
<jsp:useBean
id=
"model"
type=
"com.dianping.cat.system.page.config.Model"
scope=
"request"
/>
<a:body>
<res:useJs
value=
"
${
res
.
js
.
local
[
'jquery.validate.min.js'
]
}
"
target=
"head-js"
/>
<res:useJs
value=
"
${
res
.
js
.
local
[
'dependencyConfig.js'
]
}
"
target=
"head-js"
/>
<res:useCss
value=
"
${
res
.
css
.
local
[
'select2.css'
]
}
"
target=
"head-css"
/>
<res:useJs
value=
"
${
res
.
js
.
local
[
'select2.min.js'
]
}
"
target=
"head-js"
/>
<res:useCss
value=
"
${
res
.
css
.
local
[
'jqx.base.css'
]
}
"
target=
"head-css"
/>
<res:useJs
value=
"
${
res
.
js
.
local
[
'jqxcore.js'
]
}
"
target=
"head-js"
/>
<res:useJs
value=
"
${
res
.
js
.
local
[
'jqxbuttons.js'
]
}
"
target=
"head-js"
/>
<res:useJs
value=
"
${
res
.
js
.
local
[
'jqxscrollbar.js'
]
}
"
target=
"head-js"
/>
<res:useJs
value=
"
${
res
.
js
.
local
[
'jqxlistbox.js'
]
}
"
target=
"head-js"
/>
<res:useJs
value=
"
${
res
.
js
.
local
[
'jqxcombobox.js'
]
}
"
target=
"head-js"
/>
<script
type=
"text/javascript"
>
$
(
document
).
ready
(
function
()
{
$
(
'
#exceptionExcludeConfigList
'
).
addClass
(
'
active
'
);
$
(
"
.delete
"
).
bind
(
"
click
"
,
function
()
{
return
confirm
(
"
确定要删除此项目吗(不可恢复)?
"
);
});
var
action
=
'
${payload.action.name}
'
;
if
(
action
==
'
exceptionExcludeDelete
'
||
action
==
'
exceptionExcludeUpdateSubmit
'
){
var
state
=
'
${model.opState}
'
;
if
(
state
==
'
Success
'
){
$
(
'
#state
'
).
html
(
'
操作成功
'
);
}
else
{
$
(
'
#state
'
).
html
(
'
操作失败
'
);
}
setInterval
(
function
(){
$
(
'
#state
'
).
html
(
'
'
);
},
3000
);
}
$
(
document
).
delegate
(
'
.update,.create
'
,
'
click
'
,
function
(
e
){
var
anchor
=
this
,
el
=
$
(
anchor
);
if
(
e
.
ctrlKey
||
e
.
metaKey
){
return
true
;
}
else
{
e
.
preventDefault
();
}
$
.
ajax
({
type
:
"
get
"
,
url
:
anchor
.
href
,
success
:
function
(
response
,
textStatus
)
{
$
(
'
#myModal
'
).
html
(
response
);
$
(
'
#myModal
'
).
modal
();
$
(
"
#domainId
"
).
select2
();
exceptionValidate
();
}
});
});
});
</script>
<div>
<div
class=
"row-fluid"
>
<div
class=
"span2"
>
<%@include
file=
"../configTree.jsp"
%>
</div>
<div
class=
"span10"
>
<!-- Modal -->
<div
id=
"myModal"
class=
"modal hide fade"
tabindex=
"-1"
role=
"dialog"
aria-labelledby=
"myModalLabel"
aria-hidden=
"true"
>
</div>
<div>
<table
class=
"table table-striped table-bordered table-condensed table-hover"
id=
"contents"
width=
"100%"
>
<thead>
<tr
class=
"odd"
>
<th
width=
"25%"
>
域名
</th>
<th
width=
"65%"
>
异常名称
</th>
<th
width=
"10%"
>
操作
<a
class=
'create btn btn-primary btn-small'
href=
"?op=exceptionExcludeAdd"
>
新增
</a></th>
</tr></thead><tbody>
<c:forEach
var=
"item"
items=
"
${
model
.
exceptionExcludes
}
"
varStatus=
"status"
>
<tr
class=
"${status.index mod 2 != 0 ? 'odd' : 'even'}"
>
<td>
${item.domain}
</td>
<td>
${item.id}
</td>
<td><a
class=
'update btn btn-small btn-primary'
href=
"?op=exceptionExcludeUpdate&domain=${item.domain}&exception=${item.id}"
>
编辑
</a>
<a
class=
'delete btn btn-small btn-danger'
href=
"?op=exceptionExcludeDelete&domain=${item.domain}&exception=${item.id}"
>
删除
</a></td>
</tr>
</c:forEach></tbody>
</tbody>
</table>
</div>
</div></div></div>
</a:body>
\ No newline at end of file
cat-home/src/main/webapp/jsp/system/exceptionExclude/exceptionExcludeConfig.jsp
0 → 100644
浏览文件 @
c7ea21a4
<%@ page
contentType=
"text/html; charset=utf-8"
%>
<%@ taglib
prefix=
"a"
uri=
"/WEB-INF/app.tld"
%>
<%@ taglib
prefix=
"c"
uri=
"http://java.sun.com/jsp/jstl/core"
%>
<script
type=
"text/javascript"
>
$
(
document
).
ready
(
function
()
{
var
source
=
new
Array
();
source
=
"
${model.exceptionList}
"
.
replace
(
/
[\[\]]
/g
,
''
).
split
(
'
,
'
);
if
(
document
.
getElementById
(
"
jqxcombobox
"
))
{
$
(
"
#jqxcombobox
"
).
jqxComboBox
({
source
:
source
,
selectedIndex
:
0
,
width
:
'
200px
'
,
height
:
'
25px
'
});
}
});
function
setWidth
(){
var
sel
=
document
.
getElementById
(
"
domainId
"
);
sel
.
style
.
width
=
((
sel
.
offsetWidth
<
200
)
?
'
200
'
:
'
auto
'
);
}
</script>
<form
name=
"exceptionConfig"
id=
"form"
method=
"post"
action=
"${model.pageUri}?op=exceptionExcludeUpdateSubmit"
>
<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"
>
<c:set
var=
"action"
value=
"exceptionExcludeUpdate"
/>
<tr>
<td
style=
"text-align:right"
class=
"text-success"
>
项目名称
</td>
<td>
<c:choose>
<c:when
test=
"
${
payload
.
action
.
name
eq
action
}
"
>
<input
name=
"exceptionExclude.domain"
value=
"${model.exceptionExclude.domain}"
/>
</c:when>
<c:otherwise>
<select
name=
"exceptionExclude.domain"
id=
"domainId"
style=
"width:200px;"
>
<c:forEach
var=
"item"
items=
"
${
model
.
domainList
}
"
>
<option
value=
"${item}"
>
${item}
</option>
</c:forEach>
</select>
</c:otherwise>
</c:choose>
</td>
</tr>
<tr>
<td
style=
"text-align:right"
class=
"text-success"
>
异常名称
</td>
<td>
<c:choose>
<c:when
test=
"
${
payload
.
action
.
name
eq
action
}
"
>
<input
name=
"exceptionExclude.id"
value=
"${model.exceptionExclude.id}"
/>
</c:when>
<c:otherwise>
<div
id=
"jqxcombobox"
name=
'exceptionExclude.id'
>
</div>
</c:otherwise>
</c:choose>
</td>
</tr>
<tr>
<td
colspan=
'2'
style=
"text-align:center"
><input
class=
'btn btn-primary'
id=
"addOrUpdateExceptionConfigSubmit"
type=
"submit"
name=
"submit"
value=
"提交"
/></td>
</tr>
</table>
</form>
\ No newline at end of file
cat-home/src/main/webapp/jsp/system/exception/exceptionThreshold.jsp
→
cat-home/src/main/webapp/jsp/system/exception
Threshold
/exceptionThreshold.jsp
浏览文件 @
c7ea21a4
文件已移动
cat-home/src/main/webapp/jsp/system/exception/exceptionThresholdConfig.jsp
→
cat-home/src/main/webapp/jsp/system/exception
Threshold
/exceptionThresholdConfig.jsp
浏览文件 @
c7ea21a4
文件已移动
cat-home/src/main/webapp/jsp/system/metric/metricConfigs.jsp
浏览文件 @
c7ea21a4
...
...
@@ -100,7 +100,9 @@
<th
width=
"8%"
><h5
class=
'text-center'
>
显示次数
</h5></th>
<th
width=
"8%"
><h5
class=
'text-center'
>
显示平均值
</h5></th>
<th
width=
"8%"
><h5
class=
'text-center'
>
显示总和
</h5></th>
<th
width=
"13%"
><h5
class=
'text-center'
>
操作
<a
class=
"btn update btn-primary btn-small"
href=
"?op=metricConfigAdd&metricKey=${config.metricKey}&domain=${config.domain}&productLineName=${key}"
>
新增
</a></h5></th>
<th
width=
"13%"
><h5
class=
'text-center'
>
操作
<%-- <a class="btn update btn-primary btn-small" href="?op=metricConfigAdd&metricKey=${config.metricKey}&domain=${config.domain}&productLineName=${key}">新增</a>
--%>
</h5></th>
</tr>
<c:forEach
var=
"config"
items=
"
${
value
}
"
>
<tr>
...
...
cat-home/src/main/webapp/jsp/system/productLine/topologyProductLineAdd.jsp
浏览文件 @
c7ea21a4
...
...
@@ -23,7 +23,7 @@
<input
type=
"hidden"
name=
"op"
value=
"topologyProductLineAddSubmit"
/>
<table
class=
"table table-striped table-bordered table-condensed"
>
<tr>
<td
style=
"width:2
0
%;text-align: right"
class=
"text-success"
>
产品线名称(全英文)
</td>
<td
style=
"width:2
5
%;text-align: right"
class=
"text-success"
>
产品线名称(全英文)
</td>
<td><input
name=
"productLine.id"
value=
"${model.productLine.id}"
required
/>
<input
name=
"type"
value=
"${payload.type}"
type=
"hidden"
/>
...
...
@@ -81,7 +81,7 @@
</c:choose></td>
</tr>
<tr>
<td
style=
"text-align: right"
class=
"text-success"
>
是否显示到
业务网络大盘
</td>
<td
style=
"text-align: right"
class=
"text-success"
>
是否显示到
网络监控
</td>
<td><c:choose>
<c:when
test=
"
${
model
.
productLine
.
networkDashboard
}
"
>
<input
type=
"radio"
name=
"productLine.networkDashboard"
value=
"true"
checked
/>
是
...
...
@@ -93,6 +93,19 @@
</c:otherwise>
</c:choose></td>
</tr>
<tr>
<td
style=
"text-align: right"
class=
"text-success"
>
是否显示到系统监控
</td>
<td><c:choose>
<c:when
test=
"
${
model
.
productLine
.
systemMonitorDashboard
}
"
>
<input
type=
"radio"
name=
"productLine.systemMonitorDashboard"
value=
"true"
checked
/>
是
<input
type=
"radio"
name=
"productLine.systemMonitorDashboard"
value=
"false"
/>
否
</c:when>
<c:otherwise>
<input
type=
"radio"
name=
"productLine.systemMonitorDashboard"
value=
"true"
/>
是
<input
type=
"radio"
name=
"productLine.systemMonitorDashboard"
value=
"false"
checked
/>
否
</c:otherwise>
</c:choose></td>
</tr>
<tr>
<td
style=
"text-align: right"
class=
"text-success"
>
是否显示到外部监控
</td>
<td><c:choose>
...
...
cat-home/src/main/webapp/jsp/system/productLine/topologyProductLines.jsp
浏览文件 @
c7ea21a4
...
...
@@ -73,24 +73,27 @@
<th
width=
"10%"
>
产品线
</th>
<th
width=
"10%"
>
标题
</th>
<th
width=
"5%"
>
顺序
</th>
<th
width=
"5%"
>
错误监控
</th>
<th
width=
"5%"
>
业务监控
</th>
<th
width=
"5%"
>
网络监控
</th>
<th
width=
"5%"
>
外部监控
</th>
<th
width=
"45%"
>
项目列表
</th>
<th
width=
"5%"
>
应用监控
</th>
<th
width=
"5%"
>
网络监控
</th>
<th
width=
"5%"
>
系统监控
</th>
<th
width=
"40%"
>
项目列表
</th>
<th
width=
"10%"
>
操作
<a
href=
"?op=topologyProductLineAdd&type=${type}"
class=
'update btn btn-primary btn-small'
>
新增
</a></th>
</tr>
<c:forEach
var=
"item"
items=
"
${
listItem
.
value
}
"
varStatus=
"status"
>
<tr><td>
${item.id}
</td><td>
${item.title}
</td>
<td>
${item.order}
</td>
<td><c:if
test=
"
${
item
.
dashboard
}
"
><span
class=
"text-error"
><strong>
是
</strong></span></c:if>
<c:if
test=
"
${
!
item
.
dashboard
}
"
><span><strong>
否
</strong></span></c:if>
</td>
<td><c:if
test=
"
${
item
.
metricDashboard
}
"
><span
class=
"text-error"
><strong>
是
</strong></span></c:if>
<c:if
test=
"
${
!
item
.
metricDashboard
}
"
><span><strong>
否
</strong></span></c:if>
</td>
<td><c:if
test=
"
${
item
.
networkDashboard
}
"
><span
class=
"text-error"
><strong>
是
</strong></span></c:if>
<c:if
test=
"
${
!
item
.
networkDashboard
}
"
><span><strong>
否
</strong></span></c:if>
</td>
<td><c:if
test=
"
${
item
.
userMonitorDashboard
}
"
><span
class=
"text-error"
><strong>
是
</strong></span></c:if>
<c:if
test=
"
${
!
item
.
userMonitorDashboard
}
"
><span><strong>
否
</strong></span></c:if>
</td>
<td><c:if
test=
"
${
item
.
applicationDashboard
}
"
><span
class=
"text-error"
><strong>
是
</strong></span></c:if>
<c:if
test=
"
${
!
item
.
applicationDashboard
}
"
><span><strong>
否
</strong></span></c:if>
</td>
<td><c:if
test=
"
${
item
.
networkDashboard
}
"
><span
class=
"text-error"
><strong>
是
</strong></span></c:if>
<c:if
test=
"
${
!
item
.
networkDashboard
}
"
><span><strong>
否
</strong></span></c:if>
</td>
<td><c:if
test=
"
${
item
.
systemMonitorDashboard
}
"
><span
class=
"text-error"
><strong>
是
</strong></span></c:if>
<c:if
test=
"
${
!
item
.
systemMonitorDashboard
}
"
><span><strong>
否
</strong></span></c:if>
</td>
<td>
<c:forEach
var=
"domain"
items=
"
${
item
.
domains
}
"
>
${domain.key},
...
...
cat-home/src/main/webapp/jsp/system/urlPattern/urlPattern.jsp
浏览文件 @
c7ea21a4
...
...
@@ -31,7 +31,7 @@
<th
width=
"15%"
>
唯一ID
</th>
<th
width=
"15%"
>
属于组
</th>
<th
width=
"62%"
>
Pattern内容
</th>
<th
width=
"8%"
>
操作
<a
class=
'btn btn-primary btn-small'
href=
"?op=urlPatternUpdate"
>
新增
</a></th>
<th
width=
"8%"
><a
class=
'btn btn-primary btn-small'
href=
"?op=urlPatternUpdate"
>
新增
</a></th>
</tr></thead><tbody>
<c:forEach
var=
"item"
items=
"
${
model
.
patternItems
}
"
...
...
cat-home/src/main/webapp/jsp/system/urlPattern/urlPatternUpdate.jsp
浏览文件 @
c7ea21a4
...
...
@@ -30,9 +30,10 @@
<td><span
class=
"text-error"
>
暂时不起作用,仅仅用作url的分组,用于展示目的
</span></td>
</tr>
<tr>
<th>
所属组
</th>
<th>
Pattern名
</th>
<td><input
type=
"text"
class=
"input-xlarge"
name=
"patternItem.pattern"
required
value=
"${model.patternItem.pattern}"
/></td>
<td><span
class=
"text-error"
>
支付完全匹配方式,和部分匹配,比如 http://www.dianping.com/{City}/food,{City}可以匹配任何字符串
</span></td>
<td><span
class=
"text-error"
>
支持完全匹配方式,比如http://m.api.dianping.com/searchshop.api,
<br/>
部分匹配,比如 http://www.dianping.com/{City}/food,{City}可以匹配任何字符串
</span></td>
</tr>
<tr>
<td
style=
'text-align:center'
colspan=
'3'
><input
class=
'btn btn-primary'
type=
"submit"
name=
"submit"
value=
"submit"
/></td>
...
...
cat-home/src/test/java/com/dianping/cat/demo/TestCode.java
浏览文件 @
c7ea21a4
...
...
@@ -10,7 +10,6 @@ import com.dianping.cat.message.spi.internal.DefaultMessageTree;
public
class
TestCode
{
public
void
logError
(
Throwable
able
){
Transaction
t
=
Cat
.
newTransaction
(
"Neocortex"
,
"Error"
);
...
...
cat-home/src/test/java/com/dianping/cat/report/page/metric/TestCode.java
浏览文件 @
c7ea21a4
...
...
@@ -46,6 +46,7 @@ public class TestCode {
report
.
addMetricItem
(
create
(
getKey1
(
i
),
i
));
report
.
addMetricItem
(
create
(
getKey2
(
i
),
i
));
report
.
addMetricItem
(
create
(
getKey3
(
i
),
i
));
report
.
addMetricItem
(
create
(
getKey4
(
i
),
i
));
}
Files
.
forIO
().
writeTo
(
new
File
(
"/tmp/data.txt"
),
report
.
toString
());
}
...
...
@@ -85,62 +86,81 @@ public class TestCode {
public
String
getKey1
(
int
i
)
{
if
(
i
<
100
)
{
return
"broker-service:Metric:江苏
南京:中国移动:httpStatus|200"
;
return
"broker-service:Metric:江苏
-
南京:中国移动:httpStatus|200"
;
}
else
if
(
i
<
200
)
{
return
"broker-service:Metric:江苏
南京:中国移动:httpStatus|300"
;
return
"broker-service:Metric:江苏
-
南京:中国移动:httpStatus|300"
;
}
else
if
(
i
<
300
)
{
return
"broker-service:Metric:江苏
南京:中国移动:httpStatus|400"
;
return
"broker-service:Metric:江苏
-
南京:中国移动:httpStatus|400"
;
}
else
if
(
i
<
400
)
{
return
"broker-service:Metric:江苏
南京:中国联通:httpStatus|200"
;
return
"broker-service:Metric:江苏
-
南京:中国联通:httpStatus|200"
;
}
else
if
(
i
<
500
)
{
return
"broker-service:Metric:江苏
南京:中国联通:httpStatus|300"
;
return
"broker-service:Metric:江苏
-
南京:中国联通:httpStatus|300"
;
}
else
if
(
i
<
600
)
{
return
"broker-service:Metric:江苏
扬州:中国联通:httpStatus|200"
;
return
"broker-service:Metric:江苏
-
扬州:中国联通:httpStatus|200"
;
}
else
if
(
i
<
700
)
{
return
"broker-service:Metric:江苏
扬州:中国联通:httpStatus|300"
;
return
"broker-service:Metric:江苏
-
扬州:中国联通:httpStatus|300"
;
}
else
{
return
"broker-service:Metric:江苏
扬州:中国联通:httpStatus|400"
;
return
"broker-service:Metric:江苏
-
扬州:中国联通:httpStatus|400"
;
}
}
public
String
getKey3
(
int
i
)
{
if
(
i
<
100
)
{
return
"broker-service:Metric:江苏
南京:中国移动:errorCode|200"
;
return
"broker-service:Metric:江苏
-
南京:中国移动:errorCode|200"
;
}
else
if
(
i
<
200
)
{
return
"broker-service:Metric:江苏
南京:中国移动:errorCode|300"
;
return
"broker-service:Metric:江苏
-
南京:中国移动:errorCode|300"
;
}
else
if
(
i
<
300
)
{
return
"broker-service:Metric:江苏
南京:中国移动:errorCode|400"
;
return
"broker-service:Metric:江苏
-
南京:中国移动:errorCode|400"
;
}
else
if
(
i
<
400
)
{
return
"broker-service:Metric:江苏
南京:中国联通:errorCode|200"
;
return
"broker-service:Metric:江苏
-
南京:中国联通:errorCode|200"
;
}
else
if
(
i
<
500
)
{
return
"broker-service:Metric:江苏
南京:中国联通:errorCode|300"
;
return
"broker-service:Metric:江苏
-
南京:中国联通:errorCode|300"
;
}
else
if
(
i
<
600
)
{
return
"broker-service:Metric:江苏
扬州:中国联通:errorCode|200"
;
return
"broker-service:Metric:江苏
-
扬州:中国联通:errorCode|200"
;
}
else
if
(
i
<
700
)
{
return
"broker-service:Metric:江苏
扬州:中国联通:errorCode|300"
;
return
"broker-service:Metric:江苏
-
扬州:中国联通:errorCode|300"
;
}
else
{
return
"broker-service:Metric:江苏
扬州:中国联通:errorCode|400"
;
return
"broker-service:Metric:江苏
-
扬州:中国联通:errorCode|400"
;
}
}
public
String
getKey2
(
int
i
)
{
if
(
i
<
100
)
{
return
"broker-service:Metric:江苏
南京:中国移动:hit"
;
return
"broker-service:Metric:江苏
-
南京:中国移动:hit"
;
}
else
if
(
i
<
200
)
{
return
"broker-service:Metric:江苏
南京:中国移动:hit"
;
return
"broker-service:Metric:江苏
-
南京:中国移动:hit"
;
}
else
if
(
i
<
300
)
{
return
"broker-service:Metric:江苏
南京:中国移动:error"
;
return
"broker-service:Metric:江苏
-
南京:中国移动:error"
;
}
else
if
(
i
<
400
)
{
return
"broker-service:Metric:江苏
南京:中国联通:error"
;
return
"broker-service:Metric:江苏
-
南京:中国联通:error"
;
}
else
if
(
i
<
500
)
{
return
"broker-service:Metric:江苏
南京:中国联通:hit"
;
return
"broker-service:Metric:江苏
-
南京:中国联通:hit"
;
}
else
if
(
i
<
600
)
{
return
"broker-service:Metric:江苏
扬州:中国联通:hit"
;
return
"broker-service:Metric:江苏
-
扬州:中国联通:hit"
;
}
else
if
(
i
<
700
)
{
return
"broker-service:Metric:江苏
扬州:中国联通:error"
;
return
"broker-service:Metric:江苏
-
扬州:中国联通:error"
;
}
else
{
return
"broker-service:Metric:江苏
扬州:中国联通:error"
;
return
"broker-service:Metric:江苏
-
扬州:中国联通:error"
;
}
}
public
String
getKey4
(
int
i
)
{
if
(
i
<
100
)
{
return
"broker-service:Metric:江苏-南京:中国移动:avg"
;
}
else
if
(
i
<
200
)
{
return
"broker-service:Metric:江苏-南京:中国移动:avg"
;
}
else
if
(
i
<
300
)
{
return
"broker-service:Metric:江苏-南京:中国移动:avg"
;
}
else
if
(
i
<
400
)
{
return
"broker-service:Metric:江苏-南京:中国联通:avg"
;
}
else
if
(
i
<
500
)
{
return
"broker-service:Metric:江苏-南京:中国联通:avg"
;
}
else
if
(
i
<
600
)
{
return
"broker-service:Metric:江苏-扬州:中国联通:avg"
;
}
else
if
(
i
<
700
)
{
return
"broker-service:Metric:江苏-扬州:中国联通:avg"
;
}
else
{
return
"broker-service:Metric:江苏-扬州:中国联通:avg"
;
}
}
}
cat-home/src/test/java/com/dianping/cat/report/task/exceptionAlert/TopReportVisitorTest.java
浏览文件 @
c7ea21a4
...
...
@@ -12,6 +12,8 @@ import com.dianping.cat.Constants;
import
com.dianping.cat.consumer.top.model.entity.TopReport
;
import
com.dianping.cat.home.alertReport.entity.AlertReport
;
import
com.dianping.cat.home.dependency.exception.entity.ExceptionLimit
;
import
com.dianping.cat.home.dependency.exceptionExclude.entity.ExceptionExclude
;
import
com.dianping.cat.system.config.ExceptionExcludeConfigManager
;
import
com.dianping.cat.system.config.ExceptionThresholdConfigManager
;
public
class
TopReportVisitorTest
extends
ComponentTestCase
{
...
...
@@ -25,9 +27,12 @@ public class TopReportVisitorTest extends ComponentTestCase {
String
expectedAlertReportXml
=
Files
.
forIO
()
.
readFrom
(
getClass
().
getResourceAsStream
(
"alertReport.xml"
),
"utf-8"
);
ConfigMock
m_configManager
=
new
ConfigMock
();
ThresholdConfigMock
m_thresholeConfigManager
=
new
ThresholdConfigMock
();
ExcludeConfigMock
m_excludeConfigManager
=
new
ExcludeConfigMock
();
AlertReport
alertReport
=
new
AlertReport
(
Constants
.
CAT
);
TopReportVisitor
visitor
=
new
TopReportVisitor
(
m_configManager
).
setReport
(
alertReport
);
TopReportVisitor
visitor
=
new
TopReportVisitor
().
setReport
(
alertReport
)
.
setExceptionThresholdConfigManager
(
m_thresholeConfigManager
)
.
setExceptionExcludeConfigManager
(
m_excludeConfigManager
);
alertReport
.
setStartTime
(
topReport
.
getStartTime
());
alertReport
.
setEndTime
(
topReport
.
getEndTime
());
...
...
@@ -37,11 +42,11 @@ public class TopReportVisitorTest extends ComponentTestCase {
.
replace
(
"\r"
,
""
));
}
public
class
ConfigMock
extends
ExceptionThresholdConfigManager
{
public
class
Threshold
ConfigMock
extends
ExceptionThresholdConfigManager
{
private
Map
<
String
,
ExceptionLimit
>
exceptionMap
=
new
HashMap
<
String
,
ExceptionLimit
>();
public
ConfigMock
()
{
public
Threshold
ConfigMock
()
{
ExceptionLimit
exceptionAA
=
new
ExceptionLimit
(
"exceptionA"
);
exceptionAA
.
setDomain
(
"domainA"
).
setError
(
10
).
setWarning
(
5
);
exceptionMap
.
put
(
exceptionAA
.
getDomain
()
+
"_"
+
exceptionAA
.
getId
(),
exceptionAA
);
...
...
@@ -85,4 +90,28 @@ public class TopReportVisitorTest extends ComponentTestCase {
}
}
public
class
ExcludeConfigMock
extends
ExceptionExcludeConfigManager
{
private
Map
<
String
,
ExceptionExclude
>
exceptionMap
=
new
HashMap
<
String
,
ExceptionExclude
>();
public
ExcludeConfigMock
()
{
ExceptionExclude
exceptionAll
=
new
ExceptionExclude
(
"All"
);
exceptionAll
.
setDomain
(
"domainA"
);
exceptionMap
.
put
(
exceptionAll
.
getDomain
()
+
"_"
+
exceptionAll
.
getId
(),
exceptionAll
);
ExceptionExclude
exceptionCA
=
new
ExceptionExclude
(
"exceptionA"
);
exceptionCA
.
setDomain
(
"domainC"
);
exceptionMap
.
put
(
exceptionCA
.
getDomain
()
+
"_"
+
exceptionCA
.
getId
(),
exceptionCA
);
}
public
ExceptionExclude
queryDomainExceptionExclude
(
String
domain
,
String
exceptionName
)
{
ExceptionExclude
exceptionExclude
=
null
;
exceptionExclude
=
exceptionMap
.
get
(
domain
+
"_"
+
exceptionName
);
if
(
exceptionExclude
==
null
)
{
exceptionExclude
=
exceptionMap
.
get
(
domain
+
"_All"
);
}
return
exceptionExclude
;
}
}
}
cat-home/src/test/resources/com/dianping/cat/report/page/dependency/exception-exclude-config.xml
0 → 100644
浏览文件 @
c7ea21a4
<?xml version="1.0" encoding="utf-8"?>
<exception-exclude-config>
<domain-config
id =
"Default"
>
<exception-exclude
domain=
"Default"
id=
"java.lang.IllegalArgumentException"
></exception-exclude>
<exception-exclude
domain=
"Default"
id=
"java.lang.IllegalArgumentException"
></exception-exclude>
</domain-config>
<domain-config
id =
"Cat"
>
</domain-config>
</exception-exclude-config>
cat-home/src/test/resources/com/dianping/cat/report/task/exceptionAlert/alertReport.xml
浏览文件 @
c7ea21a4
<?xml version="1.0" encoding="utf-8"?>
<alert-report
domain=
"Cat"
start-time=
"2014-05-06 21:00:00"
end-time=
"2014-05-06 21:59:59"
>
<domain
name=
"domainA"
warn-number=
"1"
error-number=
"1"
>
<exception
id=
"TotalExceptionAlert"
warn-number=
"0"
error-number=
"1"
/>
<exception
id=
"exceptionA"
warn-number=
"1"
error-number=
"0"
/>
</domain>
<domain
name=
"domainC"
warn-number=
"6"
error-number=
"12"
>
<exception
id=
"TotalExceptionAlert"
warn-number=
"1"
error-number=
"4"
/>
<exception
id=
"exceptionA"
warn-number=
"1"
error-number=
"3"
/>
<domain
name=
"domainC"
warn-number=
"6"
error-number=
"7"
>
<exception
id=
"exceptionB"
warn-number=
"2"
error-number=
"2"
/>
<exception
id=
"exceptionC"
warn-number=
"1"
error-number=
"2"
/>
<exception
id=
"TotalExceptionAlert"
warn-number=
"2"
error-number=
"2"
/>
<exception
id=
"exceptionD"
warn-number=
"1"
error-number=
"1"
/>
</domain>
</alert-report>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录