Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
558c2f14
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,发现更多精彩内容 >>
提交
558c2f14
编写于
8月 20, 2014
作者:
J
jialinsun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
pass monitor modify, app data daily report alarm
上级
45f63d29
变更
33
隐藏空白更改
内联
并排
Showing
33 changed file
with
732 addition
and
35 deletion
+732
-35
cat-agent/src/main/webapp/paas-monitor.py
cat-agent/src/main/webapp/paas-monitor.py
+5
-9
cat-core/pom.xml
cat-core/pom.xml
+1
-0
cat-core/src/main/java/com/dianping/cat/build/ComponentsConfigurator.java
...n/java/com/dianping/cat/build/ComponentsConfigurator.java
+3
-0
cat-core/src/main/java/com/dianping/cat/config/app/AppComparisonConfigManager.java
...m/dianping/cat/config/app/AppComparisonConfigManager.java
+116
-0
cat-core/src/main/java/com/dianping/cat/config/app/AppDataService.java
...main/java/com/dianping/cat/config/app/AppDataService.java
+22
-8
cat-core/src/main/resources/META-INF/dal/model/app-comparison-config-codegen.xml
...rces/META-INF/dal/model/app-comparison-config-codegen.xml
+16
-0
cat-core/src/main/resources/META-INF/dal/model/app-comparison-config-manifest.xml
...ces/META-INF/dal/model/app-comparison-config-manifest.xml
+6
-0
cat-core/src/main/resources/META-INF/dal/model/app-comparison-config-model.xml
...ources/META-INF/dal/model/app-comparison-config-model.xml
+16
-0
cat-core/src/main/resources/META-INF/plexus/components.xml
cat-core/src/main/resources/META-INF/plexus/components.xml
+9
-0
cat-core/src/main/resources/META-INF/wizard/model/wizard.xml
cat-core/src/main/resources/META-INF/wizard/model/wizard.xml
+4
-1
cat-home/src/main/java/com/dianping/cat/CatHomeModule.java
cat-home/src/main/java/com/dianping/cat/CatHomeModule.java
+1
-1
cat-home/src/main/java/com/dianping/cat/build/AlarmComponentConfigurator.java
...va/com/dianping/cat/build/AlarmComponentConfigurator.java
+12
-1
cat-home/src/main/java/com/dianping/cat/build/ComponentsConfigurator.java
...n/java/com/dianping/cat/build/ComponentsConfigurator.java
+2
-2
cat-home/src/main/java/com/dianping/cat/report/page/system/graph/SystemGraphCreator.java
...ping/cat/report/page/system/graph/SystemGraphCreator.java
+3
-3
cat-home/src/main/java/com/dianping/cat/report/task/alert/sender/decorator/ExceptionDecorator.java
...eport/task/alert/sender/decorator/ExceptionDecorator.java
+1
-2
cat-home/src/main/java/com/dianping/cat/report/task/alert/sender/decorator/ProjectDecorator.java
.../report/task/alert/sender/decorator/ProjectDecorator.java
+1
-1
cat-home/src/main/java/com/dianping/cat/report/task/alert/sender/decorator/ThirdpartyDecorator.java
...port/task/alert/sender/decorator/ThirdpartyDecorator.java
+1
-2
cat-home/src/main/java/com/dianping/cat/report/task/alert/summary/AlertSummaryFTLDecorator.java
...t/report/task/alert/summary/AlertSummaryFTLDecorator.java
+1
-2
cat-home/src/main/java/com/dianping/cat/system/notify/AppDataComparisonNotifier.java
...dianping/cat/system/notify/AppDataComparisonNotifier.java
+243
-0
cat-home/src/main/java/com/dianping/cat/system/notify/AppDataComparisonResult.java
...m/dianping/cat/system/notify/AppDataComparisonResult.java
+58
-0
cat-home/src/main/java/com/dianping/cat/system/notify/ScheduledMailTask.java
...ava/com/dianping/cat/system/notify/ScheduledMailTask.java
+8
-2
cat-home/src/main/java/com/dianping/cat/system/notify/render/AppDataComparisonRender.java
...ing/cat/system/notify/render/AppDataComparisonRender.java
+50
-0
cat-home/src/main/java/com/dianping/cat/system/page/config/Action.java
...main/java/com/dianping/cat/system/page/config/Action.java
+2
-0
cat-home/src/main/java/com/dianping/cat/system/page/config/Handler.java
...ain/java/com/dianping/cat/system/page/config/Handler.java
+12
-1
cat-home/src/main/java/com/dianping/cat/system/page/config/JspFile.java
...ain/java/com/dianping/cat/system/page/config/JspFile.java
+2
-0
cat-home/src/main/java/com/dianping/cat/system/page/config/JspViewer.java
...n/java/com/dianping/cat/system/page/config/JspViewer.java
+2
-0
cat-home/src/main/resources/META-INF/plexus/components.xml
cat-home/src/main/resources/META-INF/plexus/components.xml
+43
-0
cat-home/src/main/resources/config/default-app-comparison-config.xml
...c/main/resources/config/default-app-comparison-config.xml
+10
-0
cat-home/src/main/resources/freemaker/appDataComparison.ftl
cat-home/src/main/resources/freemaker/appDataComparison.ftl
+21
-0
cat-home/src/main/webapp/WEB-INF/tags/body.tag
cat-home/src/main/webapp/WEB-INF/tags/body.tag
+1
-0
cat-home/src/main/webapp/jsp/system/appComparisonConfig/appComparisonConfig.jsp
...pp/jsp/system/appComparisonConfig/appComparisonConfig.jsp
+49
-0
cat-home/src/main/webapp/jsp/system/configTree.jsp
cat-home/src/main/webapp/jsp/system/configTree.jsp
+1
-0
cat-home/src/test/resources/com/dianping/cat/system/config/appComparisonConfig.xml
...es/com/dianping/cat/system/config/appComparisonConfig.xml
+10
-0
未找到文件。
cat-agent/src/main/webapp/paas-monitor.py
浏览文件 @
558c2f14
...
...
@@ -49,12 +49,12 @@ def get_created(inspect_info):
def
get_name
(
inspect_info
):
return
re
.
sub
(
r
'(^/|_
\d
+$)'
,
''
,
inspect_info
[
'Name'
])
return
re
.
sub
(
r
'(^/|_
.
+$)'
,
''
,
inspect_info
[
'Name'
])
def
get_cpu_usage
(
metric_info
):
if
'current_usage'
in
metric_info
[
'cpu_stats'
][
'cpu_usage'
]:
return
metric_info
[
'cpu_stats'
][
'cpu_usage'
][
'c
pu
_usage'
]
return
metric_info
[
'cpu_stats'
][
'cpu_usage'
][
'c
urrent
_usage'
]
return
0
...
...
@@ -86,13 +86,11 @@ def get_container_info(pid):
disk_usage
=
docker_command
(
pid
,
'df -h | grep "rootfs"'
)
disk_usage
=
re
.
split
(
r
'\s+'
,
disk_usage
.
strip
())[
-
2
][:
-
1
]
disk_usage
=
int
(
disk_usage
)
*
1.0
/
100
ssh_md5
=
docker_command
(
pid
,
'md5sum /usr/sbin/sshd'
)
ssh_md5
=
re
.
split
(
r
'\s+'
,
ssh_md5
.
strip
())[
0
]
eth0_rx
,
eth0_tx
,
eth0_errors
,
eth0_dropped
,
eth0_collision
=
get_network_info
(
pid
,
'eth0'
)
lo_rx
,
lo_tx
,
lo_errors
,
lo_dropped
,
lo_collision
=
get_network_info
(
pid
,
'lo'
)
return
disk_usage
,
ssh_md5
,
eth0_rx
,
eth0_tx
,
eth0_errors
,
eth0_dropped
,
eth0_collision
,
\
return
disk_usage
,
eth0_rx
,
eth0_tx
,
eth0_errors
,
eth0_dropped
,
eth0_collision
,
\
lo_rx
,
lo_tx
,
lo_errors
,
lo_dropped
,
lo_collision
...
...
@@ -159,7 +157,7 @@ def get_all_info(current_instance=None):
metric_info
=
instance_metric
(
instance_id
)
pid
=
inspect_info
[
'State'
][
'Pid'
]
disk_usage
,
ssh_md5
,
eth0_rx
,
eth0_tx
,
eth0_errors
,
eth0_dropped
,
eth0_collision
,
lo_rx
,
lo_tx
,
\
disk_usage
,
eth0_rx
,
eth0_tx
,
eth0_errors
,
eth0_dropped
,
eth0_collision
,
lo_rx
,
lo_tx
,
\
lo_errors
,
lo_dropped
,
lo_collision
=
get_container_info
(
pid
)
ip
=
get_ip
(
inspect_info
)
mem_total
,
mem_used
,
mem_cached
,
mem_free
,
mem_shared
,
mem_buffered
=
get_memory_info
(
metric_info
,
instance_id
)
...
...
@@ -170,7 +168,7 @@ def get_all_info(current_instance=None):
m
=
[
(
'domain'
,
''
,
get_name
(
inspect_info
)),
(
'system_
userCpu
'
,
'avg'
,
'%.3f'
%
(
float
(
get_cpu_usage
(
metric_info
)))),
(
'system_
cpuUsage
'
,
'avg'
,
'%.3f'
%
(
float
(
get_cpu_usage
(
metric_info
)))),
(
'system_cachedMem'
,
'avg'
,
mem_cached
),
(
'system_totalMem'
,
'avg'
,
mem_total
),
(
'system_usedMem'
,
'avg'
,
mem_used
),
...
...
@@ -179,8 +177,6 @@ def get_all_info(current_instance=None):
(
'system_buffersMem'
,
'avg'
,
mem_buffered
),
(
'system_/-usage'
,
'avg'
,
disk_usage
),
(
'system_swapUsage'
,
'avg'
,
get_swap_usage
(
metric_info
)),
(
'system_md5Change'
,
'avg'
,
ssh_md5
),
(
'system_uptime'
,
'avg'
,
get_created
(
inspect_info
)),
(
'system_eth0-outFlow'
,
'sum'
,
eth0_tx
),
(
'system_eth0-inFlow'
,
'sum'
,
eth0_rx
),
(
'system_eth0-dropped'
,
'sum'
,
eth0_dropped
),
...
...
cat-core/pom.xml
浏览文件 @
558c2f14
...
...
@@ -70,6 +70,7 @@
${basedir}/src/main/resources/META-INF/dal/model/url-pattern-manifest.xml,
${basedir}/src/main/resources/META-INF/dal/model/aggreation-manifest.xml,
${basedir}/src/main/resources/META-INF/dal/model/app-config-manifest.xml,
${basedir}/src/main/resources/META-INF/dal/model/app-comparison-config-manifest.xml,
</manifest>
</configuration>
</execution>
...
...
cat-core/src/main/java/com/dianping/cat/build/ComponentsConfigurator.java
浏览文件 @
558c2f14
...
...
@@ -15,6 +15,7 @@ import com.dianping.cat.app.AppDataCommandDao;
import
com.dianping.cat.config.aggregation.AggregationConfigManager
;
import
com.dianping.cat.config.aggregation.AggregationHandler
;
import
com.dianping.cat.config.aggregation.DefaultAggregationHandler
;
import
com.dianping.cat.config.app.AppComparisonConfigManager
;
import
com.dianping.cat.config.app.AppConfigManager
;
import
com.dianping.cat.config.app.AppDataService
;
import
com.dianping.cat.config.url.DefaultUrlPatternHandler
;
...
...
@@ -64,6 +65,8 @@ public class ComponentsConfigurator extends AbstractResourceConfigurator {
all
.
add
(
C
(
AppConfigManager
.
class
).
req
(
ConfigDao
.
class
));
all
.
add
(
C
(
AppComparisonConfigManager
.
class
).
req
(
ConfigDao
.
class
));
all
.
add
(
C
(
AppDataService
.
class
).
req
(
AppConfigManager
.
class
,
AppDataCommandDao
.
class
));
all
.
add
(
C
(
UrlPatternHandler
.
class
,
DefaultUrlPatternHandler
.
class
));
...
...
cat-core/src/main/java/com/dianping/cat/config/app/AppComparisonConfigManager.java
0 → 100644
浏览文件 @
558c2f14
package
com.dianping.cat.config.app
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
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.configuration.appComparison.entity.AppComparison
;
import
com.dianping.cat.configuration.appComparison.entity.AppComparisonConfig
;
import
com.dianping.cat.configuration.appComparison.transform.DefaultSaxParser
;
import
com.dianping.cat.core.config.Config
;
import
com.dianping.cat.core.config.ConfigDao
;
import
com.dianping.cat.core.config.ConfigEntity
;
import
com.site.helper.Splitters
;
public
class
AppComparisonConfigManager
implements
Initializable
{
@Inject
private
ConfigDao
m_configDao
;
private
AppComparisonConfig
m_config
;
private
static
final
String
CONFIG_NAME
=
"appComparisonConfig"
;
private
int
m_configId
;
public
AppComparisonConfig
getConfig
()
{
return
m_config
;
}
@Override
public
void
initialize
()
throws
InitializationException
{
try
{
Config
config
=
m_configDao
.
findByName
(
CONFIG_NAME
,
ConfigEntity
.
READSET_FULL
);
String
content
=
config
.
getContent
();
m_configId
=
config
.
getId
();
m_config
=
DefaultSaxParser
.
parse
(
content
);
}
catch
(
DalNotFoundException
e
)
{
try
{
String
content
=
Files
.
forIO
().
readFrom
(
this
.
getClass
().
getResourceAsStream
(
"/config/default-app-comparison-config.xml"
),
"utf-8"
);
Config
config
=
m_configDao
.
createLocal
();
config
.
setName
(
CONFIG_NAME
);
config
.
setContent
(
content
);
m_configDao
.
insert
(
config
);
m_configId
=
config
.
getId
();
m_config
=
DefaultSaxParser
.
parse
(
content
);
}
catch
(
Exception
ex
)
{
Cat
.
logError
(
ex
);
}
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
}
public
Map
<
String
,
AppComparison
>
queryAppComparisons
()
{
return
m_config
.
getAppComparisons
();
}
public
List
<
String
>
queryEmails
(
String
id
)
{
List
<
String
>
emails
=
new
ArrayList
<
String
>();
AppComparison
appComparison
=
m_config
.
getAppComparisons
().
get
(
id
);
if
(
appComparison
!=
null
)
{
emails
.
addAll
(
Splitters
.
by
(
","
).
noEmptyItem
().
split
(
appComparison
.
getEmails
()));
}
return
emails
;
}
public
String
queryEmailStr
(
String
id
)
{
AppComparison
appComparison
=
m_config
.
getAppComparisons
().
get
(
id
);
if
(
appComparison
!=
null
)
{
return
appComparison
.
getEmails
();
}
return
null
;
}
public
boolean
insert
(
String
xml
)
{
try
{
m_config
=
DefaultSaxParser
.
parse
(
xml
);
return
storeConfig
();
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
return
false
;
}
}
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_config
.
toString
());
m_configDao
.
updateByPK
(
config
,
ConfigEntity
.
UPDATESET_FULL
);
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
return
false
;
}
}
return
true
;
}
}
cat-core/src/main/java/com/dianping/cat/config/app/AppDataService.java
浏览文件 @
558c2f14
...
...
@@ -124,7 +124,7 @@ public class AppDataService {
}
public
Double
[]
querySuccessRatio
(
int
commandId
,
AppDataCommandMap
convertedData
)
{
int
n
=
convertedData
.
get
MaxSize
();
int
n
=
convertedData
.
get
Duration
();
Double
[]
value
=
new
Double
[
n
];
for
(
int
i
=
0
;
i
<
n
;
i
++)
{
...
...
@@ -170,7 +170,7 @@ public class AppDataService {
}
public
Double
[]
queryRequestCount
(
AppDataCommandMap
convertedData
)
{
int
n
=
convertedData
.
get
MaxSize
();
int
n
=
convertedData
.
get
Duration
();
Double
[]
value
=
new
Double
[
n
];
for
(
Entry
<
Integer
,
List
<
AppDataCommand
>>
entry
:
convertedData
.
getAppDataCommands
().
entrySet
())
{
...
...
@@ -187,7 +187,7 @@ public class AppDataService {
}
public
Double
[]
queryDelayAvg
(
AppDataCommandMap
convertedData
)
{
int
n
=
convertedData
.
get
MaxSize
();
int
n
=
convertedData
.
get
Duration
();
Double
[]
value
=
new
Double
[
n
];
for
(
Entry
<
Integer
,
List
<
AppDataCommand
>>
entry
:
convertedData
.
getAppDataCommands
().
entrySet
())
{
...
...
@@ -206,21 +206,35 @@ public class AppDataService {
return
value
;
}
public
double
queryOneDayDelayAvg
(
QueryEntity
entity
)
{
Double
[]
values
=
queryValue
(
entity
,
DELAY
);
double
delaySum
=
0
;
int
size
=
0
;
for
(
int
i
=
0
;
i
<
values
.
length
;
i
++)
{
if
(
values
[
i
]
!=
null
)
{
delaySum
+=
values
[
i
];
size
++;
}
}
return
size
>
0
?
delaySum
/
size
:
-
1
;
}
public
class
AppDataCommandMap
{
private
int
m_
maxSize
;
private
int
m_
duration
;
private
Map
<
Integer
,
List
<
AppDataCommand
>>
m_appDataCommands
;
public
int
get
MaxSize
()
{
return
m_
maxSize
;
public
int
get
Duration
()
{
return
m_
duration
;
}
public
Map
<
Integer
,
List
<
AppDataCommand
>>
getAppDataCommands
()
{
return
m_appDataCommands
;
}
public
AppDataCommandMap
(
int
maxSize
,
Map
<
Integer
,
List
<
AppDataCommand
>>
appDataCommands
)
{
m_
maxSize
=
maxSize
;
public
AppDataCommandMap
(
int
duration
,
Map
<
Integer
,
List
<
AppDataCommand
>>
appDataCommands
)
{
m_
duration
=
duration
;
m_appDataCommands
=
appDataCommands
;
}
}
...
...
cat-core/src/main/resources/META-INF/dal/model/app-comparison-config-codegen.xml
0 → 100644
浏览文件 @
558c2f14
<?xml version="1.0" encoding="UTF-8"?>
<model>
<entity
name=
"app-comparison-config"
root=
"true"
>
<entity-ref
name=
"app-comparison"
type=
"list"
names=
"app-comparisons"
/>
</entity>
<entity
name=
"app-comparison"
>
<attribute
name=
"id"
value-type=
"String"
/>
<attribute
name=
"emails"
value-type=
"String"
/>
<entity-ref
name=
"item"
type=
"list"
names=
"items"
/>
</entity>
<entity
name=
"item"
>
<attribute
name=
"id"
value-type=
"String"
/>
<attribute
name=
"command"
value-type=
"String"
/>
</entity>
</model>
cat-core/src/main/resources/META-INF/dal/model/app-comparison-config-manifest.xml
0 → 100644
浏览文件 @
558c2f14
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<file
path=
"app-comparison-config-codegen.xml"
/>
<file
path=
"app-comparison-config-model.xml"
/>
</manifest>
cat-core/src/main/resources/META-INF/dal/model/app-comparison-config-model.xml
0 → 100644
浏览文件 @
558c2f14
<?xml version="1.0" encoding="UTF-8"?>
<model
model-package=
"com.dianping.cat.configuration.appComparison"
enable-sax-parser=
"true"
>
<entity
name=
"app-comparison-config"
root=
"true"
>
<entity-ref
name=
"app-comparison"
type=
"map"
names=
"app-comparisons"
/>
</entity>
<entity
name=
"app-comparison"
>
<attribute
name=
"id"
value-type=
"String"
key=
"true"
/>
<entity-ref
name=
"item"
type=
"list"
names=
"items"
/>
<attribute
name=
"emails"
value-type=
"String"
/>
</entity>
<entity
name=
"item"
>
<attribute
name=
"id"
value-type=
"String"
/>
<attribute
name=
"command"
value-type=
"String"
/>
</entity>
</model>
cat-core/src/main/resources/META-INF/plexus/components.xml
浏览文件 @
558c2f14
...
...
@@ -85,6 +85,15 @@
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.config.app.AppComparisonConfigManager
</role>
<implementation>
com.dianping.cat.config.app.AppComparisonConfigManager
</implementation>
<requirements>
<requirement>
<role>
com.dianping.cat.core.config.ConfigDao
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.config.app.AppDataService
</role>
<implementation>
com.dianping.cat.config.app.AppDataService
</implementation>
...
...
cat-core/src/main/resources/META-INF/wizard/model/wizard.xml
浏览文件 @
558c2f14
...
...
@@ -4,6 +4,9 @@
<sample-model>
src/test/resources/com/dianping/cat/message/configuration/server.xml
</sample-model>
</model>
<model
package=
"com.dianping.cat.home.app"
name=
"app"
>
<sample-model>
src/test/resources/com/dianping/cat/system/config/appConfig.xml
</sample-model>
<sample-model>
../cat-home/src/test/resources/com/dianping/cat/system/config/appConfig.xml
</sample-model>
</model>
<model
package=
"com.dianping.cat.appComparisonConfig"
name=
"app-comparison-config"
>
<sample-model>
../cat-home/src/test/resources/com/dianping/cat/system/config/appComparisonConfig.xml
</sample-model>
</model>
</wizard>
cat-home/src/main/java/com/dianping/cat/CatHomeModule.java
浏览文件 @
558c2f14
...
...
@@ -74,7 +74,7 @@ public class CatHomeModule extends AbstractModule {
private
void
executeAlarmModule
(
ModuleContext
ctx
)
throws
Exception
{
ServerConfigManager
serverConfigManager
=
ctx
.
lookup
(
ServerConfigManager
.
class
);
ScheduledMailTask
scheduledTask
=
ctx
.
lookup
(
ScheduledMailTask
.
class
);
Threads
.
forGroup
(
"Cat"
).
start
(
scheduledTask
);
if
(
serverConfigManager
.
isJobMachine
()
&&
!
serverConfigManager
.
isLocalMode
())
{
Threads
.
forGroup
(
"Cat"
).
start
(
scheduledTask
);
}
...
...
cat-home/src/main/java/com/dianping/cat/build/AlarmComponentConfigurator.java
浏览文件 @
558c2f14
...
...
@@ -6,12 +6,17 @@ import java.util.List;
import
org.unidal.lookup.configuration.AbstractResourceConfigurator
;
import
org.unidal.lookup.configuration.Component
;
import
com.dianping.cat.config.app.AppComparisonConfigManager
;
import
com.dianping.cat.config.app.AppConfigManager
;
import
com.dianping.cat.config.app.AppDataService
;
import
com.dianping.cat.home.dal.alarm.MailRecordDao
;
import
com.dianping.cat.report.service.ReportServiceManager
;
import
com.dianping.cat.report.task.alert.sender.sender.SenderManager
;
import
com.dianping.cat.system.notify.AppDataComparisonNotifier
;
import
com.dianping.cat.system.notify.ReportRender
;
import
com.dianping.cat.system.notify.ReportRenderImpl
;
import
com.dianping.cat.system.notify.ScheduledMailTask
;
import
com.dianping.cat.system.notify.render.AppDataComparisonRender
;
import
com.dianping.cat.system.page.alarm.ScheduledManager
;
class
AlarmComponentConfigurator
extends
AbstractResourceConfigurator
{
...
...
@@ -21,10 +26,16 @@ class AlarmComponentConfigurator extends AbstractResourceConfigurator {
all
.
add
(
C
(
ReportRender
.
class
,
ReportRenderImpl
.
class
));
all
.
add
(
C
(
AppDataComparisonRender
.
class
));
all
.
add
(
C
(
AppDataComparisonNotifier
.
class
).
req
(
AppDataService
.
class
)
.
req
(
AppComparisonConfigManager
.
class
,
AppConfigManager
.
class
)
.
req
(
SenderManager
.
class
,
MailRecordDao
.
class
,
AppDataComparisonRender
.
class
));
all
.
add
(
C
(
ScheduledMailTask
.
class
).
//
req
(
ReportRender
.
class
,
SenderManager
.
class
)
//
.
req
(
ReportServiceManager
.
class
,
ScheduledManager
.
class
)
//
.
req
(
MailRecordDao
.
class
));
.
req
(
MailRecordDao
.
class
,
AppDataComparisonNotifier
.
class
));
return
all
;
}
...
...
cat-home/src/main/java/com/dianping/cat/build/ComponentsConfigurator.java
浏览文件 @
558c2f14
...
...
@@ -337,8 +337,8 @@ public class ComponentsConfigurator extends AbstractResourceConfigurator {
all
.
add
(
C
(
AlertEntityService
.
class
).
req
(
AlertDao
.
class
));
all
.
add
(
C
(
AlertSummaryExecutor
.
class
).
req
(
AlertSummaryGenerator
.
class
,
AlertSummaryManager
.
class
,
SenderManager
.
class
)
.
req
(
AlertSummaryDecorator
.
class
,
AlertSummaryFTLDecorator
.
ID
));
all
.
add
(
C
(
AlertSummaryExecutor
.
class
).
req
(
AlertSummaryGenerator
.
class
,
AlertSummaryManager
.
class
,
SenderManager
.
class
)
.
req
(
AlertSummaryDecorator
.
class
,
AlertSummaryFTLDecorator
.
ID
));
all
.
add
(
C
(
AlertSummaryDecorator
.
class
,
AlertSummaryFTLDecorator
.
ID
,
AlertSummaryFTLDecorator
.
class
));
...
...
cat-home/src/main/java/com/dianping/cat/report/page/system/graph/SystemGraphCreator.java
浏览文件 @
558c2f14
...
...
@@ -67,9 +67,9 @@ public class SystemGraphCreator extends AbstractGraphCreator {
String
type
=
pars
.
get
(
"type"
);
if
(
PAAS_SYSTEM
.
equals
(
type
))
{
type
=
SYSTEM_TYPE
;
pars
.
put
(
"type"
,
type
);
type
=
PAAS_SYSTEM
;
pars
.
put
(
"type"
,
SYSTEM_TYPE
);
}
return
type
;
}
...
...
cat-home/src/main/java/com/dianping/cat/report/task/alert/sender/decorator/ExceptionDecorator.java
浏览文件 @
558c2f14
...
...
@@ -12,7 +12,6 @@ import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationExce
import
com.dianping.cat.Cat
;
import
com.dianping.cat.report.task.alert.AlertType
;
import
com.dianping.cat.report.task.alert.sender.AlertEntity
;
import
com.dianping.cat.system.notify.ReportRenderImpl
;
import
freemarker.template.Configuration
;
import
freemarker.template.Template
;
...
...
@@ -69,7 +68,7 @@ public class ExceptionDecorator extends ProjectDecorator implements Initializabl
m_configuration
=
new
Configuration
();
m_configuration
.
setDefaultEncoding
(
"UTF-8"
);
try
{
m_configuration
.
setClassForTemplateLoading
(
ReportRenderImpl
.
class
,
"/freemaker"
);
m_configuration
.
setClassForTemplateLoading
(
this
.
getClass
()
,
"/freemaker"
);
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
...
...
cat-home/src/main/java/com/dianping/cat/report/task/alert/sender/decorator/ProjectDecorator.java
浏览文件 @
558c2f14
...
...
@@ -31,7 +31,7 @@ public abstract class ProjectDecorator extends DefaultDecorator {
return
builder
.
toString
();
}
}
catch
(
Exception
ex
)
{
Cat
.
logError
(
"build project contact info error for do
am
in: "
+
domainName
,
ex
);
Cat
.
logError
(
"build project contact info error for do
ma
in: "
+
domainName
,
ex
);
}
return
""
;
...
...
cat-home/src/main/java/com/dianping/cat/report/task/alert/sender/decorator/ThirdpartyDecorator.java
浏览文件 @
558c2f14
...
...
@@ -12,7 +12,6 @@ import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationExce
import
com.dianping.cat.Cat
;
import
com.dianping.cat.report.task.alert.AlertType
;
import
com.dianping.cat.report.task.alert.sender.AlertEntity
;
import
com.dianping.cat.system.notify.ReportRenderImpl
;
import
freemarker.template.Configuration
;
import
freemarker.template.Template
;
...
...
@@ -69,7 +68,7 @@ public class ThirdpartyDecorator extends ProjectDecorator implements Initializab
m_configuration
=
new
Configuration
();
m_configuration
.
setDefaultEncoding
(
"UTF-8"
);
try
{
m_configuration
.
setClassForTemplateLoading
(
ReportRenderImpl
.
class
,
"/freemaker"
);
m_configuration
.
setClassForTemplateLoading
(
this
.
getClass
()
,
"/freemaker"
);
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
...
...
cat-home/src/main/java/com/dianping/cat/report/task/alert/summary/AlertSummaryFTLDecorator.java
浏览文件 @
558c2f14
...
...
@@ -11,7 +11,6 @@ import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationExce
import
com.dianping.cat.Cat
;
import
com.dianping.cat.home.alert.summary.entity.AlertSummary
;
import
com.dianping.cat.system.notify.ReportRenderImpl
;
import
freemarker.template.Configuration
;
import
freemarker.template.Template
;
...
...
@@ -75,7 +74,7 @@ public class AlertSummaryFTLDecorator implements AlertSummaryDecorator, Initiali
m_configuration
=
new
Configuration
();
m_configuration
.
setDefaultEncoding
(
"UTF-8"
);
try
{
m_configuration
.
setClassForTemplateLoading
(
ReportRenderImpl
.
class
,
"/freemaker"
);
m_configuration
.
setClassForTemplateLoading
(
this
.
getClass
()
,
"/freemaker"
);
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
...
...
cat-home/src/main/java/com/dianping/cat/system/notify/AppDataComparisonNotifier.java
0 → 100644
浏览文件 @
558c2f14
package
com.dianping.cat.system.notify
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
java.util.Set
;
import
org.unidal.dal.jdbc.DalException
;
import
org.unidal.lookup.annotation.Inject
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.config.app.AppComparisonConfigManager
;
import
com.dianping.cat.config.app.AppConfigManager
;
import
com.dianping.cat.config.app.AppDataService
;
import
com.dianping.cat.config.app.QueryEntity
;
import
com.dianping.cat.configuration.appComparison.entity.AppComparison
;
import
com.dianping.cat.configuration.appComparison.entity.AppComparisonConfig
;
import
com.dianping.cat.configuration.appComparison.entity.Item
;
import
com.dianping.cat.helper.TimeUtil
;
import
com.dianping.cat.home.dal.alarm.MailRecord
;
import
com.dianping.cat.home.dal.alarm.MailRecordDao
;
import
com.dianping.cat.message.Transaction
;
import
com.dianping.cat.report.task.alert.sender.AlertChannel
;
import
com.dianping.cat.report.task.alert.sender.AlertMessageEntity
;
import
com.dianping.cat.report.task.alert.sender.sender.SenderManager
;
import
com.dianping.cat.system.notify.render.AppDataComparisonRender
;
import
com.site.helper.Splitters
;
import
com.site.lookup.util.StringUtils
;
public
class
AppDataComparisonNotifier
{
@Inject
private
AppDataService
m_appDataService
;
@Inject
private
AppComparisonConfigManager
m_appComparisonConfigManager
;
@Inject
private
AppConfigManager
m_appConfigManager
;
@Inject
private
SenderManager
m_sendManager
;
@Inject
private
MailRecordDao
m_mailRecordDao
;
@Inject
private
AppDataComparisonRender
m_render
;
private
SimpleDateFormat
m_sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
public
void
doNotifying
()
{
Date
yesterdayDate
=
TimeUtil
.
getYesterday
();
String
yesterday
=
m_sdf
.
format
(
yesterdayDate
);
Transaction
t
=
Cat
.
newTransaction
(
"AppDataComparitonInformer"
,
yesterday
);
try
{
Map
<
String
,
AppDataComparisonResult
>
results
=
buildAppDataComparisonResults
(
yesterdayDate
,
m_appComparisonConfigManager
.
getConfig
());
Map
<
List
<
String
>,
List
<
AppDataComparisonResult
>>
results2Receivers
=
buildReceivers2Results
(
results
);
for
(
Entry
<
List
<
String
>,
List
<
AppDataComparisonResult
>>
entry
:
results2Receivers
.
entrySet
())
{
notify
(
yesterdayDate
,
entry
.
getValue
(),
entry
.
getKey
());
}
t
.
setStatus
(
Transaction
.
SUCCESS
);
}
catch
(
Exception
e
)
{
t
.
setStatus
(
e
);
}
finally
{
t
.
complete
();
}
}
private
Set
<
String
>
buildAllUsers
(
Map
<
String
,
AppDataComparisonResult
>
results
)
{
Set
<
String
>
allUsers
=
new
HashSet
<
String
>();
for
(
Entry
<
String
,
AppDataComparisonResult
>
entry
:
results
.
entrySet
())
{
AppDataComparisonResult
result
=
entry
.
getValue
();
String
id
=
result
.
getId
();
allUsers
.
addAll
(
m_appComparisonConfigManager
.
queryEmails
(
id
));
}
return
allUsers
;
}
private
Map
<
String
,
String
>
buildUser2Ids
(
Set
<
String
>
allUsers
,
Map
<
String
,
AppDataComparisonResult
>
results
)
{
Map
<
String
,
String
>
user2Id
=
new
HashMap
<
String
,
String
>();
for
(
String
user
:
allUsers
)
{
for
(
Entry
<
String
,
AppDataComparisonResult
>
entry
:
results
.
entrySet
())
{
AppDataComparisonResult
result
=
entry
.
getValue
();
String
id
=
result
.
getId
();
String
emails
=
m_appComparisonConfigManager
.
queryEmailStr
(
id
);
if
(
emails
.
contains
(
user
))
{
String
ids
=
user2Id
.
get
(
user
);
if
(
StringUtils
.
isEmpty
(
ids
))
{
user2Id
.
put
(
user
,
id
);
}
else
{
user2Id
.
put
(
user
,
ids
+
";"
+
id
);
}
}
}
}
return
user2Id
;
}
private
Map
<
String
,
String
>
buildid2Users
(
Map
<
String
,
String
>
user2Id
)
{
Map
<
String
,
String
>
id2Users
=
new
HashMap
<
String
,
String
>();
for
(
Entry
<
String
,
String
>
entry
:
user2Id
.
entrySet
())
{
String
key
=
entry
.
getKey
();
String
value
=
entry
.
getValue
();
String
users
=
user2Id
.
get
(
value
);
if
(
StringUtils
.
isEmpty
(
users
))
{
id2Users
.
put
(
value
,
key
);
}
else
{
id2Users
.
put
(
value
,
users
+
";"
+
value
);
}
}
return
id2Users
;
}
private
Map
<
List
<
String
>,
List
<
AppDataComparisonResult
>>
buildReceivers2Results
(
Map
<
String
,
AppDataComparisonResult
>
results
)
{
Set
<
String
>
allUsers
=
buildAllUsers
(
results
);
Map
<
String
,
String
>
user2Ids
=
buildUser2Ids
(
allUsers
,
results
);
Map
<
String
,
String
>
id2Users
=
buildid2Users
(
user2Ids
);
Map
<
List
<
String
>,
List
<
AppDataComparisonResult
>>
users2Results
=
buildUsers2Results
(
id2Users
,
results
);
return
users2Results
;
}
private
Map
<
List
<
String
>,
List
<
AppDataComparisonResult
>>
buildUsers2Results
(
Map
<
String
,
String
>
id2Users
,
Map
<
String
,
AppDataComparisonResult
>
results
)
{
Map
<
List
<
String
>,
List
<
AppDataComparisonResult
>>
users2Results
=
new
HashMap
<
List
<
String
>,
List
<
AppDataComparisonResult
>>();
for
(
Entry
<
String
,
String
>
entry
:
id2Users
.
entrySet
())
{
List
<
String
>
emails
=
Splitters
.
by
(
";"
).
noEmptyItem
().
split
(
entry
.
getValue
());
List
<
String
>
ids
=
Splitters
.
by
(
";"
).
noEmptyItem
().
split
(
entry
.
getKey
());
List
<
AppDataComparisonResult
>
userResults
=
new
ArrayList
<
AppDataComparisonResult
>();
for
(
String
id
:
ids
)
{
userResults
.
add
(
results
.
get
(
id
));
}
users2Results
.
put
(
emails
,
userResults
);
}
return
users2Results
;
}
private
void
notify
(
Date
yesterday
,
List
<
AppDataComparisonResult
>
results
,
List
<
String
>
emails
)
{
String
title
=
renderTitle
();
String
content
=
m_render
.
renderReport
(
yesterday
,
results
);
AlertMessageEntity
message
=
new
AlertMessageEntity
(
null
,
title
,
"AppDataComparison"
,
content
,
emails
);
try
{
boolean
result
=
m_sendManager
.
sendAlert
(
AlertChannel
.
MAIL
,
message
);
insertMailLog
(-
1
,
content
,
title
,
result
,
emails
);
}
catch
(
DalException
e
)
{
Cat
.
logError
(
e
);
}
}
private
void
insertMailLog
(
int
reportId
,
String
content
,
String
title
,
boolean
result
,
List
<
String
>
emails
)
throws
DalException
{
MailRecord
entity
=
m_mailRecordDao
.
createLocal
();
entity
.
setTitle
(
title
);
entity
.
setContent
(
content
);
entity
.
setRuleId
(
reportId
);
entity
.
setType
(
1
);
entity
.
setReceivers
(
emails
.
toString
());
if
(
result
)
{
entity
.
setStatus
(
0
);
}
else
{
entity
.
setStatus
(
1
);
}
m_mailRecordDao
.
insert
(
entity
);
}
private
String
renderTitle
()
{
return
"CAT端到端报告"
;
}
private
Map
<
String
,
AppDataComparisonResult
>
buildAppDataComparisonResults
(
Date
date
,
AppComparisonConfig
config
)
{
Map
<
String
,
AppDataComparisonResult
>
results
=
new
LinkedHashMap
<
String
,
AppDataComparisonResult
>();
for
(
Entry
<
String
,
AppComparison
>
entry
:
config
.
getAppComparisons
().
entrySet
())
{
try
{
// AppDataComparisonResult result = queryDelay4AppComparison(date, appComparison);
AppDataComparisonResult
result
=
queryDelay4AppComparison
(
m_sdf
.
parse
(
"2014-07-18"
),
entry
.
getValue
());
results
.
put
(
entry
.
getKey
(),
result
);
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
}
return
results
;
}
private
AppDataComparisonResult
queryDelay4AppComparison
(
Date
yesterday
,
AppComparison
appComparison
)
{
String
id
=
appComparison
.
getId
();
AppDataComparisonResult
result
=
new
AppDataComparisonResult
();
result
.
setId
(
id
);
for
(
Item
item
:
appComparison
.
getItems
())
{
String
itemId
=
item
.
getId
();
String
command
=
item
.
getCommand
();
double
delay
=
queryOneDayDelay4Command
(
yesterday
,
command
);
if
(
delay
>
-
1
)
{
result
.
addItem
(
itemId
,
command
,
delay
);
}
}
return
result
;
}
private
double
queryOneDayDelay4Command
(
Date
yesterday
,
String
url
)
{
String
yesterdayStr
=
m_sdf
.
format
(
yesterday
);
Integer
command
=
m_appConfigManager
.
getCommands
().
get
(
url
);
if
(
command
!=
null
)
{
QueryEntity
entity
=
new
QueryEntity
(
yesterdayStr
+
";"
+
command
+
";;;;;;;"
);
return
m_appDataService
.
queryOneDayDelayAvg
(
entity
);
}
else
{
Cat
.
logError
(
new
RuntimeException
(
"AppComparison config has unrecognized command: "
+
url
));
return
-
1
;
}
}
}
cat-home/src/main/java/com/dianping/cat/system/notify/AppDataComparisonResult.java
0 → 100644
浏览文件 @
558c2f14
package
com.dianping.cat.system.notify
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
AppDataComparisonResult
{
private
String
m_id
;
private
List
<
AppDataComparisonItem
>
m_items
=
new
ArrayList
<
AppDataComparisonItem
>();
public
void
addItem
(
String
id
,
String
command
,
double
delay
)
{
m_items
.
add
(
new
AppDataComparisonItem
(
id
,
command
,
delay
));
}
public
List
<
AppDataComparisonItem
>
getItems
()
{
return
m_items
;
}
public
int
getSize
()
{
return
m_items
.
size
();
}
public
void
setId
(
String
id
)
{
m_id
=
id
;
}
public
String
getId
()
{
return
m_id
;
}
public
class
AppDataComparisonItem
{
private
String
m_id
;
private
String
m_command
;
private
double
m_delay
;
public
AppDataComparisonItem
(
String
id
,
String
command
,
double
delay
)
{
m_id
=
id
;
m_command
=
command
;
m_delay
=
delay
;
}
public
String
getId
()
{
return
m_id
;
}
public
String
getCommand
()
{
return
m_command
;
}
public
double
getDelay
()
{
return
m_delay
;
}
}
}
cat-home/src/main/java/com/dianping/cat/system/notify/ScheduledMailTask.java
浏览文件 @
558c2f14
...
...
@@ -49,6 +49,9 @@ public class ScheduledMailTask implements Task, LogEnabled {
@Inject
private
ScheduledManager
m_scheduledManager
;
@Inject
private
AppDataComparisonNotifier
m_appDataInformer
;
private
SimpleDateFormat
m_sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
private
Logger
m_logger
;
...
...
@@ -126,8 +129,10 @@ public class ScheduledMailTask implements Task, LogEnabled {
}
long
currentDay
=
TimeUtil
.
getCurrentDay
().
getTime
();
Calendar
cal
=
Calendar
.
getInstance
();
m_appDataInformer
.
doNotifying
();
if
(
lastSendMailTime
<
currentDay
&&
cal
.
get
(
Calendar
.
HOUR_OF_DAY
)
>=
2
)
{
// m_appDataInformer.doNotifying();
List
<
ScheduledReport
>
reports
=
m_scheduledManager
.
queryScheduledReports
();
m_logger
.
info
(
"Send daily report starting! size :"
+
reports
.
size
());
...
...
@@ -162,13 +167,14 @@ public class ScheduledMailTask implements Task, LogEnabled {
Cat
.
logError
(
e
);
}
try
{
Thread
.
sleep
(
TimeUtil
.
ONE_HOUR
);
// Thread.sleep(TimeUtil.ONE_HOUR);
Thread
.
sleep
(
10000
);
}
catch
(
Exception
e
)
{
active
=
false
;
}
}
}
@Override
public
void
shutdown
()
{
}
...
...
cat-home/src/main/java/com/dianping/cat/system/notify/render/AppDataComparisonRender.java
0 → 100644
浏览文件 @
558c2f14
package
com.dianping.cat.system.notify.render
;
import
java.io.StringWriter
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable
;
import
org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.system.notify.AppDataComparisonResult
;
import
freemarker.template.Configuration
;
import
freemarker.template.Template
;
public
class
AppDataComparisonRender
implements
Initializable
{
private
Configuration
m_configuration
;
@Override
public
void
initialize
()
throws
InitializationException
{
m_configuration
=
new
Configuration
();
m_configuration
.
setDefaultEncoding
(
"UTF-8"
);
try
{
m_configuration
.
setClassForTemplateLoading
(
this
.
getClass
(),
"/freemaker"
);
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
}
public
String
renderReport
(
Date
yesterday
,
List
<
AppDataComparisonResult
>
results
)
{
Map
<
Object
,
Object
>
root
=
new
HashMap
<
Object
,
Object
>();
root
.
put
(
"results"
,
results
);
root
.
put
(
"yesterday"
,
yesterday
.
toString
());
root
.
put
(
"date"
,
new
Date
().
toString
());
StringWriter
sw
=
new
StringWriter
(
5000
);
try
{
Template
t
=
m_configuration
.
getTemplate
(
"appDataComparison.ftl"
);
t
.
process
(
root
,
sw
);
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
return
sw
.
toString
();
}
}
cat-home/src/main/java/com/dianping/cat/system/page/config/Action.java
浏览文件 @
558c2f14
...
...
@@ -99,6 +99,8 @@ public enum Action implements org.unidal.web.mvc.Action {
APP_CONFIG_UPDATE
(
"appConfigUpdate"
),
APP_COMPARISON_CONFIG_UPDATE
(
"appComparisonConfigUpdate"
),
THIRD_PARTY_CONFIG_UPDATE
(
"thirdPartyConfigUpdate"
),
ROUTER_CONFIG_UPDATE
(
"routerConfigUpdate"
);
...
...
cat-home/src/main/java/com/dianping/cat/system/page/config/Handler.java
浏览文件 @
558c2f14
...
...
@@ -26,6 +26,7 @@ import com.dianping.cat.Cat;
import
com.dianping.cat.Constants
;
import
com.dianping.cat.advanced.metric.config.entity.MetricItemConfig
;
import
com.dianping.cat.config.aggregation.AggregationConfigManager
;
import
com.dianping.cat.config.app.AppComparisonConfigManager
;
import
com.dianping.cat.config.app.AppConfigManager
;
import
com.dianping.cat.config.url.UrlPatternConfigManager
;
import
com.dianping.cat.configuration.aggreation.model.entity.AggregationRule
;
...
...
@@ -106,6 +107,9 @@ public class Handler implements PageHandler<Context> {
@Inject
private
AppConfigManager
m_appConfigManager
;
@Inject
private
AppComparisonConfigManager
m_appComparisonConfigManager
;
@Inject
private
DomainNavManager
m_manager
;
...
...
@@ -123,7 +127,7 @@ public class Handler implements PageHandler<Context> {
@Inject
private
RouterConfigManager
m_routerConfigManager
;
private
void
deleteAggregationRule
(
Payload
payload
)
{
m_aggreationConfigManager
.
deleteAggregationRule
(
payload
.
getPattern
());
}
...
...
@@ -486,6 +490,13 @@ public class Handler implements PageHandler<Context> {
}
model
.
setContent
(
m_appConfigManager
.
getConfig
().
toString
());
break
;
case
APP_COMPARISON_CONFIG_UPDATE:
String
appComparisonConfig
=
payload
.
getContent
();
if
(!
StringUtils
.
isEmpty
(
appComparisonConfig
))
{
model
.
setOpState
(
m_appComparisonConfigManager
.
insert
(
appComparisonConfig
));
}
model
.
setContent
(
m_appComparisonConfigManager
.
getConfig
().
toString
());
break
;
case
THIRD_PARTY_CONFIG_UPDATE:
String
thirdPartyConfig
=
payload
.
getContent
();
if
(!
StringUtils
.
isEmpty
(
thirdPartyConfig
))
{
...
...
cat-home/src/main/java/com/dianping/cat/system/page/config/JspFile.java
浏览文件 @
558c2f14
...
...
@@ -65,6 +65,8 @@ public enum JspFile {
APP_CONFIG_UPDATE
(
"/jsp/system/appConfig/appConfig.jsp"
),
APP_COMPARISON_CONFIG_UPDATE
(
"/jsp/system/appComparisonConfig/appComparisonConfig.jsp"
),
ROUTER_CONFIG_UPDATE
(
"/jsp/system/router/routerConfig.jsp"
),
THIRD_PARTY_CONFIG_UPDATE
(
"/jsp/system/thirdParty/thirdPartyConfig.jsp"
);
...
...
cat-home/src/main/java/com/dianping/cat/system/page/config/JspViewer.java
浏览文件 @
558c2f14
...
...
@@ -110,6 +110,8 @@ public class JspViewer extends BaseJspViewer<SystemPage, Action, Context, Model>
return
JspFile
.
METRIC_GROUP_CONFIG_UPDATE
.
getPath
();
case
APP_CONFIG_UPDATE:
return
JspFile
.
APP_CONFIG_UPDATE
.
getPath
();
case
APP_COMPARISON_CONFIG_UPDATE:
return
JspFile
.
APP_COMPARISON_CONFIG_UPDATE
.
getPath
();
case
THIRD_PARTY_CONFIG_UPDATE:
return
JspFile
.
THIRD_PARTY_CONFIG_UPDATE
.
getPath
();
case
ROUTER_CONFIG_UPDATE:
...
...
cat-home/src/main/resources/META-INF/plexus/components.xml
浏览文件 @
558c2f14
...
...
@@ -4316,6 +4316,9 @@
<requirement>
<role>
com.dianping.cat.config.app.AppConfigManager
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.config.app.AppComparisonConfigManager
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.report.view.DomainNavManager
</role>
</requirement>
...
...
@@ -4402,6 +4405,15 @@
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.config.app.AppComparisonConfigManager
</role>
<implementation>
com.dianping.cat.config.app.AppComparisonConfigManager
</implementation>
<requirements>
<requirement>
<role>
com.dianping.cat.core.config.ConfigDao
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.system.config.AlertPolicyManager
</role>
<implementation>
com.dianping.cat.system.config.AlertPolicyManager
</implementation>
...
...
@@ -4475,6 +4487,34 @@
<role>
com.dianping.cat.system.notify.ReportRender
</role>
<implementation>
com.dianping.cat.system.notify.ReportRenderImpl
</implementation>
</component>
<component>
<role>
com.dianping.cat.system.notify.render.AppDataComparisonRender
</role>
<implementation>
com.dianping.cat.system.notify.render.AppDataComparisonRender
</implementation>
</component>
<component>
<role>
com.dianping.cat.system.notify.AppDataComparisonNotifier
</role>
<implementation>
com.dianping.cat.system.notify.AppDataComparisonNotifier
</implementation>
<requirements>
<requirement>
<role>
com.dianping.cat.config.app.AppDataService
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.config.app.AppComparisonConfigManager
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.config.app.AppConfigManager
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.report.task.alert.sender.sender.SenderManager
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.home.dal.alarm.MailRecordDao
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.system.notify.render.AppDataComparisonRender
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.system.notify.ScheduledMailTask
</role>
<implementation>
com.dianping.cat.system.notify.ScheduledMailTask
</implementation>
...
...
@@ -4494,6 +4534,9 @@
<requirement>
<role>
com.dianping.cat.home.dal.alarm.MailRecordDao
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.system.notify.AppDataComparisonNotifier
</role>
</requirement>
</requirements>
</component>
</components>
...
...
cat-home/src/main/resources/config/default-app-comparison-config.xml
0 → 100644
浏览文件 @
558c2f14
<app-comparison-config
>
<app-comparison
id=
"首页"
mail=
"jialin.sun@dianping.com"
>
<item
id=
"点评"
command=
"shop.bin"
></item>
<item
id=
"美团"
command=
"shop.bin"
></item>
</app-comparison>
<app-comparison
id=
"详情"
mail=
"jialin.sun@dianping.com"
>
<item
id=
"点评"
command=
"shop.bin"
></item>
<item
id=
"美团"
command=
"shop.bin"
></item>
</app-comparison>
</app-comparison-config>
\ No newline at end of file
cat-home/src/main/resources/freemaker/appDataComparison.ftl
0 → 100644
浏览文件 @
558c2f14
[CAT端到端数据报告] : [${yesterday}] [时间: ${date}] <br/>
<table rules="all" border="1" >
<tr>
<td>分类</td>
<td>公司</td>
<td>命令字</td>
<td>响应时间</td>
</tr>
<#list results as result>
<#list result.items as item>
<tr>
<#if item_index == 0>
<td rowspan=${result.size}>${result.id}</td>
</#if>
<td style="text-align:right">${item.id}</td>
<td style="text-align:right">${item.command}</td>
<td style="text-align:right">${item.delay}</td>
</tr>
</#list>
</#list>
</table>
cat-home/src/main/webapp/WEB-INF/tags/body.tag
浏览文件 @
558c2f14
...
...
@@ -81,6 +81,7 @@
<li><a
style=
"padding:1px 30px"
href=
"/cat/s/config?op=urlPatterns"
>
URL合并规则
</a></li>
<li><a
style=
"padding:1px 30px"
href=
"/cat/s/config?op=aggregations"
>
JS合并规则
</a></li>
<li><a
style=
"padding:1px 30px"
href=
"/cat/s/config?op=appConfigUpdate"
>
APP监控配置
</a></li>
<li><a
style=
"padding:1px 30px"
href=
"/cat/s/config?op=appComparisonConfigUpdate"
>
APP报表配置
</a></li>
<li><a
style=
"padding:1px 30px"
href=
"/cat/s/config?op=thirdPartyConfigUpdate"
>
第三方监控配置
</a></li>
<li
class=
'nav-header'
style=
"margin-top:0px;"
>
业务监控配置
</li>
<li><a
style=
"padding:1px 30px"
href=
"/cat/s/config?op=metricConfigList"
>
业务监控规则
</a></li>
...
...
cat-home/src/main/webapp/jsp/system/appComparisonConfig/appComparisonConfig.jsp
0 → 100644
浏览文件 @
558c2f14
<%@ 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"
%>
<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:useJs
value=
"
${
res
.
js
.
local
[
'alarm_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"
/>
<div
class=
"row-fluid"
>
<div
class=
"span2"
>
<%@include
file=
"../configTree.jsp"
%>
</div>
<div
class=
"span10"
>
<form
name=
"appComparisonConfigUpdate"
id=
"form"
method=
"post"
action=
"${model.pageUri}?op=appComparisonConfigUpdate"
>
<h4
class=
"text-center text-error"
id=
"state"
>
</h4>
<h4
class=
"text-center text-error"
>
手机端报表配置
</h4>
<table
class=
"table table-striped table-bordered table-condensed table-hover"
>
<tr>
<td><textarea
name=
"content"
style=
"width:auto"
rows=
"20"
cols=
"150"
>
${model.content}
</textarea></td>
</tr>
<tr>
<td
style=
"text-align:center"
><input
class=
'btn btn-primary'
type=
"submit"
name=
"submit"
value=
"提交"
/></td>
</tr>
</table>
</form>
</div>
</div>
</a:body>
<script
type=
"text/javascript"
>
$
(
document
).
ready
(
function
()
{
$
(
'
#appComparisonConfigUpdate
'
).
addClass
(
'
active
'
);
var
state
=
'
${model.opState}
'
;
if
(
state
==
'
Success
'
){
$
(
'
#state
'
).
html
(
'
操作成功
'
);
}
else
{
$
(
'
#state
'
).
html
(
'
操作失败
'
);
}
setInterval
(
function
(){
$
(
'
#state
'
).
html
(
'
'
);
},
3000
);
});
</script>
\ No newline at end of file
cat-home/src/main/webapp/jsp/system/configTree.jsp
浏览文件 @
558c2f14
...
...
@@ -12,6 +12,7 @@
<li
class=
"text-right"
id=
"urlPatternList"
><a
href=
"?op=urlPatterns"
>
URL合并规则
</a></li>
<li
class=
"text-right"
id=
"aggregationList"
><a
href=
"?op=aggregations"
>
JS合并规则
</a></li>
<li
class=
"text-right"
id=
"appConfigUpdate"
><a
href=
"?op=appConfigUpdate"
>
APP监控配置
</a></li>
<li
class=
"text-right"
id=
"appComparisonConfigUpdate"
><a
href=
"?op=appComparisonConfigUpdate"
>
APP报表配置
</a></li>
<li
class=
"text-right"
id=
"thirdPartyConfigUpdate"
><a
href=
"?op=thirdPartyConfigUpdate"
>
第三方监控配置
</a></li>
<li
class=
'nav-header'
>
业务监控配置
</li>
<li
class=
"text-right"
id=
"metricConfigList"
><a
href=
"?op=metricConfigList"
>
业务监控规则
</a></li>
...
...
cat-home/src/test/resources/com/dianping/cat/system/config/appComparisonConfig.xml
0 → 100644
浏览文件 @
558c2f14
<app-comparison-config>
<app-comparison
id=
"首页"
emails=
"jialin.sun@dianping.com"
>
<item
id=
"点评"
command=
"shop.bin"
></item>
<item
id=
"美团"
command=
"shop.bin"
></item>
</app-comparison>
<app-comparison
id=
"详情"
>
<item
id=
"点评"
command=
"shop.bin"
></item>
<item
id=
"美团"
command=
"shop.bin"
></item>
</app-comparison>
</app-comparison-config>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录