Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
3a4e9924
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,发现更多精彩内容 >>
提交
3a4e9924
编写于
4月 19, 2013
作者:
F
Frankie Wu
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'biz' of github.com:dianping/cat into biz
上级
b9e47a94
99fb0c1a
变更
43
隐藏空白更改
内联
并排
Showing
43 changed file
with
659 addition
and
260 deletion
+659
-260
cat-consumer/pom.xml
cat-consumer/pom.xml
+11
-1
cat-consumer/src/main/java/com/dianping/cat/consumer/dump/DumpUploader.java
...ain/java/com/dianping/cat/consumer/dump/DumpUploader.java
+1
-5
cat-consumer/src/main/java/com/dianping/cat/consumer/metric/MetricAnalyzer.java
...java/com/dianping/cat/consumer/metric/MetricAnalyzer.java
+26
-0
cat-consumer/src/main/java/com/dianping/cat/consumer/problem/handler/DefaultProblemHandler.java
...g/cat/consumer/problem/handler/DefaultProblemHandler.java
+1
-1
cat-consumer/src/main/resources/META-INF/dal/model/metric-report-codegen.xml
...in/resources/META-INF/dal/model/metric-report-codegen.xml
+2
-1
cat-consumer/src/main/resources/META-INF/dal/model/metric-report-model.xml
...main/resources/META-INF/dal/model/metric-report-model.xml
+2
-0
cat-consumer/src/main/resources/META-INF/wizard/model/manifest.xml
...mer/src/main/resources/META-INF/wizard/model/manifest.xml
+5
-0
cat-consumer/src/main/resources/META-INF/wizard/model/wizard.xml
...sumer/src/main/resources/META-INF/wizard/model/wizard.xml
+6
-0
cat-consumer/src/test/resources/com/dianping/cat/consumer/metric/model/metric-report.xml
.../com/dianping/cat/consumer/metric/model/metric-report.xml
+10
-88
cat-core/src/main/java/com/dianping/cat/message/io/DefaultTransportManager.java
.../com/dianping/cat/message/io/DefaultTransportManager.java
+1
-1
cat-core/src/main/java/com/dianping/cat/storage/dump/LocalMessageBucketManager.java
.../dianping/cat/storage/dump/LocalMessageBucketManager.java
+3
-3
cat-home/pom.xml
cat-home/pom.xml
+6
-1
cat-home/src/main/java/com/dianping/cat/report/ReportModule.java
...e/src/main/java/com/dianping/cat/report/ReportModule.java
+1
-1
cat-home/src/main/java/com/dianping/cat/report/ReportPage.java
...ome/src/main/java/com/dianping/cat/report/ReportPage.java
+1
-1
cat-home/src/main/java/com/dianping/cat/report/page/jsError/Action.java
...ain/java/com/dianping/cat/report/page/jsError/Action.java
+1
-1
cat-home/src/main/java/com/dianping/cat/report/page/jsError/Context.java
...in/java/com/dianping/cat/report/page/jsError/Context.java
+1
-1
cat-home/src/main/java/com/dianping/cat/report/page/jsError/Handler.java
...in/java/com/dianping/cat/report/page/jsError/Handler.java
+141
-0
cat-home/src/main/java/com/dianping/cat/report/page/jsError/JspFile.java
...in/java/com/dianping/cat/report/page/jsError/JspFile.java
+2
-2
cat-home/src/main/java/com/dianping/cat/report/page/jsError/JspViewer.java
.../java/com/dianping/cat/report/page/jsError/JspViewer.java
+1
-1
cat-home/src/main/java/com/dianping/cat/report/page/jsError/Model.java
...main/java/com/dianping/cat/report/page/jsError/Model.java
+1
-1
cat-home/src/main/java/com/dianping/cat/report/page/jsError/Payload.java
...in/java/com/dianping/cat/report/page/jsError/Payload.java
+13
-25
cat-home/src/main/java/com/dianping/cat/report/page/metric/Handler.java
...ain/java/com/dianping/cat/report/page/metric/Handler.java
+6
-3
cat-home/src/main/java/com/dianping/cat/report/page/metric/Model.java
.../main/java/com/dianping/cat/report/page/metric/Model.java
+11
-0
cat-home/src/main/java/com/dianping/cat/report/page/metric/Payload.java
...ain/java/com/dianping/cat/report/page/metric/Payload.java
+11
-0
cat-home/src/main/java/com/dianping/cat/report/page/model/Payload.java
...main/java/com/dianping/cat/report/page/model/Payload.java
+11
-0
cat-home/src/main/java/com/dianping/cat/system/alarm/alert/AlertInfo.java
...n/java/com/dianping/cat/system/alarm/alert/AlertInfo.java
+12
-6
cat-home/src/main/java/com/dianping/cat/system/alarm/alert/AlertManager.java
...ava/com/dianping/cat/system/alarm/alert/AlertManager.java
+23
-7
cat-home/src/main/java/com/dianping/cat/system/alarm/threshold/ThresholdRule.java
...om/dianping/cat/system/alarm/threshold/ThresholdRule.java
+14
-6
cat-home/src/main/java/com/dianping/cat/system/alarm/threshold/listener/ExceptionDataListener.java
...ystem/alarm/threshold/listener/ExceptionDataListener.java
+9
-2
cat-home/src/main/java/com/dianping/cat/system/alarm/threshold/listener/ServiceDataListener.java
.../system/alarm/threshold/listener/ServiceDataListener.java
+1
-0
cat-home/src/main/java/com/dianping/cat/system/alarm/threshold/listener/ThresholdAlertListener.java
...stem/alarm/threshold/listener/ThresholdAlertListener.java
+18
-18
cat-home/src/main/java/com/dianping/cat/system/page/alarm/RuleManager.java
.../java/com/dianping/cat/system/page/alarm/RuleManager.java
+2
-1
cat-home/src/main/java/com/dianping/cat/system/tool/MailSMSImpl.java
...c/main/java/com/dianping/cat/system/tool/MailSMSImpl.java
+1
-0
cat-home/src/main/resources/META-INF/plexus/components.xml
cat-home/src/main/resources/META-INF/plexus/components.xml
+130
-5
cat-home/src/main/resources/META-INF/wizard/webapp/wizard.xml
...home/src/main/resources/META-INF/wizard/webapp/wizard.xml
+2
-2
cat-home/src/main/webapp/jsp/report/jsError.jsp
cat-home/src/main/webapp/jsp/report/jsError.jsp
+5
-0
cat-home/src/main/webapp/jsp/report/metric.jsp
cat-home/src/main/webapp/jsp/report/metric.jsp
+7
-8
cat-home/src/main/webapp/jsp/system/alarmRuleAdd.jsp
cat-home/src/main/webapp/jsp/system/alarmRuleAdd.jsp
+68
-20
cat-home/src/main/webapp/jsp/system/alarmRuleUpdate.jsp
cat-home/src/main/webapp/jsp/system/alarmRuleUpdate.jsp
+65
-28
cat-home/src/test/java/com/dianping/cat/demo/TestBusinessMessage.java
.../test/java/com/dianping/cat/demo/TestBusinessMessage.java
+10
-9
cat-home/src/test/java/com/dianping/cat/demo/TestMaxMessage.java
...e/src/test/java/com/dianping/cat/demo/TestMaxMessage.java
+3
-2
cat-home/src/test/java/com/dianping/cat/demo/TestSendMessage.java
.../src/test/java/com/dianping/cat/demo/TestSendMessage.java
+1
-1
cat-home/src/test/java/com/dianping/cat/report/page/jsError/JsTest.java
...est/java/com/dianping/cat/report/page/jsError/JsTest.java
+13
-8
未找到文件。
cat-consumer/pom.xml
浏览文件 @
3a4e9924
...
...
@@ -88,7 +88,17 @@
<goal>
dal-jdbc
</goal>
</goals>
<configuration>
<manifest>
<![CDATA[${basedir}/src/main/resources/META-INF/dal/jdbc/report-manifest.xml,]]>
<![CDATA[${basedir}/src/main/resources/META-INF/dal/jdbc/report-manifest.xml,]]>
</manifest>
<manifest>
<![CDATA[${basedir}/src/main/resources/META-INF/dal/jdbc/report-manifest.xml,]]>
<![CDATA[${basedir}/src/main/resources/META-INF/dal/jdbc/report-manifest.xml,]]>
</manifest>
</configuration>
</execution>
<execution>
<id>
generate dal model files
</id>
<phase>
generate-sources
</phase>
<goals>
<goal>
dal-model
</goal>
</goals>
<configuration>
<manifest>
<![CDATA[${basedir}/src/main/resources/META-INF/dal/model/metric-report-manifest.xml,]]>
</manifest>
</configuration>
</execution>
</executions>
...
...
cat-consumer/src/main/java/com/dianping/cat/consumer/dump/DumpUploader.java
浏览文件 @
3a4e9924
...
...
@@ -181,11 +181,7 @@ public class DumpUploader implements Initializable, LogEnabled {
}
catch
(
AlreadyBeingCreatedException
e
)
{
Cat
.
logError
(
e
);
t
.
setStatus
(
e
);
m_logger
.
error
(
String
.
format
(
"Already being created (%s), delete the file!"
,
path
),
e
);
if
(!
file
.
delete
())
{
m_logger
.
warn
(
"Can't delete file: "
+
file
);
}
m_logger
.
error
(
String
.
format
(
"Already being created (%s)!"
,
path
),
e
);
}
catch
(
AccessControlException
e
)
{
cat
.
logError
(
e
);
t
.
setStatus
(
e
);
...
...
cat-consumer/src/main/java/com/dianping/cat/consumer/metric/MetricAnalyzer.java
浏览文件 @
3a4e9924
...
...
@@ -41,6 +41,8 @@ public class MetricAnalyzer extends AbstractMessageAnalyzer<MetricReport> implem
private
static
final
String
TUANGOU
=
"TuanGou"
;
private
static
final
String
CHANNEL
=
"channel"
;
private
static
Map
<
String
,
Set
<
String
>>
s_urls
=
new
HashMap
<
String
,
Set
<
String
>>();
private
static
Map
<
String
,
Map
<
String
,
String
>>
s_metric
=
new
HashMap
<
String
,
Map
<
String
,
String
>>();
...
...
@@ -167,9 +169,28 @@ public class MetricAnalyzer extends AbstractMessageAnalyzer<MetricReport> implem
point
.
setCount
(
point
.
getCount
()
+
1
);
point
.
setSum
(
point
.
getSum
()
+
transaction
.
getDurationInMillis
());
point
.
setAvg
(
point
.
getSum
()
/
point
.
getCount
());
Object
data
=
transaction
.
getData
();
if
(
data
!=
null
)
{
double
value
=
parseValue
(
CHANNEL
,
(
String
)
data
);
if
(
value
>
0
)
{
updateChannel
(
min
,
metric
,
value
);
}
}
}
}
private
void
updateChannel
(
int
min
,
com
.
dianping
.
cat
.
consumer
.
metric
.
model
.
entity
.
Metric
metric
,
double
value
)
{
com
.
dianping
.
cat
.
consumer
.
metric
.
model
.
entity
.
Metric
detail
=
metric
.
findOrCreateMetric
(
CHANNEL
+
"="
+(
int
)(
value
));
Point
channelPoint
=
detail
.
findOrCreatePoint
(
min
);
channelPoint
.
setCount
(
channelPoint
.
getCount
()
+
1
);
channelPoint
.
setSum
(
channelPoint
.
getSum
()
+
value
);
channelPoint
.
setAvg
(
channelPoint
.
getSum
()
/
channelPoint
.
getCount
());
}
private
int
processMetric
(
String
group
,
MetricReport
report
,
MessageTree
tree
,
Metric
metric
)
{
String
name
=
metric
.
getName
();
Map
<
String
,
String
>
metrics
=
s_metric
.
get
(
group
);
...
...
@@ -188,6 +209,11 @@ public class MetricAnalyzer extends AbstractMessageAnalyzer<MetricReport> implem
point
.
setCount
(
point
.
getCount
()
+
1
);
point
.
setSum
(
point
.
getSum
()
+
value
);
point
.
setAvg
(
point
.
getSum
()
/
point
.
getCount
());
double
channel
=
parseValue
(
"channel"
,
data
);
if
(
channel
>
0
)
{
updateChannel
(
min
,
temp
,
channel
);
}
}
return
0
;
}
...
...
cat-consumer/src/main/java/com/dianping/cat/consumer/problem/handler/DefaultProblemHandler.java
浏览文件 @
3a4e9924
...
...
@@ -63,7 +63,7 @@ public class DefaultProblemHandler extends Handler {
String
status
=
""
;
if
(
m_failureTypes
.
contains
(
type
))
{
type
=
transaction
.
getType
()
.
toLowerCase
()
;
type
=
transaction
.
getType
();
//make it march for alarm
if
(
type
.
equals
(
"PigeonCall"
))
{
type
=
"call"
;
...
...
cat-consumer/src/main/resources/META-INF/dal/model/metric-report-codegen.xml
浏览文件 @
3a4e9924
...
...
@@ -4,12 +4,13 @@
<attribute
name=
"group"
value-type=
"String"
/>
<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"
/>
<element
name=
"group"
value-type=
"String"
type=
"list"
names=
"groups"
/>
<element
name=
"group"
value-type=
"String"
/>
<entity-ref
name=
"metric"
type=
"list"
names=
"metrics"
/>
</entity>
<entity
name=
"metric"
>
<attribute
name=
"id"
value-type=
"String"
/>
<entity-ref
name=
"point"
type=
"list"
names=
"points"
/>
<entity-ref
name=
"metric"
/>
</entity>
<entity
name=
"point"
>
<attribute
name=
"id"
value-type=
"int"
/>
...
...
cat-consumer/src/main/resources/META-INF/dal/model/metric-report-model.xml
浏览文件 @
3a4e9924
...
...
@@ -15,6 +15,8 @@
<attribute
name=
"id"
value-type=
"String"
key=
"true"
/>
<entity-ref
name=
"point"
type=
"map"
names=
"points"
method-find-or-create=
"true"
/>
<entity-ref
name=
"metric"
type=
"map"
names=
"metrics"
method-find-or-create=
"true"
/>
</entity>
<entity
name=
"point"
>
<attribute
name=
"id"
value-type=
"int"
key=
"true"
/>
...
...
cat-consumer/src/main/resources/META-INF/wizard/model/manifest.xml
0 → 100644
浏览文件 @
3a4e9924
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<file
path=
"wizard.xml"
/>
</manifest>
cat-consumer/src/main/resources/META-INF/wizard/model/wizard.xml
0 → 100644
浏览文件 @
3a4e9924
<?xml version="1.0" encoding="utf-8"?>
<wizard
package=
"com.dianping.cat.consumer"
>
<model
package=
"com.dianping.cat.consumer.metric-report"
name=
"metric-report"
>
<sample-model>
/Users/youyong/Documents/workspace/cat/cat-consumer/src/test/resources/com/dianping/cat/consumer/metric/model/metric-report.xml
</sample-model>
</model>
</wizard>
cat-consumer/src/test/resources/com/dianping/cat/consumer/metric/model/metric-report.xml
浏览文件 @
3a4e9924
...
...
@@ -5,97 +5,19 @@
<point
id=
"0"
count=
"3"
sum=
"708.00"
avg=
"236.00"
/>
<point
id=
"1"
count=
"4"
sum=
"1044.00"
avg=
"261.00"
/>
<point
id=
"2"
count=
"3"
sum=
"701.00"
avg=
"233.67"
/>
<point
id=
"5"
count=
"1003"
sum=
"994.00"
avg=
"0.99"
/>
<point
id=
"6"
count=
"6003"
sum=
"2861.00"
avg=
"0.48"
/>
<point
id=
"3"
count=
"3"
sum=
"552.00"
avg=
"184.00"
/>
<point
id=
"7"
count=
"6008"
sum=
"2903.00"
avg=
"0.48"
/>
<point
id=
"8"
count=
"6004"
sum=
"1129.00"
avg=
"0.19"
/>
<point
id=
"9"
count=
"6006"
sum=
"1778.00"
avg=
"0.30"
/>
<point
id=
"10"
count=
"6005"
sum=
"1145.00"
avg=
"0.19"
/>
<point
id=
"11"
count=
"6003"
sum=
"740.00"
avg=
"0.12"
/>
<point
id=
"12"
count=
"4004"
sum=
"1020.00"
avg=
"0.25"
/>
<point
id=
"13"
count=
"3"
sum=
"659.00"
avg=
"219.67"
/>
<point
id=
"14"
count=
"3"
sum=
"642.00"
avg=
"214.00"
/>
<point
id=
"15"
count=
"4"
sum=
"815.00"
avg=
"203.75"
/>
<point
id=
"16"
count=
"3"
sum=
"541.00"
avg=
"180.33"
/>
<point
id=
"17"
count=
"3"
sum=
"801.00"
avg=
"267.00"
/>
<point
id=
"18"
count=
"3"
sum=
"529.00"
avg=
"176.33"
/>
<point
id=
"19"
count=
"3"
sum=
"607.00"
avg=
"202.33"
/>
<point
id=
"20"
count=
"4"
sum=
"1007.00"
avg=
"251.75"
/>
<point
id=
"21"
count=
"3"
sum=
"906.00"
avg=
"302.00"
/>
<point
id=
"22"
count=
"1"
sum=
"388.00"
avg=
"388.00"
/>
<point
id=
"23"
count=
"1"
sum=
"727.00"
avg=
"727.00"
/>
<point
id=
"24"
count=
"1"
sum=
"364.00"
avg=
"364.00"
/>
<point
id=
"25"
count=
"2"
sum=
"748.00"
avg=
"374.00"
/>
<point
id=
"27"
count=
"1"
sum=
"447.00"
avg=
"447.00"
/>
<point
id=
"30"
count=
"1"
sum=
"901.00"
avg=
"901.00"
/>
<point
id=
"41"
count=
"1"
sum=
"455.00"
avg=
"455.00"
/>
<point
id=
"44"
count=
"1"
sum=
"585.00"
avg=
"585.00"
/>
<point
id=
"49"
count=
"1"
sum=
"201.00"
avg=
"201.00"
/>
<point
id=
"54"
count=
"4"
sum=
"1294.00"
avg=
"323.50"
/>
<point
id=
"55"
count=
"1"
sum=
"5.00"
avg=
"5.00"
/>
<point
id=
"56"
count=
"5"
sum=
"11877.00"
avg=
"2375.40"
/>
<point
id=
"57"
count=
"1"
sum=
"672.00"
avg=
"672.00"
/>
<point
id=
"58"
count=
"8"
sum=
"2327.00"
avg=
"290.88"
/>
<point
id=
"59"
count=
"1"
sum=
"2852.00"
avg=
"2852.00"
/>
<metric
id=
"800tuan"
>
<point
id=
"0"
count=
"3"
sum=
"708.00"
avg=
"236.00"
/>
<point
id=
"1"
count=
"4"
sum=
"1044.00"
avg=
"261.00"
/>
<point
id=
"2"
count=
"3"
sum=
"701.00"
avg=
"233.67"
/>
</metric>
<metric
id=
"abc"
>
<point
id=
"0"
count=
"3"
sum=
"708.00"
avg=
"236.00"
/>
<point
id=
"1"
count=
"4"
sum=
"1044.00"
avg=
"261.00"
/>
<point
id=
"2"
count=
"3"
sum=
"701.00"
avg=
"233.67"
/>
</metric>
</metric>
<metric
id=
"order"
>
<point
id=
"5"
count=
"1000"
sum=
"499500.00"
avg=
"499.50"
/>
<point
id=
"6"
count=
"6000"
sum=
"2997000.00"
avg=
"499.50"
/>
<point
id=
"7"
count=
"6000"
sum=
"2997000.00"
avg=
"499.50"
/>
<point
id=
"8"
count=
"6000"
sum=
"2997000.00"
avg=
"499.50"
/>
<point
id=
"9"
count=
"6000"
sum=
"2997000.00"
avg=
"499.50"
/>
<point
id=
"10"
count=
"6000"
sum=
"2997000.00"
avg=
"499.50"
/>
<point
id=
"11"
count=
"6000"
sum=
"2997000.00"
avg=
"499.50"
/>
<point
id=
"12"
count=
"4000"
sum=
"1998000.00"
avg=
"499.50"
/>
</metric>
<metric
id=
"/detail"
>
<point
id=
"5"
count=
"1000"
sum=
"0.00"
avg=
"0.00"
/>
<point
id=
"6"
count=
"6000"
sum=
"2.00"
avg=
"0.00"
/>
<point
id=
"7"
count=
"6000"
sum=
"9.00"
avg=
"0.00"
/>
<point
id=
"8"
count=
"6000"
sum=
"5.00"
avg=
"0.00"
/>
<point
id=
"9"
count=
"6001"
sum=
"77.00"
avg=
"0.01"
/>
<point
id=
"10"
count=
"6000"
sum=
"7.00"
avg=
"0.00"
/>
<point
id=
"11"
count=
"6000"
sum=
"6.00"
avg=
"0.00"
/>
<point
id=
"12"
count=
"4000"
sum=
"6.00"
avg=
"0.00"
/>
<point
id=
"27"
count=
"1"
sum=
"262.00"
avg=
"262.00"
/>
<point
id=
"28"
count=
"1"
sum=
"54.00"
avg=
"54.00"
/>
<point
id=
"30"
count=
"1"
sum=
"55.00"
avg=
"55.00"
/>
<point
id=
"31"
count=
"1"
sum=
"53.00"
avg=
"53.00"
/>
<point
id=
"36"
count=
"4"
sum=
"226.00"
avg=
"56.50"
/>
<point
id=
"37"
count=
"2"
sum=
"176.00"
avg=
"88.00"
/>
<point
id=
"45"
count=
"1"
sum=
"56.00"
avg=
"56.00"
/>
<point
id=
"47"
count=
"1"
sum=
"338.00"
avg=
"338.00"
/>
<point
id=
"49"
count=
"1"
sum=
"52.00"
avg=
"52.00"
/>
</metric>
<metric
id=
"payment.pending"
>
<point
id=
"5"
count=
"1000"
sum=
"499500.00"
avg=
"499.50"
/>
<point
id=
"6"
count=
"6000"
sum=
"2997000.00"
avg=
"499.50"
/>
<point
id=
"7"
count=
"6000"
sum=
"2997000.00"
avg=
"499.50"
/>
<point
id=
"8"
count=
"6000"
sum=
"2997000.00"
avg=
"499.50"
/>
<point
id=
"9"
count=
"6000"
sum=
"2997000.00"
avg=
"499.50"
/>
<point
id=
"10"
count=
"6000"
sum=
"2997000.00"
avg=
"499.50"
/>
<point
id=
"11"
count=
"6000"
sum=
"2997000.00"
avg=
"499.50"
/>
<point
id=
"12"
count=
"4000"
sum=
"1998000.00"
avg=
"499.50"
/>
</metric>
<metric
id=
"/order/submitOrder"
>
<point
id=
"5"
count=
"1000"
sum=
"0.00"
avg=
"0.00"
/>
<point
id=
"6"
count=
"6000"
sum=
"15.00"
avg=
"0.00"
/>
<point
id=
"7"
count=
"6000"
sum=
"10.00"
avg=
"0.00"
/>
<point
id=
"8"
count=
"6000"
sum=
"4.00"
avg=
"0.00"
/>
<point
id=
"9"
count=
"6000"
sum=
"8.00"
avg=
"0.00"
/>
<point
id=
"10"
count=
"6000"
sum=
"8.00"
avg=
"0.00"
/>
<point
id=
"11"
count=
"6000"
sum=
"10.00"
avg=
"0.00"
/>
<point
id=
"12"
count=
"4000"
sum=
"0.00"
avg=
"0.00"
/>
</metric>
<metric
id=
"payment.success"
>
<point
id=
"5"
count=
"1000"
sum=
"499500.00"
avg=
"499.50"
/>
<point
id=
"6"
count=
"6000"
sum=
"2997000.00"
avg=
"499.50"
/>
<point
id=
"7"
count=
"6000"
sum=
"2997000.00"
avg=
"499.50"
/>
<point
id=
"8"
count=
"6000"
sum=
"2997000.00"
avg=
"499.50"
/>
<point
id=
"9"
count=
"6000"
sum=
"2997000.00"
avg=
"499.50"
/>
<point
id=
"10"
count=
"6000"
sum=
"2997000.00"
avg=
"499.50"
/>
<point
id=
"11"
count=
"6000"
sum=
"2997000.00"
avg=
"499.50"
/>
<point
id=
"12"
count=
"4000"
sum=
"1998000.00"
avg=
"499.50"
/>
</metric>
</metric-report>
\ No newline at end of file
cat-core/src/main/java/com/dianping/cat/message/io/DefaultTransportManager.java
浏览文件 @
3a4e9924
...
...
@@ -49,7 +49,7 @@ public class DefaultTransportManager extends ContainerHolder implements Transpor
}
m_logger
.
info
(
"Remote CAT servers: "
+
addresses
);
if
(
addresses
.
isEmpty
())
{
throw
new
RuntimeException
(
"All servers in configuration are disabled!\r\n"
+
servers
);
}
else
if
(
addresses
.
size
()
==
1
)
{
...
...
cat-core/src/main/java/com/dianping/cat/storage/dump/LocalMessageBucketManager.java
浏览文件 @
3a4e9924
...
...
@@ -241,7 +241,7 @@ public class LocalMessageBucketManager extends ContainerHolder implements Messag
if
(
paths
.
size
()
>
0
)
{
String
ip
=
NetworkInterfaceManager
.
INSTANCE
.
getLocalHostAddress
();
Transaction
t
=
Cat
.
newTransaction
(
"System"
,
"
Dump
"
+
"-"
+
ip
);
Transaction
t
=
Cat
.
newTransaction
(
"System"
,
"
Move
"
+
"-"
+
ip
);
t
.
setStatus
(
Message
.
SUCCESS
);
for
(
String
path
:
paths
)
{
...
...
@@ -254,7 +254,7 @@ public class LocalMessageBucketManager extends ContainerHolder implements Messag
bucket
.
close
();
bucket
.
archive
();
Cat
.
getProducer
().
logEvent
(
"
Dump
"
,
"Outbox.Normal"
,
Message
.
SUCCESS
,
loginfo
);
Cat
.
getProducer
().
logEvent
(
"
Move
"
,
"Outbox.Normal"
,
Message
.
SUCCESS
,
loginfo
);
}
catch
(
Exception
e
)
{
t
.
setStatus
(
e
);
Cat
.
logError
(
e
);
...
...
@@ -268,7 +268,7 @@ public class LocalMessageBucketManager extends ContainerHolder implements Messag
moveFile
(
path
);
moveFile
(
path
+
".idx"
);
Cat
.
getProducer
().
logEvent
(
"
Dump
"
,
"Outbox.Abnormal"
,
Message
.
SUCCESS
,
loginfo
);
Cat
.
getProducer
().
logEvent
(
"
Move
"
,
"Outbox.Abnormal"
,
Message
.
SUCCESS
,
loginfo
);
}
catch
(
Exception
e
)
{
t
.
setStatus
(
e
);
Cat
.
logError
(
e
);
...
...
cat-home/pom.xml
浏览文件 @
3a4e9924
...
...
@@ -110,7 +110,12 @@
<dependency>
<groupId>
org.unidal.framework
</groupId>
<artifactId>
web-framework
</artifactId>
<version>
2.0.1
</version>
<version>
2.0.2
</version>
</dependency>
<dependency>
<groupId>
org.unidal.framework
</groupId>
<artifactId>
foundation-service
</artifactId>
<version>
2.0.2
</version>
</dependency>
<dependency>
<groupId>
org.unidal.framework
</groupId>
...
...
cat-home/src/main/java/com/dianping/cat/report/ReportModule.java
浏览文件 @
3a4e9924
...
...
@@ -49,7 +49,7 @@ com.dianping.cat.report.page.top.Handler.class,
com
.
dianping
.
cat
.
report
.
page
.
metric
.
Handler
.
class
,
com
.
dianping
.
cat
.
report
.
page
.
push
Error
.
Handler
.
class
com
.
dianping
.
cat
.
report
.
page
.
js
Error
.
Handler
.
class
})
public
class
ReportModule
extends
AbstractModule
{
...
...
cat-home/src/main/java/com/dianping/cat/report/ReportPage.java
浏览文件 @
3a4e9924
...
...
@@ -47,7 +47,7 @@ public enum ReportPage implements Page {
METRIC
(
"metric"
,
"metric"
,
"Metric"
,
"Metric"
,
true
),
PUSHERROR
(
"pushError"
,
"pushError"
,
"PushError"
,
"Push
Error"
,
true
);
JSERROR
(
"jsError"
,
"jsError"
,
"JsError"
,
"js
Error"
,
true
);
private
String
m_name
;
...
...
cat-home/src/main/java/com/dianping/cat/report/page/
push
Error/Action.java
→
cat-home/src/main/java/com/dianping/cat/report/page/
js
Error/Action.java
浏览文件 @
3a4e9924
package
com.dianping.cat.report.page.
push
Error
;
package
com.dianping.cat.report.page.
js
Error
;
public
enum
Action
implements
org
.
unidal
.
web
.
mvc
.
Action
{
VIEW
(
"view"
);
...
...
cat-home/src/main/java/com/dianping/cat/report/page/
push
Error/Context.java
→
cat-home/src/main/java/com/dianping/cat/report/page/
js
Error/Context.java
浏览文件 @
3a4e9924
package
com.dianping.cat.report.page.
push
Error
;
package
com.dianping.cat.report.page.
js
Error
;
import
com.dianping.cat.report.ReportContext
;
...
...
cat-home/src/main/java/com/dianping/cat/report/page/
push
Error/Handler.java
→
cat-home/src/main/java/com/dianping/cat/report/page/
js
Error/Handler.java
浏览文件 @
3a4e9924
package
com.dianping.cat.report.page.
push
Error
;
package
com.dianping.cat.report.page.
js
Error
;
import
java.io.IOException
;
import
java.net.MalformedURLException
;
import
java.net.URL
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.List
;
import
javax.servlet.ServletException
;
...
...
@@ -14,6 +17,7 @@ import org.unidal.web.mvc.annotation.PayloadMeta;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.message.Message
;
import
com.dianping.cat.message.Transaction
;
import
com.dianping.cat.message.spi.internal.DefaultMessageTree
;
import
com.dianping.cat.report.ReportPage
;
...
...
@@ -21,15 +25,88 @@ public class Handler implements PageHandler<Context> {
@Inject
private
JspViewer
m_jspViewer
;
private
static
final
String
ACCESS
=
"DirectAccess"
;
@Override
@PayloadMeta
(
Payload
.
class
)
@InboundActionMeta
(
name
=
"
push
Error"
)
@InboundActionMeta
(
name
=
"
js
Error"
)
public
void
handleInbound
(
Context
ctx
)
throws
ServletException
,
IOException
{
// display only, no action here
}
private
String
parseHost
()
{
DefaultMessageTree
tree
=
(
DefaultMessageTree
)
Cat
.
getManager
().
getThreadLocalMessageTree
();
Message
message
=
tree
.
getMessage
();
if
(
message
.
getType
().
equals
(
"URL"
)
&&
message
instanceof
Transaction
)
{
Transaction
t
=
(
Transaction
)
message
;
List
<
Message
>
messages
=
t
.
getChildren
();
for
(
Message
temp
:
messages
)
{
String
type
=
temp
.
getType
();
if
(
type
.
equals
(
"URL.Server"
)
||
type
.
equals
(
"ClientInfo"
))
{
String
data
=
temp
.
getData
().
toString
();
String
url
=
parseValue
(
"Referer"
,
data
);
if
(
url
!=
null
)
{
try
{
URL
u
=
new
URL
(
url
);
return
u
.
getHost
();
}
catch
(
MalformedURLException
e
)
{
break
;
}
}
}
}
}
return
ACCESS
;
}
protected
String
parseValue
(
final
String
key
,
final
String
data
)
{
int
len
=
data
==
null
?
0
:
data
.
length
();
int
keyLen
=
key
.
length
();
StringBuilder
name
=
new
StringBuilder
();
StringBuilder
value
=
new
StringBuilder
();
boolean
inName
=
true
;
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
char
ch
=
data
.
charAt
(
i
);
switch
(
ch
)
{
case
'&'
:
if
(
name
.
length
()
==
keyLen
&&
name
.
toString
().
equals
(
key
))
{
return
value
.
toString
();
}
inName
=
true
;
name
.
setLength
(
0
);
value
.
setLength
(
0
);
break
;
case
'='
:
if
(
inName
)
{
inName
=
false
;
}
else
{
value
.
append
(
ch
);
}
break
;
default
:
if
(
inName
)
{
name
.
append
(
ch
);
}
else
{
value
.
append
(
ch
);
}
break
;
}
}
if
(
name
.
length
()
==
keyLen
&&
name
.
toString
().
equals
(
key
))
{
return
value
.
toString
();
}
return
null
;
}
@Override
@OutboundActionMeta
(
name
=
"
push
Error"
)
@OutboundActionMeta
(
name
=
"
js
Error"
)
public
void
handleOutbound
(
Context
ctx
)
throws
ServletException
,
IOException
{
Model
model
=
new
Model
(
ctx
);
Payload
payload
=
ctx
.
getPayload
();
...
...
@@ -37,22 +114,28 @@ public class Handler implements PageHandler<Context> {
long
timestamp
=
payload
.
getTimestamp
();
String
error
=
payload
.
getError
();
String
file
=
payload
.
getFile
();
String
line
=
payload
.
getLine
();
String
url
=
payload
.
getUrl
();
String
host
=
payload
.
getHost
();
String
host
=
parseHost
();
if
(
file
==
null
||
file
.
length
()
==
0
)
{
file
=
"unknown"
;
}
int
index
=
file
.
indexOf
(
'?'
);
if
(
index
>
-
1
)
{
file
=
file
.
substring
(
0
,
index
);
}
Cat
.
logEvent
(
"Error"
,
file
,
"Error"
,
error
);
Cat
.
logEvent
(
"Error.
url"
,
url
,
Message
.
SUCCESS
,
"line="
+
line
+
"&time="
+
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm"
).
format
(
new
Date
(
timestamp
)));
Cat
.
logEvent
(
"Error.
Date"
,
file
,
Message
.
SUCCESS
,
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm"
).
format
(
new
Date
(
timestamp
)));
DefaultMessageTree
tree
=
(
DefaultMessageTree
)
Cat
.
getManager
().
getThreadLocalMessageTree
();
tree
.
setDomain
(
"FrontEnd"
);
tree
.
setHostName
(
String
.
valueOf
(
host
)
);
tree
.
setIpAddress
(
String
.
valueOf
(
host
)
);
tree
.
setHostName
(
host
);
tree
.
setIpAddress
(
host
);
model
.
setStatus
(
"SUCCESS"
);
model
.
setAction
(
Action
.
VIEW
);
model
.
setPage
(
ReportPage
.
PUSH
ERROR
);
model
.
setPage
(
ReportPage
.
JS
ERROR
);
m_jspViewer
.
view
(
ctx
,
model
);
}
}
cat-home/src/main/java/com/dianping/cat/report/page/
push
Error/JspFile.java
→
cat-home/src/main/java/com/dianping/cat/report/page/
js
Error/JspFile.java
浏览文件 @
3a4e9924
package
com.dianping.cat.report.page.
push
Error
;
package
com.dianping.cat.report.page.
js
Error
;
public
enum
JspFile
{
VIEW
(
"/jsp/report/
push
Error.jsp"
),
VIEW
(
"/jsp/report/
js
Error.jsp"
),
;
...
...
cat-home/src/main/java/com/dianping/cat/report/page/
push
Error/JspViewer.java
→
cat-home/src/main/java/com/dianping/cat/report/page/
js
Error/JspViewer.java
浏览文件 @
3a4e9924
package
com.dianping.cat.report.page.
push
Error
;
package
com.dianping.cat.report.page.
js
Error
;
import
com.dianping.cat.report.ReportPage
;
import
org.unidal.web.mvc.view.BaseJspViewer
;
...
...
cat-home/src/main/java/com/dianping/cat/report/page/
push
Error/Model.java
→
cat-home/src/main/java/com/dianping/cat/report/page/
js
Error/Model.java
浏览文件 @
3a4e9924
package
com.dianping.cat.report.page.
push
Error
;
package
com.dianping.cat.report.page.
js
Error
;
import
com.dianping.cat.report.ReportPage
;
import
org.unidal.web.mvc.ViewModel
;
...
...
cat-home/src/main/java/com/dianping/cat/report/page/
push
Error/Payload.java
→
cat-home/src/main/java/com/dianping/cat/report/page/
js
Error/Payload.java
浏览文件 @
3a4e9924
package
com.dianping.cat.report.page.
push
Error
;
package
com.dianping.cat.report.page.
js
Error
;
import
com.dianping.cat.report.ReportPage
;
import
org.unidal.web.mvc.ActionContext
;
...
...
@@ -20,14 +20,11 @@ public class Payload implements ActionPayload<ReportPage, Action> {
@FieldMeta
(
"file"
)
private
String
m_file
;
@FieldMeta
(
"url"
)
private
String
m_url
;
@FieldMeta
(
"host"
)
private
String
m_host
;
@FieldMeta
(
"line"
)
private
String
m_line
;
@FieldMeta
(
"data"
)
private
String
m_data
;
public
void
setAction
(
String
action
)
{
m_action
=
Action
.
getByName
(
action
,
Action
.
VIEW
);
...
...
@@ -45,7 +42,7 @@ public class Payload implements ActionPayload<ReportPage, Action> {
@Override
public
void
setPage
(
String
page
)
{
m_page
=
ReportPage
.
getByName
(
page
,
ReportPage
.
PUSH
ERROR
);
m_page
=
ReportPage
.
getByName
(
page
,
ReportPage
.
JS
ERROR
);
}
public
long
getTimestamp
()
{
...
...
@@ -72,22 +69,6 @@ public class Payload implements ActionPayload<ReportPage, Action> {
m_file
=
file
;
}
public
String
getUrl
()
{
return
m_url
;
}
public
void
setUrl
(
String
url
)
{
m_url
=
url
;
}
public
String
getHost
()
{
return
m_host
;
}
public
void
setHost
(
String
host
)
{
m_host
=
host
;
}
public
String
getLine
()
{
return
m_line
;
}
...
...
@@ -102,6 +83,13 @@ public class Payload implements ActionPayload<ReportPage, Action> {
m_action
=
Action
.
VIEW
;
}
}
public
String
getData
()
{
return
m_data
;
}
public
void
setData
(
String
data
)
{
m_data
=
data
;
}
}
cat-home/src/main/java/com/dianping/cat/report/page/metric/Handler.java
浏览文件 @
3a4e9924
...
...
@@ -34,11 +34,15 @@ public class Handler implements PageHandler<Context> {
private
MetricReport
getReport
(
Payload
payload
)
{
String
group
=
payload
.
getGroup
();
String
channel
=
payload
.
getChannel
();
group
=
"TuanGou"
;
String
date
=
String
.
valueOf
(
payload
.
getDate
());
ModelRequest
request
=
new
ModelRequest
(
group
,
payload
.
getPeriod
())
//
.
setProperty
(
"date"
,
date
);
if
(
channel
!=
null
)
{
request
.
setProperty
(
"channel"
,
channel
);
}
if
(
m_service
.
isEligable
(
request
))
{
ModelResponse
<
MetricReport
>
response
=
m_service
.
invoke
(
request
);
MetricReport
report
=
response
.
getModel
();
...
...
@@ -62,13 +66,11 @@ public class Handler implements PageHandler<Context> {
Payload
payload
=
ctx
.
getPayload
();
normalize
(
model
,
payload
);
MetricReport
report
=
getReport
(
payload
);
System
.
out
.
println
(
report
);
if
(
report
!=
null
)
{
MetricDisplay
display
=
new
MetricDisplay
(
buildTuanGouMetricConfig
(),
report
.
getStartTime
());
display
.
visitMetricReport
(
report
);
display
.
buildConvertRate
(
"/index"
,
"/detail"
,
MetricTitle
.
INDEX_DETAIL
);
display
.
buildConvertRate
(
"/detail"
,
"/order/submitOrder"
,
MetricTitle
.
DETAIL_PAY
);
model
.
setDisplay
(
display
);
model
.
setReport
(
report
);
}
...
...
@@ -101,6 +103,7 @@ public class Handler implements PageHandler<Context> {
model
.
setLongDate
(
payload
.
getDate
());
model
.
setDisplayDomain
(
payload
.
getDomain
());
model
.
setDomain
(
payload
.
getDomain
());
model
.
setGroup
(
payload
.
getGroup
());
}
public
class
MetricTitle
{
...
...
cat-home/src/main/java/com/dianping/cat/report/page/metric/Model.java
浏览文件 @
3a4e9924
...
...
@@ -14,6 +14,8 @@ public class Model extends AbstractReportModel<Action, Context> {
private
String
m_domain
;
private
String
m_group
;
public
Model
(
Context
ctx
)
{
super
(
ctx
);
}
...
...
@@ -52,4 +54,13 @@ public class Model extends AbstractReportModel<Action, Context> {
public
void
setReport
(
MetricReport
report
)
{
m_report
=
report
;
}
public
String
getGroup
()
{
return
m_group
;
}
public
void
setGroup
(
String
group
)
{
m_group
=
group
;
}
}
cat-home/src/main/java/com/dianping/cat/report/page/metric/Payload.java
浏览文件 @
3a4e9924
...
...
@@ -15,6 +15,9 @@ public class Payload extends AbstractReportPayload<Action> {
@FieldMeta
(
"op"
)
private
String
m_group
;
@FieldMeta
(
"channel"
)
private
String
m_channel
;
public
Payload
()
{
super
(
ReportPage
.
METRIC
);
}
...
...
@@ -46,6 +49,14 @@ public class Payload extends AbstractReportPayload<Action> {
m_page
=
ReportPage
.
getByName
(
page
,
ReportPage
.
METRIC
);
}
public
String
getChannel
()
{
return
m_channel
;
}
public
void
setChannel
(
String
channel
)
{
m_channel
=
channel
;
}
@Override
public
void
validate
(
ActionContext
<?>
ctx
)
{
if
(
m_action
==
null
)
{
...
...
cat-home/src/main/java/com/dianping/cat/report/page/model/Payload.java
浏览文件 @
3a4e9924
...
...
@@ -41,6 +41,9 @@ public class Payload implements ActionPayload<ReportPage, Action> {
@FieldMeta
(
"database"
)
private
String
m_database
;
@FieldMeta
(
"channel"
)
private
String
m_channel
;
@Override
public
Action
getAction
()
{
return
m_action
;
...
...
@@ -148,6 +151,14 @@ public class Payload implements ActionPayload<ReportPage, Action> {
m_waterfall
=
waterfall
;
}
public
String
getChannel
()
{
return
m_channel
;
}
public
void
setChannel
(
String
channel
)
{
m_channel
=
channel
;
}
@Override
public
void
validate
(
ActionContext
<?>
ctx
)
{
if
(
m_action
==
null
)
{
...
...
cat-home/src/main/java/com/dianping/cat/system/alarm/alert/AlertInfo.java
浏览文件 @
3a4e9924
...
...
@@ -8,15 +8,15 @@ public class AlertInfo {
public
static
final
String
EMAIL
=
"email"
;
public
static
final
int
EMAIL_TYPE
=
0
;
public
static
final
String
SMS
=
"sms"
;
public
static
final
String
EXCEPTION
=
"exception"
;
public
static
final
int
EMAIL_TYPE
=
1
;
public
static
final
String
SERVICE
=
"service"
;
public
static
final
int
SMS_TYPE
=
2
;
public
static
final
String
SMS
=
"sms
"
;
public
static
final
String
EXCEPTION
=
"exception
"
;
public
static
final
int
SMS_TYPE
=
1
;
public
static
final
String
SERVICE
=
"service"
;
private
int
m_alertType
;
...
...
@@ -31,7 +31,7 @@ public class AlertInfo {
private
int
m_ruleId
;
private
String
m_ruleType
;
private
String
m_title
;
public
int
getAlertType
()
{
...
...
@@ -108,4 +108,10 @@ public class AlertInfo {
return
this
;
}
@Override
public
String
toString
()
{
return
"AlertInfo [m_alertType="
+
m_alertType
+
", m_date="
+
m_date
+
", m_mails="
+
m_mails
+
", m_phones="
+
m_phones
+
", m_ruleId="
+
m_ruleId
+
", m_ruleType="
+
m_ruleType
+
", m_title="
+
m_title
+
"]"
;
}
}
cat-home/src/main/java/com/dianping/cat/system/alarm/alert/AlertManager.java
浏览文件 @
3a4e9924
...
...
@@ -5,6 +5,8 @@ import java.util.concurrent.BlockingQueue;
import
java.util.concurrent.LinkedBlockingQueue
;
import
java.util.concurrent.TimeUnit
;
import
org.codehaus.plexus.logging.LogEnabled
;
import
org.codehaus.plexus.logging.Logger
;
import
org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable
;
import
org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException
;
import
org.unidal.helper.Threads
;
...
...
@@ -17,7 +19,7 @@ import com.dianping.cat.home.dal.alarm.MailRecord;
import
com.dianping.cat.home.dal.alarm.MailRecordDao
;
import
com.dianping.cat.system.tool.MailSMS
;
public
class
AlertManager
implements
Initializable
{
public
class
AlertManager
implements
Initializable
,
LogEnabled
{
private
final
BlockingQueue
<
AlertInfo
>
m_alarmInfos
=
new
LinkedBlockingQueue
<
AlertInfo
>(
1000
);
...
...
@@ -30,6 +32,8 @@ public class AlertManager implements Initializable {
@Inject
private
MailSMS
m_mailSms
;
private
Logger
m_logger
;
public
void
addAlarmInfo
(
AlertInfo
info
)
{
m_alarmInfos
.
offer
(
info
);
}
...
...
@@ -79,10 +83,7 @@ public class AlertManager implements Initializable {
while
(
active
)
{
try
{
AlertInfo
entity
=
m_alarmInfos
.
poll
(
5
,
TimeUnit
.
MILLISECONDS
);
if
(
entity
!=
null
)
{
String
alarmType
=
entity
.
getRuleType
();
int
alertType
=
entity
.
getAlertType
();
String
title
=
entity
.
getTitle
();
String
content
=
entity
.
getContent
();
...
...
@@ -92,15 +93,25 @@ public class AlertManager implements Initializable {
List
<
String
>
mails
=
entity
.
getMails
();
sendResult
=
m_mailSms
.
sendEmail
(
title
,
content
,
mails
);
if
(!
sendResult
)
{
m_logger
.
error
(
String
.
format
(
"Error when send email %s to %s"
,
title
,
mails
));
}
}
else
if
(
alertType
==
AlertInfo
.
SMS_TYPE
)
{
List
<
String
>
phones
=
entity
.
getPhones
();
sendResult
=
m_mailSms
.
sendSMS
(
title
+
" "
+
content
,
phones
);
sendResult
=
m_mailSms
.
sendSMS
(
title
,
phones
);
if
(!
sendResult
)
{
m_logger
.
error
(
String
.
format
(
"Error when send sms %s to %s"
,
title
,
phones
));
}
}
else
{
Cat
.
logError
(
new
RuntimeException
(
"unexcepted alert type! type : "
+
alertType
));
}
String
ruleType
=
entity
.
getRuleType
();
if
(
alarm
Type
.
equals
(
AlertInfo
.
EXCEPTION
))
{
if
(
rule
Type
.
equals
(
AlertInfo
.
EXCEPTION
))
{
insert
(
entity
,
2
,
sendResult
);
}
else
if
(
alarm
Type
.
equals
(
AlertInfo
.
SERVICE
))
{
}
else
if
(
rule
Type
.
equals
(
AlertInfo
.
SERVICE
))
{
insert
(
entity
,
3
,
sendResult
);
}
}
else
{
...
...
@@ -121,4 +132,9 @@ public class AlertManager implements Initializable {
}
}
@Override
public
void
enableLogging
(
Logger
logger
)
{
m_logger
=
logger
;
}
}
cat-home/src/main/java/com/dianping/cat/system/alarm/threshold/ThresholdRule.java
浏览文件 @
3a4e9924
package
com.dianping.cat.system.alarm.threshold
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.Collection
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
org.unidal.lookup.logger.LoggerFactory
;
import
com.dianping.cat.helper.TimeUtil
;
import
com.dianping.cat.home.template.entity.Duration
;
import
com.dianping.cat.home.template.entity.Param
;
...
...
@@ -45,7 +47,7 @@ public class ThresholdRule {
int
length
=
durations
.
size
();
Date
date
=
entity
.
getDate
();
for
(
int
i
=
length
-
1
;
i
>
0
;
i
--)
{
for
(
int
i
=
length
-
1
;
i
>
=
0
;
i
--)
{
Duration
duration
=
durations
.
get
(
i
);
String
strategy
=
duration
.
getAlarm
();
...
...
@@ -69,6 +71,8 @@ public class ThresholdRule {
}
}
cleanData
(
getMaxInterval
(),
date
.
getTime
());
}
else
{
}
return
null
;
}
...
...
@@ -194,7 +198,12 @@ public class ThresholdRule {
}
private
boolean
validateData
(
ThresholdDataEntity
entity
)
{
if
(
entity
.
getDate
().
getTime
()
>
System
.
currentTimeMillis
())
{
Date
entityDate
=
entity
.
getDate
();
long
now
=
System
.
currentTimeMillis
()
+
TimeUtil
.
ONE_MINUTE
;
if
(
entityDate
.
getTime
()
>
now
)
{
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
LoggerFactory
.
getLogger
(
ThresholdRule
.
class
).
error
(
"date is invalidate!"
+
sdf
.
format
(
entity
.
getDate
())
+
" Now:"
+
sdf
.
format
(
new
Date
()));
return
false
;
}
if
(
m_lastData
==
null
)
{
...
...
@@ -206,10 +215,9 @@ public class ThresholdRule {
if
(
newCount
>
lastCount
)
{
return
true
;
}
else
{
Calendar
cal
=
Calendar
.
getInstance
()
;
cal
.
setTime
(
entity
.
getDate
(
));
long
current
=
entityDate
.
getTime
()
/
1000
/
60
;
int
minute
=
(
int
)
(
current
%
(
60
));
int
minute
=
cal
.
get
(
Calendar
.
MINUTE
);
if
(
minute
==
0
)
{
return
true
;
}
...
...
cat-home/src/main/java/com/dianping/cat/system/alarm/threshold/listener/ExceptionDataListener.java
浏览文件 @
3a4e9924
...
...
@@ -6,6 +6,7 @@ import org.unidal.lookup.annotation.Inject;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.message.Message
;
import
com.dianping.cat.message.Transaction
;
import
com.dianping.cat.system.alarm.alert.AlertInfo
;
import
com.dianping.cat.system.alarm.threshold.ThresholdDataEntity
;
import
com.dianping.cat.system.alarm.threshold.ThresholdRule
;
...
...
@@ -37,7 +38,6 @@ public class ExceptionDataListener implements EventListener {
@Override
public
void
onEvent
(
Event
event
)
{
ExceptionDataEvent
dataEvent
=
(
ExceptionDataEvent
)
event
;
ThresholdDataEntity
data
=
dataEvent
.
getData
();
List
<
ThresholdRule
>
rules
=
m_manager
.
getExceptionRuleByDomain
(
data
.
getDomain
());
...
...
@@ -45,13 +45,20 @@ public class ExceptionDataListener implements EventListener {
ThresholdAlarmMeta
alarmMeta
=
rule
.
addData
(
data
,
AlertInfo
.
EXCEPTION
);
if
(
alarmMeta
!=
null
)
{
Transaction
t
=
Cat
.
newTransaction
(
"SendAlarm"
,
"Exception"
);
t
.
addData
(
alarmMeta
.
toString
());
try
{
ThresholdAlertEvent
alertEvent
=
new
ThresholdAlertEvent
(
alarmMeta
);
Cat
.
getProducer
().
logEvent
(
"ExceptionAlarm"
,
"Domain"
,
Message
.
SUCCESS
,
alarmMeta
.
getRuleId
()
+
""
);
m_dispatcher
.
dispatch
(
alertEvent
);
t
.
setStatus
(
"Alarm"
);
}
catch
(
Exception
e
)
{
t
.
setStatus
(
e
);
Cat
.
logError
(
e
);
}
finally
{
t
.
complete
();
}
}
}
...
...
cat-home/src/main/java/com/dianping/cat/system/alarm/threshold/listener/ServiceDataListener.java
浏览文件 @
3a4e9924
...
...
@@ -55,6 +55,7 @@ public class ServiceDataListener implements EventListener {
Cat
.
getProducer
().
logEvent
(
"ServiceAlarm"
,
"Domain"
,
Message
.
SUCCESS
,
alarmMeta
.
getRuleId
()
+
""
);
m_dispatcher
.
dispatch
(
alertEvent
);
t
.
setStatus
(
Transaction
.
SUCCESS
);
t
.
setStatus
(
"Alarm"
);
}
catch
(
Exception
e
)
{
t
.
setStatus
(
e
);
}
finally
{
...
...
cat-home/src/main/java/com/dianping/cat/system/alarm/threshold/listener/ThresholdAlertListener.java
浏览文件 @
3a4e9924
...
...
@@ -50,7 +50,7 @@ public class ThresholdAlertListener implements EventListener, Initializable {
}
private
AlertInfo
buildAlertInfo
(
ThresholdAlarmMeta
meta
,
String
title
,
String
content
,
String
ruleType
,
List
<
String
>
address
)
{
int
alertType
)
{
AlertInfo
info
=
new
AlertInfo
();
info
.
setContent
(
content
);
...
...
@@ -58,7 +58,7 @@ public class ThresholdAlertListener implements EventListener, Initializable {
info
.
setRuleId
(
meta
.
getRuleId
());
info
.
setDate
(
meta
.
getDate
());
info
.
setRuleType
(
ruleType
);
info
.
set
Mails
(
address
);
info
.
set
AlertType
(
alertType
);
return
info
;
}
...
...
@@ -135,35 +135,35 @@ public class ThresholdAlertListener implements EventListener, Initializable {
@Override
public
void
onEvent
(
Event
event
)
{
ThresholdAlertEvent
alertEvent
=
(
ThresholdAlertEvent
)
event
;
ThresholdAlarmMeta
meta
=
alertEvent
.
getAlarmMeta
();
String
title
=
buildAlarmTitle
(
meta
);
String
content
=
buildEmailAlarmContent
(
meta
);
String
alertType
=
meta
.
getDuration
().
getAlarm
().
toLowerCase
();
String
ruleType
=
meta
.
getType
();
ThresholdAlarmMeta
meta
Info
=
alertEvent
.
getAlarmMeta
();
String
title
=
buildAlarmTitle
(
meta
Info
);
String
content
=
buildEmailAlarmContent
(
meta
Info
);
String
alertType
=
meta
Info
.
getDuration
().
getAlarm
().
toLowerCase
();
String
ruleType
=
meta
Info
.
getType
();
if
(
alertType
!=
null
&&
alertType
.
length
()
>
0
)
{
String
[]
types
=
alertType
.
split
(
","
);
for
(
String
type
:
types
)
{
if
(
type
.
equalsIgnoreCase
(
AlertInfo
.
EMAIL
))
{
List
<
String
>
address
=
m_ruleManager
.
queryUserMailsByRuleId
(
meta
.
getRuleId
());
AlertInfo
info
=
buildAlertInfo
(
meta
,
title
,
content
,
ruleType
,
address
);
List
<
String
>
emailAddress
=
m_ruleManager
.
queryUserMailsByRuleId
(
metaInfo
.
getRuleId
());
AlertInfo
info
=
buildAlertInfo
(
meta
Info
,
title
,
content
,
ruleType
,
AlertInfo
.
EMAIL_TYPE
);
info
.
set
AlertType
(
AlertInfo
.
EMAIL_TYPE
);
info
.
set
Mails
(
emailAddress
);
m_alertManager
.
addAlarmInfo
(
info
);
}
if
(
type
.
equalsIgnoreCase
(
AlertInfo
.
SMS
))
{
List
<
String
>
email
s
=
m_ruleManager
.
queryUserMailsByRuleId
(
meta
.
getRuleId
());
AlertInfo
emailsInfo
=
buildAlertInfo
(
meta
,
title
+
"[SMS]"
,
content
,
ruleType
,
emails
);
List
<
String
>
email
Address
=
m_ruleManager
.
queryUserMailsByRuleId
(
metaInfo
.
getRuleId
());
AlertInfo
info
=
buildAlertInfo
(
metaInfo
,
title
+
"[SMS]"
,
content
,
ruleType
,
AlertInfo
.
EMAIL_TYPE
);
emailsInfo
.
setAlertType
(
AlertInfo
.
EMAIL_TYPE
);
m_alertManager
.
addAlarmInfo
(
emailsI
nfo
);
info
.
setMails
(
emailAddress
);
m_alertManager
.
addAlarmInfo
(
i
nfo
);
List
<
String
>
address
=
m_ruleManager
.
queryUserPhonesByRuleId
(
meta
.
getRuleId
());
AlertInfo
info
=
buildAlertInfo
(
meta
,
title
,
content
,
ruleType
,
address
);
List
<
String
>
phoneAddress
=
m_ruleManager
.
queryUserPhonesByRuleId
(
metaInfo
.
getRuleId
());
AlertInfo
smsInfo
=
buildAlertInfo
(
metaInfo
,
title
,
content
,
ruleType
,
AlertInfo
.
SMS_TYPE
);
info
.
setAlertType
(
AlertInfo
.
SMS_TYPE
);
m_alertManager
.
addAlarmInfo
(
i
nfo
);
smsInfo
.
setPhones
(
phoneAddress
);
m_alertManager
.
addAlarmInfo
(
smsI
nfo
);
}
}
}
...
...
cat-home/src/main/java/com/dianping/cat/system/page/alarm/RuleManager.java
浏览文件 @
3a4e9924
...
...
@@ -154,7 +154,8 @@ public class RuleManager {
List
<
String
>
domains
=
new
ArrayList
<
String
>();
model
.
setDomains
(
domains
);
AlarmTemplate
template
=
queryTemplateByName
(
payload
.
getType
());
model
.
setAlarmTemplate
(
template
);
}
public
void
ruleAddSubmit
(
Payload
payload
,
Model
model
)
{
...
...
cat-home/src/main/java/com/dianping/cat/system/tool/MailSMSImpl.java
浏览文件 @
3a4e9924
...
...
@@ -65,6 +65,7 @@ public class MailSMSImpl implements MailSMS, Initializable, LogEnabled {
try
{
m_mailService
.
send
(
DEFAULT_EMAIL_TYPE
,
mail
,
title
,
content
);
sendResult
=
true
;
m_logger
.
info
(
"CAT send email to! "
+
mail
+
" title:"
+
title
);
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
...
...
cat-home/src/main/resources/META-INF/plexus/components.xml
浏览文件 @
3a4e9924
...
...
@@ -1524,6 +1524,11 @@
<component>
<role>
com.dianping.cat.report.page.home.JspViewer
</role>
<implementation>
com.dianping.cat.report.page.home.JspViewer
</implementation>
<requirements>
<requirement>
<role>
org.unidal.web.mvc.view.model.ModelHandler
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.consumer.RealtimeConsumer
</role>
...
...
@@ -1622,6 +1627,11 @@
<component>
<role>
com.dianping.cat.report.page.problem.JspViewer
</role>
<implementation>
com.dianping.cat.report.page.problem.JspViewer
</implementation>
<requirements>
<requirement>
<role>
org.unidal.web.mvc.view.model.ModelHandler
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.report.page.transaction.Handler
</role>
...
...
@@ -1667,6 +1677,11 @@
<component>
<role>
com.dianping.cat.report.page.transaction.JspViewer
</role>
<implementation>
com.dianping.cat.report.page.transaction.JspViewer
</implementation>
<requirements>
<requirement>
<role>
org.unidal.web.mvc.view.model.ModelHandler
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.report.page.transaction.XmlViewer
</role>
...
...
@@ -1713,6 +1728,11 @@
<component>
<role>
com.dianping.cat.report.page.event.JspViewer
</role>
<implementation>
com.dianping.cat.report.page.event.JspViewer
</implementation>
<requirements>
<requirement>
<role>
org.unidal.web.mvc.view.model.ModelHandler
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.report.page.heartbeat.Handler
</role>
...
...
@@ -1755,6 +1775,11 @@
<component>
<role>
com.dianping.cat.report.page.heartbeat.JspViewer
</role>
<implementation>
com.dianping.cat.report.page.heartbeat.JspViewer
</implementation>
<requirements>
<requirement>
<role>
org.unidal.web.mvc.view.model.ModelHandler
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.report.page.logview.Handler
</role>
...
...
@@ -1776,6 +1801,11 @@
<component>
<role>
com.dianping.cat.report.page.logview.JspViewer
</role>
<implementation>
com.dianping.cat.report.page.logview.JspViewer
</implementation>
<requirements>
<requirement>
<role>
org.unidal.web.mvc.view.model.ModelHandler
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.report.page.ip.Handler
</role>
...
...
@@ -1797,6 +1827,11 @@
<component>
<role>
com.dianping.cat.report.page.ip.JspViewer
</role>
<implementation>
com.dianping.cat.report.page.ip.JspViewer
</implementation>
<requirements>
<requirement>
<role>
org.unidal.web.mvc.view.model.ModelHandler
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.report.page.model.Handler
</role>
...
...
@@ -1875,6 +1910,11 @@
<component>
<role>
com.dianping.cat.report.page.model.JspViewer
</role>
<implementation>
com.dianping.cat.report.page.model.JspViewer
</implementation>
<requirements>
<requirement>
<role>
org.unidal.web.mvc.view.model.ModelHandler
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.report.page.model.event.LocalEventService
</role>
...
...
@@ -2116,6 +2156,11 @@
<component>
<role>
com.dianping.cat.report.page.sql.JspViewer
</role>
<implementation>
com.dianping.cat.report.page.sql.JspViewer
</implementation>
<requirements>
<requirement>
<role>
org.unidal.web.mvc.view.model.ModelHandler
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.report.page.heatmap.Handler
</role>
...
...
@@ -2141,6 +2186,11 @@
<component>
<role>
com.dianping.cat.report.page.heatmap.JspViewer
</role>
<implementation>
com.dianping.cat.report.page.heatmap.JspViewer
</implementation>
<requirements>
<requirement>
<role>
org.unidal.web.mvc.view.model.ModelHandler
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.report.page.dashboard.Handler
</role>
...
...
@@ -2169,6 +2219,11 @@
<component>
<role>
com.dianping.cat.report.page.dashboard.JspViewer
</role>
<implementation>
com.dianping.cat.report.page.dashboard.JspViewer
</implementation>
<requirements>
<requirement>
<role>
org.unidal.web.mvc.view.model.ModelHandler
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.report.page.task.Handler
</role>
...
...
@@ -2188,6 +2243,11 @@
<component>
<role>
com.dianping.cat.report.page.task.JspViewer
</role>
<implementation>
com.dianping.cat.report.page.task.JspViewer
</implementation>
<requirements>
<requirement>
<role>
org.unidal.web.mvc.view.model.ModelHandler
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.report.task.spi.ReportFacade
</role>
...
...
@@ -2663,6 +2723,11 @@
<component>
<role>
com.dianping.cat.report.page.matrix.JspViewer
</role>
<implementation>
com.dianping.cat.report.page.matrix.JspViewer
</implementation>
<requirements>
<requirement>
<role>
org.unidal.web.mvc.view.model.ModelHandler
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.report.page.health.Handler
</role>
...
...
@@ -2685,6 +2750,11 @@
<component>
<role>
com.dianping.cat.report.page.health.JspViewer
</role>
<implementation>
com.dianping.cat.report.page.health.JspViewer
</implementation>
<requirements>
<requirement>
<role>
org.unidal.web.mvc.view.model.ModelHandler
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.report.page.health.HistoryGraphs
</role>
...
...
@@ -2721,6 +2791,11 @@
<component>
<role>
com.dianping.cat.report.page.cross.JspViewer
</role>
<implementation>
com.dianping.cat.report.page.cross.JspViewer
</implementation>
<requirements>
<requirement>
<role>
org.unidal.web.mvc.view.model.ModelHandler
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.report.page.cache.Handler
</role>
...
...
@@ -2750,6 +2825,11 @@
<component>
<role>
com.dianping.cat.report.page.cache.JspViewer
</role>
<implementation>
com.dianping.cat.report.page.cache.JspViewer
</implementation>
<requirements>
<requirement>
<role>
org.unidal.web.mvc.view.model.ModelHandler
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.report.page.database.Handler
</role>
...
...
@@ -2771,6 +2851,11 @@
<component>
<role>
com.dianping.cat.report.page.database.JspViewer
</role>
<implementation>
com.dianping.cat.report.page.database.JspViewer
</implementation>
<requirements>
<requirement>
<role>
org.unidal.web.mvc.view.model.ModelHandler
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.report.page.state.Handler
</role>
...
...
@@ -2798,6 +2883,11 @@
<component>
<role>
com.dianping.cat.report.page.state.JspViewer
</role>
<implementation>
com.dianping.cat.report.page.state.JspViewer
</implementation>
<requirements>
<requirement>
<role>
org.unidal.web.mvc.view.model.ModelHandler
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.report.page.state.StateGraphs
</role>
...
...
@@ -2823,6 +2913,11 @@
<component>
<role>
com.dianping.cat.report.page.query.JspViewer
</role>
<implementation>
com.dianping.cat.report.page.query.JspViewer
</implementation>
<requirements>
<requirement>
<role>
org.unidal.web.mvc.view.model.ModelHandler
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.report.page.top.Handler
</role>
...
...
@@ -2847,6 +2942,11 @@
<component>
<role>
com.dianping.cat.report.page.top.JspViewer
</role>
<implementation>
com.dianping.cat.report.page.top.JspViewer
</implementation>
<requirements>
<requirement>
<role>
org.unidal.web.mvc.view.model.ModelHandler
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.report.page.metric.Handler
</role>
...
...
@@ -2871,19 +2971,29 @@
<component>
<role>
com.dianping.cat.report.page.metric.JspViewer
</role>
<implementation>
com.dianping.cat.report.page.metric.JspViewer
</implementation>
<requirements>
<requirement>
<role>
org.unidal.web.mvc.view.model.ModelHandler
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.report.page.
push
Error.Handler
</role>
<implementation>
com.dianping.cat.report.page.
push
Error.Handler
</implementation>
<role>
com.dianping.cat.report.page.
js
Error.Handler
</role>
<implementation>
com.dianping.cat.report.page.
js
Error.Handler
</implementation>
<requirements>
<requirement>
<role>
com.dianping.cat.report.page.
push
Error.JspViewer
</role>
<role>
com.dianping.cat.report.page.
js
Error.JspViewer
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.report.page.pushError.JspViewer
</role>
<implementation>
com.dianping.cat.report.page.pushError.JspViewer
</implementation>
<role>
com.dianping.cat.report.page.jsError.JspViewer
</role>
<implementation>
com.dianping.cat.report.page.jsError.JspViewer
</implementation>
<requirements>
<requirement>
<role>
org.unidal.web.mvc.view.model.ModelHandler
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.system.SystemModule
</role>
...
...
@@ -2913,6 +3023,11 @@
<component>
<role>
com.dianping.cat.system.page.alarm.JspViewer
</role>
<implementation>
com.dianping.cat.system.page.alarm.JspViewer
</implementation>
<requirements>
<requirement>
<role>
org.unidal.web.mvc.view.model.ModelHandler
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.system.page.alarm.RecordManager
</role>
...
...
@@ -3049,6 +3164,11 @@
<component>
<role>
com.dianping.cat.system.page.login.JspViewer
</role>
<implementation>
com.dianping.cat.system.page.login.JspViewer
</implementation>
<requirements>
<requirement>
<role>
org.unidal.web.mvc.view.model.ModelHandler
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.system.page.login.service.SigninService
</role>
...
...
@@ -3109,6 +3229,11 @@
<component>
<role>
com.dianping.cat.system.page.project.JspViewer
</role>
<implementation>
com.dianping.cat.system.page.project.JspViewer
</implementation>
<requirements>
<requirement>
<role>
org.unidal.web.mvc.view.model.ModelHandler
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dainping.cat.consumer.dal.report.ProjectDao
</role>
...
...
cat-home/src/main/resources/META-INF/wizard/webapp/wizard.xml
浏览文件 @
3a4e9924
...
...
@@ -65,8 +65,8 @@
<page
name=
"metric"
title=
"Metric"
path=
"metric"
>
<description>
Metric
</description>
</page>
<page
name=
"
pushError"
title=
"PushError"
path=
"push
Error"
>
<description>
Push
Error
</description>
<page
name=
"
jsError"
title=
"JsError"
path=
"js
Error"
>
<description>
js
Error
</description>
</page>
</module>
<module
name=
"system"
path=
"s"
default=
"false"
>
...
...
cat-home/src/main/webapp/jsp/report/jsError.jsp
0 → 100644
浏览文件 @
3a4e9924
<%@ page
contentType=
"text/html; charset=utf-8"
%>
<jsp:useBean
id=
"ctx"
type=
"com.dianping.cat.report.page.jsError.Context"
scope=
"request"
/>
<jsp:useBean
id=
"payload"
type=
"com.dianping.cat.report.page.jsError.Payload"
scope=
"request"
/>
<jsp:useBean
id=
"model"
type=
"com.dianping.cat.report.page.jsError.Model"
scope=
"request"
/>
${model.status}
\ No newline at end of file
cat-home/src/main/webapp/jsp/report/metric.jsp
浏览文件 @
3a4e9924
...
...
@@ -35,10 +35,10 @@
</c:forEach>
<c:forEach
var=
"item"
items=
"
${
model
.
display
.
conversionRates
}
"
varStatus=
"status"
>
/*
<c:forEach
var=
"item"
items=
"
${
model
.
display
.
conversionRates
}
"
varStatus=
"status"
>
var data = ${item.jsonString};
graph(document.getElementById('${item.title}'), data);
</c:forEach>
</c:forEach>
*/
});
...
...
@@ -61,10 +61,9 @@
<div
class=
"span2"
>
<div
class=
"well sidebar-nav"
>
<ul
class=
"nav nav-list"
>
<li
class=
"nav-header"
>
业务监控
</li>
<li
class=
"active"
><a
href=
"#"
>
团购
</a></li>
<li><a
href=
"#"
>
ToDo
</a></li>
<li><a
href=
"#"
>
ToDo
</a></li>
<li
class=
"nav-header active"
><a
href=
"#"
>
团购
</a></li>
<li><a
href=
"?date=${model.date}&group=${model.group}&channel=1"
>
团800
</a></li>
<li><a
href=
"#"
>
搜索引擎
</a></li>
</ul>
</div>
<!--/.well -->
</div>
<!--/span-->
...
...
@@ -73,12 +72,12 @@
<div
style=
"float:left;"
id=
"${item.title}"
class=
"graph"
></div>
</c:forEach>
</div>
<div
class=
"span10 offset1"
>
<
%-- <
div class="span10 offset1">
<h3 class='text-center'>页面实时转化率</h3>
<c:forEach var="item" items="${model.display.conversionRates}" varStatus="status">
<div style="float:left;" id="${item.title}" class="graph"></div>
</c:forEach>
</div>
</div>
--%>
<table
class=
"footer"
>
<tr>
<td>
[ end ]
</td>
...
...
cat-home/src/main/webapp/jsp/system/alarmRuleAdd.jsp
浏览文件 @
3a4e9924
...
...
@@ -8,23 +8,71 @@
<jsp:useBean
id=
"payload"
type=
"com.dianping.cat.system.page.alarm.Payload"
scope=
"request"
/>
<jsp:useBean
id=
"model"
type=
"com.dianping.cat.system.page.alarm.Model"
scope=
"request"
/>
<form
name=
"alarmAdd"
id=
"form"
method=
"post"
action=
"${model.pageUri}?op=alarmRuleAddSubmit"
>
<table
border=
"0"
>
<tr>
<td>
模板名称
</td>
<td><input
type=
"type"
name=
"type"
value=
"${payload.type}"
readonly
/></td>
</tr>
<tr>
<td>
项目名称
</td>
<td><input
type=
"domain"
name=
"domain"
/></td>
</tr>
<tr>
<td>
自定义内容
</td>
<td><textarea
style=
"height:500px;width:500px"
id=
"content"
name=
"content"
></textarea></td>
</tr>
<tr>
<td>
</td>
<td><input
type=
"submit"
name=
"submit"
value=
"submit"
/></td>
</tr>
</table>
</form>
\ No newline at end of file
<a:body>
<res:useCss
value=
"
${
res
.
css
.
local
[
'bootstrap.css'
]
}
"
target=
"head-css"
/>
<res:useJs
value=
"
${
res
.
js
.
local
[
'bootstrap.min.js'
]
}
"
target=
"head-js"
/>
<div
class=
"row-fluid"
>
<div
class=
"span6"
>
<form
name=
"alarmModify"
id=
"form"
method=
"post"
action=
"${model.pageUri}?op=alarmRuleUpdateSubmit"
>
<table
class=
"table table table-striped table-bordered"
>
<tr>
<td>
模板名称
</td>
<td><input
type=
"type"
name=
"type"
value=
"${payload.type}"
readonly
/></td>
</tr>
<tr>
<td>
项目名称
</td>
<td><input
type=
"domain"
name=
"domain"
/></td>
</tr>
<tr>
<td>
自定义内容
</td>
<td><textarea
style=
"height: 500px; width: 500px"
id=
"content"
name=
"content"
></textarea></td>
</tr>
<tr>
<td
colspan=
"2"
style=
"text-align: center"
><input
type=
"submit"
class=
'btn-small btn-primary'
name=
"submit"
value=
"submit"
/></td>
</tr>
</table>
</form>
</div>
<div
class=
"span6"
>
<h3
class=
'text-error text-error'
>
样本内容(可以copy右侧内容修改简单参数即可)
</h3>
<xmp>
${model.alarmTemplate.content}
</xmp>
<h3
class=
'text-error'
>
说明事项
</h3>
<table
class=
"table table table-striped table-bordered"
>
<tr>
<td
class=
"text-error"
>
interval
</td>
<td>
定义一段时间
</td>
</tr>
<tr>
<td
class=
"text-error"
>
min
</td>
<td>
一段时间内出现错误的最小值
</td>
</tr>
<tr>
<td
class=
"text-error"
>
max
</td>
<td>
一段时间内出现错误的最大值
</td>
</tr>
<tr>
<td
class=
"text-error"
>
alarm-interval
</td>
<td>
表示在此时间段内告警一次
</td>
</tr>
<tr>
<td
class=
"text-error"
>
alarm
</td>
<td>
表示告警类型,暂时支持EMAIL和SMS,多种用逗号隔开
</td>
</tr>
</table>
<h3
class=
'text-error'
>
解释说明duration1
</h3>
<xmp><duration
id=
"duration1"
min=
"50"
max=
"250"
interval=
"3"
alarm-interval=
"30"
alarm=
"EMAIL"
/></xmp>
<p
class=
"text-warning"
>
duration1表示在一定的3分钟时间内错误出现在50到250之间之间,会发email告警,在30分钟内只会告警一次。
</p>
<h3
class=
'text-error'
>
解释说明duration2
</h3>
<xmp><duration
id=
"duration2"
min=
"250"
max=
"2500000"
interval=
"3"
alarm-interval=
"120"
alarm=
"SMS"
/></xmp>
<p
class=
"text-warning"
>
duration2表示在一定的3分钟时间内错误出现在250到2500000之间之间,会发SMS告警,在120分钟内只会告警一次。(目前SMS不启作用,仍然会用邮件,邮件标题有SMS)
</p>
</div>
</div>
</a:body>
\ No newline at end of file
cat-home/src/main/webapp/jsp/system/alarmRuleUpdate.jsp
浏览文件 @
3a4e9924
...
...
@@ -8,31 +8,68 @@
<jsp:useBean
id=
"payload"
type=
"com.dianping.cat.system.page.alarm.Payload"
scope=
"request"
/>
<jsp:useBean
id=
"model"
type=
"com.dianping.cat.system.page.alarm.Model"
scope=
"request"
/>
<form
name=
"alarmModify"
id=
"form"
method=
"post"
action=
"${model.pageUri}?op=alarmRuleUpdateSubmit"
>
<table
border=
"1"
align=
"center"
width=
"100%"
rules=
"all"
>
<input
type=
"hidden"
name=
"alarmRuleId"
value=
"${model.alarmRule.id}"
/>
<tr>
<td>
项目名称
</td>
<td
colspan=
'2'
>
${model.alarmRule.domain}
</td>
</tr>
<tr>
<td>
样本内容
</td>
<td><textarea
style=
"height:200px;width:600px"
readonly
>
${model.alarmTemplate.content}
</textarea></td>
<td>
min-最小值、max-最大值,interval表示时间段、alarm-interval表示在此时间段内告警一次,alarm表示告警类型,暂时支持EMAIL和SMS,多中用逗号隔开。
<xmp><duration
id=
"duration1"
min=
"50"
max=
"250"
interval=
"3"
alarm-interval=
"30"
alarm=
"EMAIL"
/></xmp>
duration1表示在一定的3分钟时间内错误出现在50到250之间之间,会发email告警,在30分钟内只会告警一次。
<xmp>
<duration
id=
"duration2"
min=
"250"
max=
"2500000"
interval=
"3"
alarm-interval=
"120"
alarm=
"SMS"
/></xmp>
duration2表示在一定的3分钟时间内错误出现在250到2500000之间之间,会发SMS告警,在120分钟内只会告警一次。(目前SMS不启作用,仍然会用邮件,邮件标题有SMS)
</td>
</tr>
<tr>
<td>
自定义内容
</td>
<td><textarea
style=
"height:200px;width:600px"
id=
"content"
name=
"content"
>
${model.alarmRule.content}
</textarea></td>
<td>
可以Coyp样本内容,修改duration1或者duration2中的min、max、interval、alarm-interval值即可
</td>
</tr>
<tr>
<td
colspan=
"3"
align=
"center"
><input
type=
"submit"
name=
"submit"
value=
"submit"
/></td>
</tr>
</table>
</form>
\ No newline at end of file
<a:body>
<res:useCss
value=
"
${
res
.
css
.
local
[
'bootstrap.css'
]
}
"
target=
"head-css"
/>
<res:useJs
value=
"
${
res
.
js
.
local
[
'bootstrap.min.js'
]
}
"
target=
"head-js"
/>
<div
class=
"row-fluid"
>
<div
class=
"span6"
>
<form
name=
"alarmModify"
id=
"form"
method=
"post"
action=
"${model.pageUri}?op=alarmRuleUpdateSubmit"
>
<table
class=
"table table table-striped table-bordered"
>
<input
type=
"hidden"
name=
"alarmRuleId"
value=
"${model.alarmRule.id}"
/>
<tr>
<td>
项目名称
</td>
<td>
${model.alarmRule.domain}
</td>
</tr>
<tr>
<td>
自定义内容
</td>
<td><textarea
style=
"height: 500px; width: 500px"
id=
"content"
name=
"content"
>
${model.alarmRule.content}
</textarea></td>
</tr>
<tr>
<td
colspan=
"2"
style=
"text-align: center"
><input
type=
"submit"
class=
'btn-small btn-primary'
name=
"submit"
value=
"submit"
/></td>
</tr>
</table>
</form>
</div>
<div
class=
"span6"
>
<h3
class=
'text-error text-error'
>
样本内容(可以copy右侧内容修改简单参数即可)
</h3>
<xmp>
${model.alarmTemplate.content}
</xmp>
<h3
class=
'text-error'
>
说明事项
</h3>
<table
class=
"table table table-striped table-bordered"
>
<tr>
<td
class=
"text-error"
>
interval
</td>
<td>
定义一段时间
</td>
</tr>
<tr>
<td
class=
"text-error"
>
min
</td>
<td>
一段时间内出现错误的最小值
</td>
</tr>
<tr>
<td
class=
"text-error"
>
max
</td>
<td>
一段时间内出现错误的最大值
</td>
</tr>
<tr>
<td
class=
"text-error"
>
alarm-interval
</td>
<td>
表示在此时间段内告警一次
</td>
</tr>
<tr>
<td
class=
"text-error"
>
alarm
</td>
<td>
表示告警类型,暂时支持EMAIL和SMS,多种用逗号隔开
</td>
</tr>
</table>
<h3
class=
'text-error'
>
解释说明duration1
</h3>
<xmp><duration
id=
"duration1"
min=
"50"
max=
"250"
interval=
"3"
alarm-interval=
"30"
alarm=
"EMAIL"
/></xmp>
<p
class=
"text-warning"
>
duration1表示在一定的3分钟时间内错误出现在50到250之间之间,会发email告警,在30分钟内只会告警一次。
</p>
<h3
class=
'text-error'
>
解释说明duration2
</h3>
<xmp><duration
id=
"duration2"
min=
"250"
max=
"2500000"
interval=
"3"
alarm-interval=
"120"
alarm=
"SMS"
/></xmp>
<p
class=
"text-warning"
>
duration2表示在一定的3分钟时间内错误出现在250到2500000之间之间,会发SMS告警,在120分钟内只会告警一次。(目前SMS不启作用,仍然会用邮件,邮件标题有SMS)
</p>
</div>
</div>
</a:body>
cat-home/src/test/java/com/dianping/cat/demo/TestBusinessMessage.java
浏览文件 @
3a4e9924
...
...
@@ -8,27 +8,28 @@ import com.dianping.cat.message.Transaction;
public
class
TestBusinessMessage
{
@Test
public
void
test
()
throws
Exception
{
while
(
true
)
{
public
void
test
()
throws
Exception
{
while
(
true
)
{
for
(
int
i
=
0
;
i
<
1000
;
i
++)
{
Transaction
t
=
Cat
.
newTransaction
(
"URL"
,
"/index"
);
Cat
.
logMetric
(
"order"
,
"quantity"
,
i
);
Cat
.
logMetric
(
"order"
,
"quantity"
,
i
);
t
.
addData
(
"channel="
+
i
%
5
);
t
.
complete
();
}
for
(
int
i
=
0
;
i
<
900
;
i
++)
{
Transaction
t
=
Cat
.
newTransaction
(
"URL"
,
"/detail"
);
Cat
.
logMetric
(
"payment.pending"
,
"amount"
,
i
);
Cat
.
logMetric
(
"payment.pending"
,
"amount"
,
i
,
"channel"
,
i
%
5
);
t
.
complete
();
}
for
(
int
i
=
0
;
i
<
500
;
i
++)
{
Transaction
t
=
Cat
.
newTransaction
(
"URL"
,
"/order/submitOrder"
);
Cat
.
logMetric
(
"payment.success"
,
"amount"
,
i
);
Cat
.
logMetric
(
"payment.success"
,
"amount"
,
i
,
"channel"
,
i
%
5
);
t
.
complete
();
}
Thread
.
sleep
(
10000
);
}
}
...
...
cat-home/src/test/java/com/dianping/cat/demo/TestMaxMessage.java
浏览文件 @
3a4e9924
...
...
@@ -14,14 +14,15 @@ public class TestMaxMessage {
@Test
public
void
testSend
()
throws
Exception
{
for
(
int
i
=
0
;
i
<
100
;
i
++)
{
for
(
int
i
=
0
;
i
<
100
00
;
i
++)
{
Transaction
t
=
Cat
.
getProducer
().
newTransaction
(
"CatTest"
,
"CatTest"
+
i
%
10
);
t
.
setStatus
(
Message
.
SUCCESS
);
Cat
.
getProducer
().
newEvent
(
"Cache.kvdb"
,
"Method"
+
i
%
10
+
":missed"
);
Cat
.
logError
(
new
NullPointerException
());
t
.
addData
(
"key and value"
);
t
.
complete
();
}
Thread
.
sleep
(
10
*
100
);
Thread
.
sleep
(
10
*
100
0
);
}
@Test
...
...
cat-home/src/test/java/com/dianping/cat/demo/TestSendMessage.java
浏览文件 @
3a4e9924
...
...
@@ -11,7 +11,7 @@ public class TestSendMessage {
@Test
public
void
sendException
()
throws
Exception
{
for
(
int
i
=
0
;
i
<
10
0
;
i
++)
{
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
Cat
.
getProducer
().
logError
(
new
OutOfMemoryError
());
Cat
.
getProducer
().
logError
(
new
NullPointerException
());
}
...
...
cat-home/src/test/java/com/dianping/cat/report/page/
pushError/PushError
Test.java
→
cat-home/src/test/java/com/dianping/cat/report/page/
jsError/Js
Test.java
浏览文件 @
3a4e9924
package
com.dianping.cat.report.page.
push
Error
;
package
com.dianping.cat.report.page.
js
Error
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
...
...
@@ -6,13 +6,16 @@ import java.net.URLConnection;
import
org.junit.Test
;
public
class
PushError
Test
{
public
class
Js
Test
{
@Test
public
void
test
()
throws
Exception
{
for
(
int
i
=
0
;
i
<
1000
;
i
++)
{
URL
url
=
new
URL
(
buildUrl
());
URL
url
=
new
URL
(
buildUrl
(
i
));
URLConnection
URLconnection
=
url
.
openConnection
();
URLconnection
.
setRequestProperty
(
"User-Agent"
,
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Maxthon;)"
);
URLconnection
.
setRequestProperty
(
"referer"
,
"http://www.dianping.com/shop/1"
);
HttpURLConnection
httpConnection
=
(
HttpURLConnection
)
URLconnection
;
int
responseCode
=
httpConnection
.
getResponseCode
();
...
...
@@ -23,14 +26,16 @@ public class PushErrorTest {
}
}
private
String
buildUrl
()
{
private
String
buildUrl
(
int
i
)
{
StringBuilder
sb
=
new
StringBuilder
(
128
);
sb
.
append
(
"http://
127.0.0.1:2281/cat/r/push
Error?"
);
sb
.
append
(
"http://
cat.qa.dianpingoa.com/cat/r/js
Error?"
);
sb
.
append
(
"error=testError1"
);
sb
.
append
(
"&host=t.dianping.com"
);
sb
.
append
(
"&file=testFile"
);
if
(
i
%
10
==
0
)
{
sb
.
append
(
"&file="
);
}
else
{
sb
.
append
(
"&file=testFile"
+
i
%
5
);
}
sb
.
append
(
"×tamp"
+
System
.
currentTimeMillis
());
sb
.
append
(
"&url=test.url"
);
sb
.
append
(
"&line=line98"
);
return
sb
.
toString
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录