Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
4f31163a
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,发现更多精彩内容 >>
提交
4f31163a
编写于
7月 23, 2014
作者:
L
leon.li
浏览文件
操作
浏览文件
下载
差异文件
resolve conflicts
上级
5058e7b1
54a5171a
变更
42
隐藏空白更改
内联
并排
Showing
42 changed file
with
1262 addition
and
309 deletion
+1262
-309
cat-broker/pom.xml
cat-broker/pom.xml
+170
-164
cat-broker/src/main/java/com/dianping/cat/broker/api/page/batch/Handler.java
.../java/com/dianping/cat/broker/api/page/batch/Handler.java
+19
-2
cat-broker/src/test/java/com/dianping/cat/broker/js/ParseTest.java
...r/src/test/java/com/dianping/cat/broker/js/ParseTest.java
+1
-1
cat-client/src/main/resources/com/dianping/cat/configuration/client/config.xsd
...esources/com/dianping/cat/configuration/client/config.xsd
+1
-2
cat-client/src/main/resources/com/dianping/cat/status/model/status.xsd
...c/main/resources/com/dianping/cat/status/model/status.xsd
+1
-2
cat-consumer-advanced/src/main/java/com/dianping/cat/consumer/metric/MetricAnalyzer.java
...java/com/dianping/cat/consumer/metric/MetricAnalyzer.java
+17
-11
cat-consumer-advanced/src/main/java/com/dianping/cat/consumer/metric/MetricConfigManager.java
...com/dianping/cat/consumer/metric/MetricConfigManager.java
+3
-8
cat-consumer-advanced/src/main/java/com/dianping/cat/consumer/metric/ProductLineConfigManager.java
...ianping/cat/consumer/metric/ProductLineConfigManager.java
+12
-7
cat-consumer-advanced/src/test/java/com/dianping/cat/consumer/metric/MetricAnalyzerTest.java
.../com/dianping/cat/consumer/metric/MetricAnalyzerTest.java
+10
-0
cat-consumer-advanced/src/test/java/com/dianping/cat/consumer/metric/MetricConfigManagerTest.java
...dianping/cat/consumer/metric/MetricConfigManagerTest.java
+17
-0
cat-core/src/main/java/com/dianping/cat/config/app/AppDataCommandTableProvider.java
.../dianping/cat/config/app/AppDataCommandTableProvider.java
+1
-1
cat-core/src/main/java/com/dianping/cat/config/app/AppDataService.java
...main/java/com/dianping/cat/config/app/AppDataService.java
+36
-20
cat-core/src/main/java/com/dianping/cat/config/app/QueryEntity.java
...rc/main/java/com/dianping/cat/config/app/QueryEntity.java
+22
-18
cat-core/src/main/resources/META-INF/dal/jdbc/app-dal.xml
cat-core/src/main/resources/META-INF/dal/jdbc/app-dal.xml
+14
-14
cat-home/pom.xml
cat-home/pom.xml
+7
-1
cat-home/src/main/java/com/dianping/cat/CatHomeModule.java
cat-home/src/main/java/com/dianping/cat/CatHomeModule.java
+12
-0
cat-home/src/main/java/com/dianping/cat/build/ComponentsConfigurator.java
...n/java/com/dianping/cat/build/ComponentsConfigurator.java
+11
-0
cat-home/src/main/java/com/dianping/cat/report/page/app/Payload.java
...c/main/java/com/dianping/cat/report/page/app/Payload.java
+1
-1
cat-home/src/main/java/com/dianping/cat/report/page/app/graph/AppGraphCreator.java
...m/dianping/cat/report/page/app/graph/AppGraphCreator.java
+10
-8
cat-home/src/main/java/com/dianping/cat/report/page/heartbeat/DisplayHeartbeat.java
.../dianping/cat/report/page/heartbeat/DisplayHeartbeat.java
+54
-31
cat-home/src/main/java/com/dianping/cat/report/task/alert/exception/AlertExceptionBuilder.java
...at/report/task/alert/exception/AlertExceptionBuilder.java
+2
-1
cat-home/src/main/java/com/dianping/cat/report/task/alert/exception/ExceptionAlert.java
...nping/cat/report/task/alert/exception/ExceptionAlert.java
+2
-11
cat-home/src/main/java/com/dianping/cat/report/task/alert/thirdParty/HttpMonitor.java
...ianping/cat/report/task/alert/thirdParty/HttpMonitor.java
+106
-0
cat-home/src/main/java/com/dianping/cat/report/task/alert/thirdParty/ThirdPartyAlert.java
...ing/cat/report/task/alert/thirdParty/ThirdPartyAlert.java
+201
-0
cat-home/src/main/java/com/dianping/cat/report/task/alert/thirdParty/ThirdPartyAlertEntity.java
...t/report/task/alert/thirdParty/ThirdPartyAlertEntity.java
+47
-0
cat-home/src/main/java/com/dianping/cat/report/task/alert/thirdParty/ThirdPartyAlertTask.java
...cat/report/task/alert/thirdParty/ThirdPartyAlertTask.java
+172
-0
cat-home/src/main/java/com/dianping/cat/system/config/ThirdPartyConfigManager.java
...m/dianping/cat/system/config/ThirdPartyConfigManager.java
+102
-0
cat-home/src/main/java/com/dianping/cat/system/page/config/Action.java
...main/java/com/dianping/cat/system/page/config/Action.java
+5
-3
cat-home/src/main/java/com/dianping/cat/system/page/config/Handler.java
...ain/java/com/dianping/cat/system/page/config/Handler.java
+11
-0
cat-home/src/main/java/com/dianping/cat/system/page/config/JspFile.java
...ain/java/com/dianping/cat/system/page/config/JspFile.java
+3
-1
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/dal/model/thirdParty-codegen.xml
.../main/resources/META-INF/dal/model/thirdParty-codegen.xml
+22
-0
cat-home/src/main/resources/META-INF/dal/model/thirdParty-manifest.xml
...main/resources/META-INF/dal/model/thirdParty-manifest.xml
+6
-0
cat-home/src/main/resources/META-INF/dal/model/thirdParty-model.xml
...rc/main/resources/META-INF/dal/model/thirdParty-model.xml
+23
-0
cat-home/src/main/resources/META-INF/plexus/components.xml
cat-home/src/main/resources/META-INF/plexus/components.xml
+64
-0
cat-home/src/main/resources/META-INF/wizard/model/wizard.xml
cat-home/src/main/resources/META-INF/wizard/model/wizard.xml
+4
-1
cat-home/src/main/resources/config/default-thirdParty-config.xml
...e/src/main/resources/config/default-thirdParty-config.xml
+7
-0
cat-home/src/main/webapp/WEB-INF/tags/body.tag
cat-home/src/main/webapp/WEB-INF/tags/body.tag
+1
-1
cat-home/src/main/webapp/jsp/system/configTree.jsp
cat-home/src/main/webapp/jsp/system/configTree.jsp
+1
-0
cat-home/src/main/webapp/jsp/system/thirdParty/thirdPartyConfig.jsp
...rc/main/webapp/jsp/system/thirdParty/thirdPartyConfig.jsp
+48
-0
cat-home/src/test/resources/config/thirdParty-config.xml
cat-home/src/test/resources/config/thirdParty-config.xml
+13
-0
script/Cat.sql
script/Cat.sql
+1
-0
未找到文件。
cat-broker/pom.xml
浏览文件 @
4f31163a
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
>
<parent>
<groupId>
com.dianping.cat
</groupId>
<artifactId>
parent
</artifactId>
<version>
1.0.5
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
broker-service
</artifactId>
<name>
broker-service
</name>
<packaging>
war
</packaging>
<dependencies>
<dependency>
<groupId>
com.dianping.cat
</groupId>
<artifactId>
cat-core
</artifactId>
</dependency>
<dependency>
<groupId>
com.google.code.gson
</groupId>
<artifactId>
gson
</artifactId>
<version>
1.6
</version>
</dependency>
<dependency>
<groupId>
org.unidal.webres
</groupId>
<artifactId>
WebResServer
</artifactId>
<version>
1.2.1
</version>
</dependency>
<dependency>
<groupId>
org.unidal.framework
</groupId>
<artifactId>
web-framework
</artifactId>
<version>
2.0.5
</version>
</dependency>
<dependency>
<groupId>
javax.servlet
</groupId>
<artifactId>
servlet-api
</artifactId>
<scope>
provided
</scope>
</dependency>
<dependency>
<groupId>
javax.servlet
</groupId>
<artifactId>
jstl
</artifactId>
<version>
1.2
</version>
</dependency>
<dependency>
<groupId>
org.mortbay.jetty
</groupId>
<artifactId>
jsp-api-2.1
</artifactId>
<version>
6.1.14
</version>
<scope>
provided
</scope>
</dependency>
<dependency>
<groupId>
org.mortbay.jetty
</groupId>
<artifactId>
jsp-2.1
</artifactId>
<scope>
provided
</scope>
</dependency>
<dependency>
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
<scope>
runtime
</scope>
</dependency>
<dependency>
<groupId>
org.freemarker
</groupId>
<artifactId>
freemarker
</artifactId>
<version>
2.3.9
</version>
</dependency>
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.mortbay.jetty
</groupId>
<artifactId>
jetty
</artifactId>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.unidal.framework
</groupId>
<artifactId>
test-framework
</artifactId>
<version>
2.0.4
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.apache.commons
</groupId>
<artifactId>
commons-email
</artifactId>
<version>
1.1
</version>
</dependency>
<dependency>
<groupId>
javax.mail
</groupId>
<artifactId>
mail
</artifactId>
<version>
1.4.4
</version>
</dependency>
<dependency>
<groupId>
com.google.code.javaparser
</groupId>
<artifactId>
javaparser
</artifactId>
<version>
1.0.8
</version>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>
${basedir}/src/main/resources
</directory>
<filtering>
true
</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>
org.unidal.maven.plugins
</groupId>
<artifactId>
codegen-maven-plugin
</artifactId>
<version>
2.0.9
</version>
<executions>
<execution>
<id>
generate plexus component descriptor
</id>
<phase>
process-classes
</phase>
<goals>
<goal>
plexus
</goal>
</goals>
<configuration>
<className>
com.dianping.cat.broker.build.ComponentsConfigurator
</className>
<env>
dev
</env>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-war-plugin
</artifactId>
<version>
2.1.1
</version>
<configuration>
<warName>
broker-service-${env}-${version}
</warName>
<webResources>
<resource>
<directory>
src/main/resources
</directory>
<filtering>
false
</filtering>
<targetPath>
WEB-INF/classes
</targetPath>
</resource>
<resource>
<directory>
src/main/webapp
</directory>
<filtering>
false
</filtering>
<includes>
<include>
WEB-INF/web.xml
</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
<plugin>
<groupId>
org.mortbay.jetty
</groupId>
<artifactId>
maven-jetty-plugin
</artifactId>
<version>
6.1.26
</version>
<configuration>
<scanIntervalSeconds>
10
</scanIntervalSeconds>
<contextPath>
/cat
</contextPath>
<defaultsDescriptor>
src/main/webapp/WEB-INF/web.xml
</defaultsDescriptor>
<connectors>
<connector
implementation=
"org.mortbay.jetty.nio.SelectChannelConnector"
>
<port>
2281
</port>
<maxIdleTime>
500000
</maxIdleTime>
</connector>
</connectors>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<packaging>
war
</packaging>
<env>
alpha
</env>
<project.build.sourceEncoding>
utf-8
</project.build.sourceEncoding>
</properties>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
>
<parent>
<groupId>
com.dianping.cat
</groupId>
<artifactId>
parent
</artifactId>
<version>
1.0.5
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
broker-service
</artifactId>
<name>
broker-service
</name>
<packaging>
war
</packaging>
<dependencies>
<dependency>
<groupId>
com.dianping.cat
</groupId>
<artifactId>
cat-core
</artifactId>
</dependency>
<dependency>
<groupId>
com.google.code.gson
</groupId>
<artifactId>
gson
</artifactId>
<version>
1.6
</version>
</dependency>
<dependency>
<groupId>
org.unidal.framework
</groupId>
<artifactId>
dal-jdbc
</artifactId>
<version>
2.1.1
</version>
</dependency>
<dependency>
<groupId>
org.unidal.webres
</groupId>
<artifactId>
WebResServer
</artifactId>
<version>
1.2.1
</version>
</dependency>
<dependency>
<groupId>
org.unidal.framework
</groupId>
<artifactId>
web-framework
</artifactId>
<version>
2.0.5
</version>
</dependency>
<dependency>
<groupId>
javax.servlet
</groupId>
<artifactId>
servlet-api
</artifactId>
<scope>
provided
</scope>
</dependency>
<dependency>
<groupId>
javax.servlet
</groupId>
<artifactId>
jstl
</artifactId>
<version>
1.2
</version>
</dependency>
<dependency>
<groupId>
org.mortbay.jetty
</groupId>
<artifactId>
jsp-api-2.1
</artifactId>
<version>
6.1.14
</version>
<scope>
provided
</scope>
</dependency>
<dependency>
<groupId>
org.mortbay.jetty
</groupId>
<artifactId>
jsp-2.1
</artifactId>
<scope>
provided
</scope>
</dependency>
<dependency>
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
<scope>
runtime
</scope>
</dependency>
<dependency>
<groupId>
org.freemarker
</groupId>
<artifactId>
freemarker
</artifactId>
<version>
2.3.9
</version>
</dependency>
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.mortbay.jetty
</groupId>
<artifactId>
jetty
</artifactId>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.unidal.framework
</groupId>
<artifactId>
test-framework
</artifactId>
<version>
2.0.4
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.apache.commons
</groupId>
<artifactId>
commons-email
</artifactId>
<version>
1.1
</version>
</dependency>
<dependency>
<groupId>
javax.mail
</groupId>
<artifactId>
mail
</artifactId>
<version>
1.4.4
</version>
</dependency>
<dependency>
<groupId>
com.google.code.javaparser
</groupId>
<artifactId>
javaparser
</artifactId>
<version>
1.0.8
</version>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>
${basedir}/src/main/resources
</directory>
<filtering>
true
</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>
org.unidal.maven.plugins
</groupId>
<artifactId>
codegen-maven-plugin
</artifactId>
<version>
2.0.9
</version>
<executions>
<execution>
<id>
generate plexus component descriptor
</id>
<phase>
process-classes
</phase>
<goals>
<goal>
plexus
</goal>
</goals>
<configuration>
<className>
com.dianping.cat.broker.build.ComponentsConfigurator
</className>
<env>
dev
</env>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-war-plugin
</artifactId>
<version>
2.1.1
</version>
<configuration>
<warName>
broker-service-${env}-${version}
</warName>
<webResources>
<resource>
<directory>
src/main/resources
</directory>
<filtering>
false
</filtering>
<targetPath>
WEB-INF/classes
</targetPath>
</resource>
<resource>
<directory>
src/main/webapp
</directory>
<filtering>
false
</filtering>
<includes>
<include>
WEB-INF/web.xml
</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
<plugin>
<groupId>
org.mortbay.jetty
</groupId>
<artifactId>
maven-jetty-plugin
</artifactId>
<version>
6.1.26
</version>
<configuration>
<scanIntervalSeconds>
10
</scanIntervalSeconds>
<contextPath>
/cat
</contextPath>
<defaultsDescriptor>
src/main/webapp/WEB-INF/web.xml
</defaultsDescriptor>
<connectors>
<connector
implementation=
"org.mortbay.jetty.nio.SelectChannelConnector"
>
<port>
2281
</port>
<maxIdleTime>
500000
</maxIdleTime>
</connector>
</connectors>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<packaging>
war
</packaging>
<env>
alpha
</env>
<project.build.sourceEncoding>
utf-8
</project.build.sourceEncoding>
</properties>
</project>
cat-broker/src/main/java/com/dianping/cat/broker/api/page/batch/Handler.java
浏览文件 @
4f31163a
package
com.dianping.cat.broker.api.page.batch
;
import
java.io.IOException
;
import
java.net.URLDecoder
;
import
javax.servlet.ServletException
;
import
javax.servlet.http.HttpServletRequest
;
...
...
@@ -15,6 +16,7 @@ import org.unidal.web.mvc.annotation.InboundActionMeta;
import
org.unidal.web.mvc.annotation.OutboundActionMeta
;
import
org.unidal.web.mvc.annotation.PayloadMeta
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.broker.api.app.AppData
;
import
com.dianping.cat.broker.api.app.AppDataConsumer
;
import
com.dianping.cat.broker.api.page.Constrants
;
...
...
@@ -24,6 +26,7 @@ import com.dianping.cat.broker.api.page.MonitorEntity;
import
com.dianping.cat.broker.api.page.MonitorManager
;
import
com.dianping.cat.broker.api.page.RequestUtils
;
import
com.dianping.cat.config.app.AppConfigManager
;
import
com.dianping.cat.message.Event
;
public
class
Handler
implements
PageHandler
<
Context
>,
LogEnabled
{
...
...
@@ -64,18 +67,27 @@ public class Handler implements PageHandler<Context>, LogEnabled {
HttpServletResponse
response
=
ctx
.
getHttpServletResponse
();
String
userIp
=
m_util
.
getRemoteIp
(
request
);
String
version
=
payload
.
getVersion
();
boolean
success
=
true
;
if
(
userIp
!=
null
)
{
if
(
"1"
.
equals
(
version
))
{
processVersion1
(
payload
,
request
,
userIp
);
}
else
if
(
"2"
.
equals
(
version
))
{
processVersion2
(
payload
,
request
,
userIp
);
}
else
{
success
=
false
;
Cat
.
logEvent
(
"InvalidVersion"
,
version
,
Event
.
SUCCESS
,
version
);
}
}
else
{
success
=
false
;
m_logger
.
info
(
"unknown http request, x-forwarded-for:"
+
request
.
getHeader
(
"x-forwarded-for"
));
}
response
.
getWriter
().
write
(
"OK"
);
if
(
success
)
{
response
.
getWriter
().
write
(
"OK"
);
}
else
{
response
.
getWriter
().
write
(
"validate request!"
);
}
}
private
void
processVersion1
(
Payload
payload
,
HttpServletRequest
request
,
String
userIp
)
{
...
...
@@ -144,7 +156,7 @@ public class Handler implements PageHandler<Context>, LogEnabled {
try
{
appData
.
setTimestamp
(
Long
.
parseLong
(
items
[
0
]));
Integer
command
=
m_appConfigManager
.
getCommands
().
get
(
items
[
1
]
);
Integer
command
=
m_appConfigManager
.
getCommands
().
get
(
URLDecoder
.
decode
(
items
[
1
],
"utf-8"
)
);
if
(
command
!=
null
)
{
appData
.
setCommand
(
command
);
...
...
@@ -161,10 +173,15 @@ public class Handler implements PageHandler<Context>, LogEnabled {
appData
.
setCount
(
1
);
m_appDataConsumer
.
enqueue
(
appData
);
Cat
.
logEvent
(
"Command"
,
String
.
valueOf
(
command
),
Event
.
SUCCESS
,
null
);
}
else
{
Cat
.
logEvent
(
"CommandNotFound"
,
items
[
1
],
Event
.
SUCCESS
,
items
[
1
]);
}
}
catch
(
Exception
e
)
{
m_logger
.
error
(
e
.
getMessage
(),
e
);
}
}
else
{
Cat
.
logEvent
(
"InvalidPar"
,
items
[
1
],
Event
.
SUCCESS
,
items
[
1
]);
}
}
...
...
cat-broker/src/test/java/com/dianping/cat/broker/js/ParseTest.java
浏览文件 @
4f31163a
...
...
@@ -15,7 +15,7 @@ public class ParseTest {
for
(
int
i
=
0
;
i
<
1000
;
i
++)
{
analyzer
.
parseValue
(
"abc"
,
data
);
}
Assert
.
assertEquals
(
analyzer
.
parseValue
(
"aaa"
,
"aaa=1.1"
),
"1.1"
);
Assert
.
assertEquals
(
analyzer
.
parseValue
(
"aaa"
,
data
),
"1.1"
);
Assert
.
assertEquals
(
analyzer
.
parseValue
(
"a"
,
data
),
"1.1"
);
...
...
cat-client/src/main/resources/com/dianping/cat/configuration/client/config.xsd
浏览文件 @
4f31163a
<?xml version="1.0" encoding="utf-8"?>
<xs:schema
xmlns:xs=
"http://www.w3.org/2001/XMLSchema"
elementFormDefault=
"qualified"
attributeFormDefault=
"unqualified"
>
<?xml version="1.0" encoding="utf-8"?>
<xs:schema
xmlns:xs=
"http://www.w3.org/2001/XMLSchema"
elementFormDefault=
"qualified"
attributeFormDefault=
"unqualified"
>
<xs:element
name=
"config"
type=
"ConfigType"
/>
<xs:complexType
name=
"ConfigType"
>
<xs:sequence>
...
...
cat-client/src/main/resources/com/dianping/cat/status/model/status.xsd
浏览文件 @
4f31163a
<?xml version="1.0" encoding="utf-8"?>
<xs:schema
xmlns:xs=
"http://www.w3.org/2001/XMLSchema"
elementFormDefault=
"qualified"
attributeFormDefault=
"unqualified"
>
<?xml version="1.0" encoding="utf-8"?>
<xs:schema
xmlns:xs=
"http://www.w3.org/2001/XMLSchema"
elementFormDefault=
"qualified"
attributeFormDefault=
"unqualified"
>
<xs:element
name=
"status"
type=
"StatusType"
/>
<xs:complexType
name=
"StatusType"
>
<xs:sequence>
...
...
cat-consumer-advanced/src/main/java/com/dianping/cat/consumer/metric/MetricAnalyzer.java
浏览文件 @
4f31163a
...
...
@@ -16,6 +16,7 @@ import com.dianping.cat.analysis.AbstractMessageAnalyzer;
import
com.dianping.cat.configuration.NetworkInterfaceManager
;
import
com.dianping.cat.consumer.advanced.dal.BusinessReport
;
import
com.dianping.cat.consumer.advanced.dal.BusinessReportDao
;
import
com.dianping.cat.consumer.company.model.entity.ProductLine
;
import
com.dianping.cat.consumer.metric.model.entity.MetricItem
;
import
com.dianping.cat.consumer.metric.model.entity.MetricReport
;
import
com.dianping.cat.consumer.metric.model.entity.Segment
;
...
...
@@ -170,7 +171,12 @@ public class MetricAnalyzer extends AbstractMessageAnalyzer<MetricReport> implem
ConfigItem
config
=
parseValue
(
status
,
data
);
if
(!
StringUtils
.
isEmpty
(
group
))
{
m_productLineConfigManager
.
insertIfNotExsit
(
group
,
domain
);
boolean
result
=
m_productLineConfigManager
.
insertIfNotExsit
(
group
,
domain
);
if
(!
result
)
{
m_logger
.
error
(
String
.
format
(
"error when insert product line info, productline %s, domain %s"
,
group
,
domain
));
}
report
=
findOrCreateReport
(
group
);
}
...
...
@@ -184,21 +190,21 @@ public class MetricAnalyzer extends AbstractMessageAnalyzer<MetricReport> implem
updateMetric
(
metricItem
,
min
,
config
.
getCount
(),
config
.
getValue
());
config
.
setTitle
(
metricName
);
if
(!
isNetwork
(
group
)
&&
!
isSystem
(
group
))
{
m_configManager
.
insertIfNotExist
(
domain
,
METRIC
,
metricName
,
config
);
ProductLine
productline
=
m_productLineConfigManager
.
queryProductLine
(
group
);
if
(
productline
!=
null
&&
productline
.
getMetricDashboard
())
{
boolean
result
=
m_configManager
.
insertIfNotExist
(
domain
,
METRIC
,
metricName
,
config
);
if
(!
result
)
{
m_logger
.
error
(
String
.
format
(
"error when insert metric config info, domain %s, metricName %s"
,
domain
,
metricName
));
}
}
}
return
0
;
}
private
boolean
isNetwork
(
String
group
)
{
return
group
.
startsWith
(
"f5"
)
||
group
.
startsWith
(
"switch"
);
}
private
boolean
isSystem
(
String
group
)
{
return
group
.
startsWith
(
"system"
);
}
private
int
processTransaction
(
MetricReport
report
,
MessageTree
tree
,
Transaction
t
)
{
int
count
=
0
;
List
<
Message
>
children
=
t
.
getChildren
();
...
...
cat-consumer-advanced/src/main/java/com/dianping/cat/consumer/metric/MetricConfigManager.java
浏览文件 @
4f31163a
...
...
@@ -19,10 +19,10 @@ import org.unidal.lookup.annotation.Inject;
import
org.xml.sax.SAXException
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.Constants
;
import
com.dianping.cat.advanced.metric.config.entity.MetricConfig
;
import
com.dianping.cat.advanced.metric.config.entity.MetricItemConfig
;
import
com.dianping.cat.advanced.metric.config.transform.DefaultSaxParser
;
import
com.dianping.cat.consumer.company.model.entity.ProductLine
;
import
com.dianping.cat.consumer.metric.MetricAnalyzer.ConfigItem
;
import
com.dianping.cat.core.config.Config
;
import
com.dianping.cat.core.config.ConfigDao
;
...
...
@@ -102,14 +102,9 @@ public class MetricConfigManager implements Initializable {
for
(
MetricItemConfig
config
:
configs
.
values
())
{
String
domain
=
config
.
getDomain
();
String
productLine
=
m_productLineConfigManager
.
queryProductLineByDomain
(
domain
);
ProductLine
product
=
m_productLineConfigManager
.
queryProductLine
(
productLine
);
if
(
Constants
.
BROKER_SERVICE
.
equals
(
domain
))
{
unused
.
add
(
config
.
getId
());
}
if
(
"Default"
.
equals
(
productLine
))
{
unused
.
add
(
config
.
getId
());
}
if
(!
config
.
getId
().
contains
(
":Metric:"
))
{
if
(
product
==
null
||
!
product
.
isMetricDashboard
())
{
unused
.
add
(
config
.
getId
());
}
}
...
...
cat-consumer-advanced/src/main/java/com/dianping/cat/consumer/metric/ProductLineConfigManager.java
浏览文件 @
4f31163a
...
...
@@ -152,16 +152,16 @@ public class ProductLineConfigManager implements Initializable, LogEnabled {
productLine
.
setDashboard
(
metricDashboard
);
}
public
boolean
insertIfNotExsit
(
String
line
,
String
domain
)
{
public
boolean
insertIfNotExsit
(
String
product
,
String
domain
)
{
Company
company
=
getCompany
();
if
(
company
!=
null
)
{
ProductLine
productLine
=
company
.
getProductLines
().
get
(
line
);
ProductLine
productLine
=
company
.
getProductLines
().
get
(
product
);
if
(
productLine
==
null
)
{
productLine
=
new
ProductLine
();
productLine
.
setId
(
line
);
productLine
.
setTitle
(
line
);
productLine
.
setId
(
product
);
productLine
.
setTitle
(
product
);
buildDefaultDashboard
(
productLine
,
domain
);
productLine
.
addDomain
(
new
Domain
(
domain
));
company
.
addProductLine
(
productLine
);
...
...
@@ -215,11 +215,16 @@ public class ProductLineConfigManager implements Initializable, LogEnabled {
return
domains
;
}
public
ProductLine
queryProductLine
(
String
id
)
{
return
getCompany
().
findProductLine
(
id
);
}
public
Map
<
String
,
ProductLine
>
queryMetricProductLines
()
{
Map
<
String
,
ProductLine
>
productLines
=
new
TreeMap
<
String
,
ProductLine
>();
for
(
ProductLine
line
:
getCompany
().
getProductLines
().
values
())
{
String
id
=
line
.
getId
();
if
(
id
!=
null
&&
id
.
length
()
>
0
&&
line
.
getMetricDashboard
())
{
productLines
.
put
(
id
,
line
);
}
...
...
@@ -248,7 +253,7 @@ public class ProductLineConfigManager implements Initializable, LogEnabled {
return
productLine
==
null
?
"Default"
:
productLine
;
}
public
Map
<
String
,
List
<
ProductLine
>>
queryTypeProductLines
()
{
Map
<
String
,
List
<
ProductLine
>>
productLines
=
new
LinkedHashMap
<
String
,
List
<
ProductLine
>>();
...
...
@@ -343,13 +348,13 @@ public class ProductLineConfigManager implements Initializable, LogEnabled {
config
.
setName
(
CONFIG_NAME
);
config
.
setContent
(
getCompany
().
toString
());
m_configDao
.
updateByPK
(
config
,
ConfigEntity
.
UPDATESET_FULL
);
m_domainToProductLines
=
buildDomainToProductLines
();
return
true
;
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
return
false
;
}
m_domainToProductLines
=
buildDomainToProductLines
();
}
return
true
;
}
}
\ No newline at end of file
cat-consumer-advanced/src/test/java/com/dianping/cat/consumer/metric/MetricAnalyzerTest.java
浏览文件 @
4f31163a
...
...
@@ -283,6 +283,16 @@ public class MetricAnalyzerTest extends ComponentTestCase {
public
Map
<
String
,
ProductLine
>
queryAllProductLines
()
{
return
new
HashMap
<
String
,
ProductLine
>();
}
@Override
public
ProductLine
queryProductLine
(
String
id
)
{
return
null
;
}
@Override
public
boolean
insertIfNotExsit
(
String
product
,
String
domain
)
{
return
true
;
}
}
}
cat-consumer-advanced/src/test/java/com/dianping/cat/consumer/metric/MetricConfigManagerTest.java
浏览文件 @
4f31163a
...
...
@@ -75,6 +75,23 @@ public class MetricConfigManagerTest {
Assert
.
assertEquals
(
3L
,
configs
.
get
(
item
).
longValue
());
Assert
.
assertEquals
(
1
,
configs
.
size
());
}
@Test
public
void
testInit
(){
MetricConfigManager
manager
=
new
MockMetricConfigManager
();
((
MockMetricConfigManager
)
manager
).
setConfigDao
(
new
MockConfigDao2
());
try
{
manager
.
initialize
();
}
catch
(
Exception
e
)
{
}
s_storeCount
=
0
;
manager
.
insertIfNotExist
(
"test"
,
"test"
,
"test"
,
new
ConfigItem
());
manager
.
insertIfNotExist
(
"test"
,
"test"
,
"test"
,
new
ConfigItem
());
manager
.
insertIfNotExist
(
"test1"
,
"test"
,
"test"
,
new
ConfigItem
());
manager
.
insertIfNotExist
(
"test1"
,
"test"
,
"test"
,
new
ConfigItem
());
Assert
.
assertEquals
(
s_storeCount
,
2
);
}
@Test
public
void
testInitThrowException
()
throws
Exception
{
...
...
cat-core/src/main/java/com/dianping/cat/config/app/AppDataCommandTableProvider.java
浏览文件 @
4f31163a
...
...
@@ -23,7 +23,7 @@ public class AppDataCommandTableProvider implements TableProvider {
public
String
getLogicalTableName
()
{
return
m_logicalTableName
;
}
@Override
public
String
getPhysicalTableName
(
Map
<
String
,
Object
>
hints
)
{
AppDataCommand
command
=
(
AppDataCommand
)
hints
.
get
(
QueryEngine
.
HINT_DATA_OBJECT
);
...
...
cat-core/src/main/java/com/dianping/cat/config/app/AppDataService.java
浏览文件 @
4f31163a
...
...
@@ -10,7 +10,6 @@ import java.util.Map.Entry;
import
org.unidal.dal.jdbc.DalException
;
import
org.unidal.lookup.annotation.Inject
;
import
org.unidal.tuple.Pair
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.app.AppDataCommand
;
...
...
@@ -52,20 +51,20 @@ public class AppDataService {
if
(
SUCCESS
.
equals
(
type
))
{
datas
=
m_dao
.
findDataByMinuteCode
(
commandId
,
period
,
city
,
operator
,
network
,
appVersion
,
connnectType
,
code
,
platform
,
AppDataCommandEntity
.
READSET_SUCCESS_DATA
);
Pair
<
Integer
,
Map
<
Integer
,
List
<
AppDataCommand
>>>
dataPair
=
convert2AppDataCommandMap
(
datas
);
AppDataCommandMap
convertedData
=
convert2AppDataCommandMap
(
datas
);
return
querySuccessRatio
(
commandId
,
dataPair
);
return
querySuccessRatio
(
commandId
,
convertedData
);
}
else
if
(
REQUEST
.
equals
(
type
))
{
datas
=
m_dao
.
findDataByMinute
(
commandId
,
period
,
city
,
operator
,
network
,
appVersion
,
connnectType
,
code
,
platform
,
AppDataCommandEntity
.
READSET_COUNT_DATA
);
Pair
<
Integer
,
Map
<
Integer
,
List
<
AppDataCommand
>>>
dataPair
=
convert2AppDataCommandMap
(
datas
);
return
queryRequestCount
(
dataPair
);
AppDataCommandMap
convertedData
=
convert2AppDataCommandMap
(
datas
);
return
queryRequestCount
(
convertedData
);
}
else
if
(
DELAY
.
equals
(
type
))
{
datas
=
m_dao
.
findDataByMinute
(
commandId
,
period
,
city
,
operator
,
network
,
appVersion
,
connnectType
,
code
,
platform
,
AppDataCommandEntity
.
READSET_AVG_DATA
);
Pair
<
Integer
,
Map
<
Integer
,
List
<
AppDataCommand
>>>
dataPair
=
convert2AppDataCommandMap
(
datas
);
AppDataCommandMap
dataPair
=
convert2AppDataCommandMap
(
datas
);
return
queryDelayAvg
(
dataPair
);
}
else
{
throw
new
RuntimeException
(
"unexpected query type, type:"
+
type
);
...
...
@@ -76,7 +75,7 @@ public class AppDataService {
return
null
;
}
private
Pair
<
Integer
,
Map
<
Integer
,
List
<
AppDataCommand
>>>
convert2AppDataCommandMap
(
List
<
AppDataCommand
>
fromDatas
)
{
private
AppDataCommandMap
convert2AppDataCommandMap
(
List
<
AppDataCommand
>
fromDatas
)
{
Map
<
Integer
,
List
<
AppDataCommand
>>
dataMap
=
new
LinkedHashMap
<
Integer
,
List
<
AppDataCommand
>>();
int
max
=
-
1
;
...
...
@@ -95,18 +94,16 @@ public class AppDataService {
}
data
.
add
(
from
);
}
int
n
=
max
/
5
;
return
new
Pair
<
Integer
,
Map
<
Integer
,
List
<
AppDataCommand
>>>
(
n
,
dataMap
);
return
new
AppDataCommandMap
(
n
,
dataMap
);
}
public
double
[]
querySuccessRatio
(
int
commandId
,
Pair
<
Integer
,
Map
<
Integer
,
List
<
AppDataCommand
>>>
dataPair
)
{
double
[]
value
=
new
double
[
dataPair
.
getKey
()];
Map
<
Integer
,
List
<
AppDataCommand
>>
dataMap
=
dataPair
.
getValue
();
public
double
[]
querySuccessRatio
(
int
commandId
,
AppDataCommandMap
convertedData
)
{
double
[]
value
=
new
double
[
convertedData
.
getMaxSize
()];
try
{
for
(
Entry
<
Integer
,
List
<
AppDataCommand
>>
entry
:
dataMap
.
entrySet
())
{
for
(
Entry
<
Integer
,
List
<
AppDataCommand
>>
entry
:
convertedData
.
getAppDataCommands
()
.
entrySet
())
{
int
key
=
entry
.
getKey
();
long
success
=
0
;
long
sum
=
0
;
...
...
@@ -139,10 +136,10 @@ public class AppDataService {
return
false
;
}
public
double
[]
queryRequestCount
(
Pair
<
Integer
,
Map
<
Integer
,
List
<
AppDataCommand
>>>
dataPair
)
{
double
[]
value
=
new
double
[
dataPair
.
getKey
()];
public
double
[]
queryRequestCount
(
AppDataCommandMap
convertedData
)
{
double
[]
value
=
new
double
[
convertedData
.
getMaxSize
()];
for
(
Entry
<
Integer
,
List
<
AppDataCommand
>>
entry
:
dataPair
.
getValue
().
entrySet
())
{
for
(
Entry
<
Integer
,
List
<
AppDataCommand
>>
entry
:
convertedData
.
getAppDataCommands
().
entrySet
())
{
for
(
AppDataCommand
data
:
entry
.
getValue
())
{
long
count
=
data
.
getAccessNumberSum
();
...
...
@@ -152,10 +149,10 @@ public class AppDataService {
return
value
;
}
public
double
[]
queryDelayAvg
(
Pair
<
Integer
,
Map
<
Integer
,
List
<
AppDataCommand
>>>
dataPair
)
{
double
[]
value
=
new
double
[
dataPair
.
getKey
()];
public
double
[]
queryDelayAvg
(
AppDataCommandMap
convertedData
)
{
double
[]
value
=
new
double
[
convertedData
.
getMaxSize
()];
for
(
Entry
<
Integer
,
List
<
AppDataCommand
>>
entry
:
dataPair
.
getValue
().
entrySet
())
{
for
(
Entry
<
Integer
,
List
<
AppDataCommand
>>
entry
:
convertedData
.
getAppDataCommands
().
entrySet
())
{
for
(
AppDataCommand
data
:
entry
.
getValue
())
{
long
count
=
data
.
getAccessNumberSum
();
long
sum
=
data
.
getResponseSumTimeSum
();
...
...
@@ -166,5 +163,24 @@ public class AppDataService {
}
return
value
;
}
public
class
AppDataCommandMap
{
private
int
m_maxSize
;
private
Map
<
Integer
,
List
<
AppDataCommand
>>
m_appDataCommands
;
public
int
getMaxSize
()
{
return
m_maxSize
;
}
public
Map
<
Integer
,
List
<
AppDataCommand
>>
getAppDataCommands
()
{
return
m_appDataCommands
;
}
public
AppDataCommandMap
(
int
maxSize
,
Map
<
Integer
,
List
<
AppDataCommand
>>
appDataCommands
)
{
m_maxSize
=
maxSize
;
m_appDataCommands
=
appDataCommands
;
}
}
}
cat-core/src/main/java/com/dianping/cat/config/app/QueryEntity.java
浏览文件 @
4f31163a
...
...
@@ -2,7 +2,9 @@ package com.dianping.cat.config.app;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.List
;
import
org.unidal.helper.Splitters
;
import
org.unidal.lookup.util.StringUtils
;
import
com.dianping.cat.Cat
;
...
...
@@ -13,34 +15,36 @@ public class QueryEntity {
private
int
m_command
;
private
int
m_code
;
private
int
m_code
=
DEFAULT_VALUE
;
private
int
m_network
;
private
int
m_network
=
DEFAULT_VALUE
;
private
int
m_version
;
private
int
m_version
=
DEFAULT_VALUE
;
private
int
m_channel
;
private
int
m_channel
=
DEFAULT_VALUE
;
private
int
m_platfrom
;
private
int
m_platfrom
=
DEFAULT_VALUE
;
private
int
m_city
;
private
int
m_city
=
DEFAULT_VALUE
;
private
int
m_operator
;
private
int
m_operator
=
DEFAULT_VALUE
;
private
static
final
int
DEFAULT_VALUE
=
-
1
;
public
QueryEntity
(
String
query
)
{
String
[]
strs
=
query
.
split
(
";"
);
List
<
String
>
strs
=
Splitters
.
by
(
";"
).
split
(
query
);
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
try
{
m_date
=
sdf
.
parse
(
strs
[
0
]
);
m_command
=
parseValue
(
strs
[
1
]
);
m_code
=
parseValue
(
strs
[
2
]
);
m_network
=
parseValue
(
strs
[
3
]
);
m_version
=
parseValue
(
strs
[
4
]
);
m_channel
=
parseValue
(
strs
[
5
]
);
m_platfrom
=
parseValue
(
strs
[
6
]
);
m_city
=
parseValue
(
strs
[
7
]
);
m_operator
=
parseValue
(
strs
[
8
]
);
m_date
=
sdf
.
parse
(
strs
.
get
(
0
)
);
m_command
=
parseValue
(
strs
.
get
(
1
)
);
m_code
=
parseValue
(
strs
.
get
(
2
)
);
m_network
=
parseValue
(
strs
.
get
(
3
)
);
m_version
=
parseValue
(
strs
.
get
(
4
)
);
m_channel
=
parseValue
(
strs
.
get
(
5
)
);
m_platfrom
=
parseValue
(
strs
.
get
(
6
)
);
m_city
=
parseValue
(
strs
.
get
(
7
)
);
m_operator
=
parseValue
(
strs
.
get
(
8
)
);
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
...
...
@@ -48,7 +52,7 @@ public class QueryEntity {
private
int
parseValue
(
String
str
)
{
if
(
StringUtils
.
isEmpty
(
str
))
{
return
-
1
;
return
DEFAULT_VALUE
;
}
else
{
return
Integer
.
parseInt
(
str
);
}
...
...
cat-core/src/main/resources/META-INF/dal/jdbc/app-dal.xml
浏览文件 @
4f31163a
...
...
@@ -44,25 +44,25 @@
<statement>
<![CDATA[SELECT <FIELDS/>
FROM
<TABLE/>
WHERE
<FIELD
name=
'period'
/>
= ${period}
<IF
type=
'N
OT_ZERO'
field=
'city
'
>
<IF
type=
'N
E'
field=
'city'
value=
'-1
'
>
AND
<FIELD
name=
'city'
/>
= ${city}
</IF>
<IF
type=
'N
OT_ZERO'
field=
'operator
'
>
<IF
type=
'N
E'
field=
'operator'
value=
'-1
'
>
AND
<FIELD
name=
'operator'
/>
= ${operator}
</IF>
<IF
type=
'N
OT_ZERO'
field=
'network
'
>
<IF
type=
'N
E'
field=
'network'
value=
'-1
'
>
AND
<FIELD
name=
'network'
/>
= ${network}
</IF>
<IF
type=
'N
OT_ZERO'
field=
'app-version
'
>
<IF
type=
'N
E'
field=
'app-version'
value=
'-1
'
>
AND
<FIELD
name=
'app-version'
/>
= ${app-version}
</IF>
<IF
type=
'N
OT_ZERO'
field=
'connnect-type
'
>
<IF
type=
'N
E'
field=
'connnect-type'
value=
'-1
'
>
AND
<FIELD
name=
'connnect-type'
/>
= ${connnect-type}
</IF>
<IF
type=
'N
OT_ZERO'
field=
'code
'
>
<IF
type=
'N
E'
field=
'code'
value=
'-1
'
>
AND
<FIELD
name=
'code'
/>
= ${code}
</IF>
<IF
type=
'N
OT_ZERO'
field=
'platform
'
>
<IF
type=
'N
E'
field=
'platform'
value=
'-1
'
>
AND
<FIELD
name=
'platform'
/>
= ${platform}
</IF>
group by
<FIELD
name=
'minute-order'
/>
]]>
</statement>
...
...
@@ -80,25 +80,25 @@
<statement>
<![CDATA[SELECT <FIELDS/>
FROM
<TABLE/>
WHERE
<FIELD
name=
'period'
/>
= ${period}
<IF
type=
'N
OT_ZERO'
field=
'city
'
>
<IF
type=
'N
E'
field=
'city'
value=
'-1
'
>
AND
<FIELD
name=
'city'
/>
= ${city}
</IF>
<IF
type=
'N
OT_ZERO'
field=
'operator
'
>
<IF
type=
'N
E'
field=
'operator'
value=
'-1
'
>
AND
<FIELD
name=
'operator'
/>
= ${operator}
</IF>
<IF
type=
'N
OT_ZERO'
field=
'network
'
>
<IF
type=
'N
E'
field=
'network'
value=
'-1
'
>
AND
<FIELD
name=
'network'
/>
= ${network}
</IF>
<IF
type=
'N
OT_ZERO'
field=
'app-version
'
>
<IF
type=
'N
E'
field=
'app-version'
value=
'-1
'
>
AND
<FIELD
name=
'app-version'
/>
= ${app-version}
</IF>
<IF
type=
'N
OT_ZERO'
field=
'connnect-type
'
>
<IF
type=
'N
E'
field=
'connnect-type'
value=
'-1
'
>
AND
<FIELD
name=
'connnect-type'
/>
= ${connnect-type}
</IF>
<IF
type=
'N
OT_ZERO'
field=
'code
'
>
<IF
type=
'N
E'
field=
'code'
value=
'-1
'
>
AND
<FIELD
name=
'code'
/>
= ${code}
</IF>
<IF
type=
'N
OT_ZERO'
field=
'platform
'
>
<IF
type=
'N
E'
field=
'platform'
value=
'-1
'
>
AND
<FIELD
name=
'platform'
/>
= ${platform}
</IF>
group by
<FIELD
name=
'minute-order'
/>
,
<FIELD
name=
'code'
/>
]]>
</statement>
...
...
cat-home/pom.xml
浏览文件 @
4f31163a
...
...
@@ -54,6 +54,11 @@
<artifactId>
jstl
</artifactId>
<version>
1.2
</version>
</dependency>
<dependency>
<groupId>
org.unidal.framework
</groupId>
<artifactId>
dal-jdbc
</artifactId>
<version>
2.1.1
</version>
</dependency>
<dependency>
<groupId>
org.mortbay.jetty
</groupId>
<artifactId>
jsp-api-2.1
</artifactId>
...
...
@@ -157,7 +162,8 @@
${basedir}/src/main/resources/META-INF/dal/model/alertconfig-manifest.xml,
${basedir}/src/main/resources/META-INF/dal/model/alertsummary-manifest.xml,
${basedir}/src/main/resources/META-INF/dal/model/alert-type-manifest.xml,
</manifest>
${basedir}/src/main/resources/META-INF/dal/model/thirdParty-manifest.xml,
</manifest>
</configuration>
</execution>
<execution>
...
...
cat-home/src/main/java/com/dianping/cat/CatHomeModule.java
浏览文件 @
4f31163a
...
...
@@ -18,6 +18,8 @@ import com.dianping.cat.report.task.alert.business.BusinessAlert;
import
com.dianping.cat.report.task.alert.exception.ExceptionAlert
;
import
com.dianping.cat.report.task.alert.network.NetworkAlert
;
import
com.dianping.cat.report.task.alert.system.SystemAlert
;
import
com.dianping.cat.report.task.alert.thirdParty.ThirdPartyAlert
;
import
com.dianping.cat.report.task.alert.thirdParty.ThirdPartyAlertTask
;
import
com.dianping.cat.report.task.product.ProjectUpdateTask
;
import
com.dianping.cat.report.view.DomainNavManager
;
import
com.dianping.cat.system.config.ConfigReloadTask
;
...
...
@@ -48,6 +50,10 @@ public class CatHomeModule extends AbstractModule {
Threads
.
forGroup
(
"Cat"
).
start
(
domainNavManager
);
Threads
.
forGroup
(
"Cat"
).
start
(
taskConsumer
);
}
ThirdPartyAlert
thirdPartyAlert
=
ctx
.
lookup
(
ThirdPartyAlert
.
class
);
ThirdPartyAlertTask
thirdPartyAlertTask
=
ctx
.
lookup
(
ThirdPartyAlertTask
.
class
);
Threads
.
forGroup
(
"Cat"
).
start
(
thirdPartyAlert
);
Threads
.
forGroup
(
"Cat"
).
start
(
thirdPartyAlertTask
);
if
(
serverConfigManager
.
isAlertMachine
()
&&
!
serverConfigManager
.
isLocalMode
())
{
BusinessAlert
metricAlert
=
ctx
.
lookup
(
BusinessAlert
.
class
);
...
...
@@ -55,12 +61,18 @@ public class CatHomeModule extends AbstractModule {
SystemAlert
systemAlert
=
ctx
.
lookup
(
SystemAlert
.
class
);
ExceptionAlert
exceptionAlert
=
ctx
.
lookup
(
ExceptionAlert
.
class
);
ProjectUpdateTask
productUpdateTask
=
ctx
.
lookup
(
ProjectUpdateTask
.
class
);
Threads
.
forGroup
(
"Cat"
).
start
(
thirdPartyAlert
);
Threads
.
forGroup
(
"Cat"
).
start
(
thirdPartyAlertTask
);
// ThirdPartyAlert thirdPartyAlert = ctx.lookup(ThirdPartyAlert.class);
// ThirdPartyAlertTask thirdPartyAlertTask = ctx.lookup(ThirdPartyAlertTask.class);
Threads
.
forGroup
(
"Cat"
).
start
(
networkAlert
);
Threads
.
forGroup
(
"Cat"
).
start
(
systemAlert
);
Threads
.
forGroup
(
"Cat"
).
start
(
metricAlert
);
Threads
.
forGroup
(
"Cat"
).
start
(
exceptionAlert
);
Threads
.
forGroup
(
"Cat"
).
start
(
productUpdateTask
);
Threads
.
forGroup
(
"Cat"
).
start
(
thirdPartyAlert
);
Threads
.
forGroup
(
"Cat"
).
start
(
thirdPartyAlertTask
);
}
executeAlarmModule
(
ctx
);
}
...
...
cat-home/src/main/java/com/dianping/cat/build/ComponentsConfigurator.java
浏览文件 @
4f31163a
...
...
@@ -79,6 +79,9 @@ import com.dianping.cat.report.task.alert.summary.AlertSummaryGenerator;
import
com.dianping.cat.report.task.alert.summary.AlertSummaryManager
;
import
com.dianping.cat.report.task.alert.system.SystemAlert
;
import
com.dianping.cat.report.task.alert.system.SystemAlertConfig
;
import
com.dianping.cat.report.task.alert.thirdParty.HttpMonitor
;
import
com.dianping.cat.report.task.alert.thirdParty.ThirdPartyAlert
;
import
com.dianping.cat.report.task.alert.thirdParty.ThirdPartyAlertTask
;
import
com.dianping.cat.report.task.product.ProjectUpdateTask
;
import
com.dianping.cat.report.view.DomainNavManager
;
import
com.dianping.cat.service.IpService
;
...
...
@@ -93,6 +96,7 @@ import com.dianping.cat.system.config.MetricGroupConfigManager;
import
com.dianping.cat.system.config.NetGraphConfigManager
;
import
com.dianping.cat.system.config.NetworkRuleConfigManager
;
import
com.dianping.cat.system.config.SystemRuleConfigManager
;
import
com.dianping.cat.system.config.ThirdPartyConfigManager
;
import
com.dianping.cat.system.tool.DefaultMailImpl
;
import
com.dianping.cat.system.tool.MailSMS
;
...
...
@@ -131,6 +135,12 @@ public class ComponentsConfigurator extends AbstractResourceConfigurator {
ExceptionConfigManager
.
class
,
AlertExceptionBuilder
.
class
,
AlertDao
.
class
).
req
(
ModelService
.
class
,
TopAnalyzer
.
ID
));
all
.
add
(
C
(
ThirdPartyAlert
.
class
).
req
(
ProjectDao
.
class
,
MailSender
.
class
));
all
.
add
(
C
(
HttpMonitor
.
class
));
all
.
add
(
C
(
ThirdPartyAlertTask
.
class
).
req
(
HttpMonitor
.
class
,
ThirdPartyAlert
.
class
,
ThirdPartyConfigManager
.
class
));
return
all
;
}
...
...
@@ -219,6 +229,7 @@ public class ComponentsConfigurator extends AbstractResourceConfigurator {
all
.
add
(
C
(
BusinessRuleConfigManager
.
class
).
req
(
ConfigDao
.
class
));
all
.
add
(
C
(
AlertConfigManager
.
class
).
req
(
ConfigDao
.
class
));
all
.
add
(
C
(
NetGraphConfigManager
.
class
).
req
(
ConfigDao
.
class
));
all
.
add
(
C
(
ThirdPartyConfigManager
.
class
).
req
(
ConfigDao
.
class
));
all
.
add
(
C
(
ConfigReloadTask
.
class
).
req
(
MetricConfigManager
.
class
,
ProductLineConfigManager
.
class
));
return
all
;
...
...
cat-home/src/main/java/com/dianping/cat/report/page/app/Payload.java
浏览文件 @
4f31163a
...
...
@@ -41,7 +41,7 @@ public class Payload extends AbstractReportPayload<Action> {
return
null
;
}
}
@Override
public
Action
getAction
()
{
return
m_action
;
...
...
cat-home/src/main/java/com/dianping/cat/report/page/app/graph/AppGraphCreator.java
浏览文件 @
4f31163a
...
...
@@ -3,6 +3,7 @@ package com.dianping.cat.report.page.app.graph;
import
java.util.Date
;
import
java.util.LinkedHashMap
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.Map
;
import
org.unidal.lookup.annotation.Inject
;
...
...
@@ -19,18 +20,18 @@ public class AppGraphCreator extends AbstractGraphCreator {
private
AppDataService
m_appDataService
;
public
LineChart
buildLineChart
(
QueryEntity
queryEntity1
,
QueryEntity
queryEntity2
,
String
type
)
{
Li
nkedList
<
double
[]>
dataList
=
new
LinkedList
<
double
[]>();
Li
st
<
double
[]>
datas
=
new
LinkedList
<
double
[]>();
if
(
queryEntity1
!=
null
)
{
double
[]
data1
=
prepareQueryData
(
queryEntity1
,
type
);
data
List
.
add
(
data1
);
data
s
.
add
(
data1
);
}
if
(
queryEntity2
!=
null
)
{
double
[]
values2
=
prepareQueryData
(
queryEntity2
,
type
);
data
List
.
add
(
values2
);
data
s
.
add
(
values2
);
}
return
buildChartData
(
data
List
,
type
);
return
buildChartData
(
data
s
,
type
);
}
private
double
[]
prepareQueryData
(
QueryEntity
queryEntity
,
String
type
)
{
...
...
@@ -51,15 +52,16 @@ public class AppGraphCreator extends AbstractGraphCreator {
}
}
public
LineChart
buildChartData
(
final
Li
nkedList
<
double
[]>
dataList
,
String
type
)
{
public
LineChart
buildChartData
(
final
Li
st
<
double
[]>
datas
,
String
type
)
{
LineChart
lineChart
=
new
LineChart
();
lineChart
.
setId
(
"app"
);
lineChart
.
setHtmlTitle
(
queryType
(
type
));
int
length
=
data
List
.
size
();
int
length
=
data
s
.
size
();
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
double
[]
data
=
dataList
.
get
(
i
);
lineChart
.
add
(
"查询"
+
i
++,
data
);
double
[]
data
=
datas
.
get
(
i
);
lineChart
.
add
(
"查询"
+
(
i
+
1
),
data
);
}
return
lineChart
;
}
...
...
cat-home/src/main/java/com/dianping/cat/report/page/heartbeat/DisplayHeartbeat.java
浏览文件 @
4f31163a
...
...
@@ -17,7 +17,6 @@ import com.dianping.cat.consumer.heartbeat.model.entity.Machine;
import
com.dianping.cat.consumer.heartbeat.model.entity.Period
;
import
com.dianping.cat.report.graph.AbstractGraphPayload
;
import
com.dianping.cat.report.graph.GraphBuilder
;
import
com.site.helper.Splitters
;
public
class
DisplayHeartbeat
{
private
static
final
int
K
=
1024
;
...
...
@@ -124,7 +123,8 @@ public class DisplayHeartbeat {
m_systemLoadAverage
[
minute
]
=
period
.
getSystemLoadAverage
();
for
(
Entry
<
String
,
Extension
>
entry
:
period
.
getExtensions
().
entrySet
())
{
for
(
Entry
<
String
,
Extension
>
entry
:
period
.
getExtensions
()
.
entrySet
())
{
Map
<
String
,
double
[]>
groups
=
m_extensions
.
get
(
entry
.
getKey
());
if
(
groups
==
null
)
{
...
...
@@ -132,7 +132,8 @@ public class DisplayHeartbeat {
m_extensions
.
put
(
entry
.
getKey
(),
groups
);
}
for
(
Entry
<
String
,
Detail
>
detail
:
entry
.
getValue
().
getDetails
().
entrySet
())
{
for
(
Entry
<
String
,
Detail
>
detail
:
entry
.
getValue
()
.
getDetails
().
entrySet
())
{
double
[]
doubles
=
groups
.
get
(
detail
.
getKey
());
if
(
doubles
==
null
)
{
...
...
@@ -156,7 +157,8 @@ public class DisplayHeartbeat {
}
public
String
getActiceThreadGraph
()
{
return
m_builder
.
build
(
new
HeartbeatPayload
(
0
,
"Active Thread"
,
"Minute"
,
"Count"
,
m_activeThreads
));
return
m_builder
.
build
(
new
HeartbeatPayload
(
0
,
"Active Thread"
,
"Minute"
,
"Count"
,
m_activeThreads
));
}
public
double
[]
getActiveThreads
()
{
...
...
@@ -206,8 +208,9 @@ public class DisplayHeartbeat {
}
public
String
getCatMessageOverflowGraph
()
{
return
m_builder
.
build
(
new
HeartbeatPayload
(
1
,
"Cat Message Overflow / Minute"
,
"Minute"
,
"Count"
,
m_addCatMessageOverflow
));
return
m_builder
.
build
(
new
HeartbeatPayload
(
1
,
"Cat Message Overflow / Minute"
,
"Minute"
,
"Count"
,
m_addCatMessageOverflow
));
}
public
double
[]
getCatMessageProduced
()
{
...
...
@@ -215,8 +218,9 @@ public class DisplayHeartbeat {
}
public
String
getCatMessageProducedGraph
()
{
return
m_builder
.
build
(
new
HeartbeatPayload
(
0
,
"Cat Message Produced / Minute"
,
"Minute"
,
"Count"
,
m_addCatMessageProduced
));
return
m_builder
.
build
(
new
HeartbeatPayload
(
0
,
"Cat Message Produced / Minute"
,
"Minute"
,
"Count"
,
m_addCatMessageProduced
));
}
public
double
[]
getCatMessageSize
()
{
...
...
@@ -224,11 +228,14 @@ public class DisplayHeartbeat {
}
public
String
getCatMessageSizeGraph
()
{
return
m_builder
.
build
(
new
HeartbeatPayload
(
2
,
"Cat Message Size / Minute"
,
"Minute"
,
"MB"
,
m_addCatMessageSize
));
return
m_builder
.
build
(
new
HeartbeatPayload
(
2
,
"Cat Message Size / Minute"
,
"Minute"
,
"MB"
,
m_addCatMessageSize
));
}
public
String
getCatThreadGraph
()
{
return
m_builder
.
build
(
new
HeartbeatPayload
(
1
,
"Cat Thread"
,
"Minute"
,
"Count"
,
m_catThreads
));
return
m_builder
.
build
(
new
HeartbeatPayload
(
1
,
"Cat Thread"
,
"Minute"
,
"Count"
,
m_catThreads
));
}
public
double
[]
getCatThreads
()
{
...
...
@@ -240,7 +247,8 @@ public class DisplayHeartbeat {
}
public
String
getDeamonThreadGraph
()
{
return
m_builder
.
build
(
new
HeartbeatPayload
(
6
,
"Daemon Thread"
,
"Minute"
,
"Count"
,
m_daemonThreads
));
return
m_builder
.
build
(
new
HeartbeatPayload
(
6
,
"Daemon Thread"
,
"Minute"
,
"Count"
,
m_daemonThreads
));
}
public
List
<
String
>
getDiskNames
()
{
...
...
@@ -290,7 +298,8 @@ public class DisplayHeartbeat {
}
String
path
=
disks
.
get
(
i
).
getPath
();
String
graph
=
m_builder
.
build
(
new
HeartbeatPayload
(
i
,
"Disk Free ("
+
path
+
")"
,
"Minute"
,
"GB"
,
values
));
String
graph
=
m_builder
.
build
(
new
HeartbeatPayload
(
i
,
"Disk Free ("
+
path
+
")"
,
"Minute"
,
"GB"
,
values
));
sb
.
append
(
graph
);
}
...
...
@@ -325,11 +334,13 @@ public class DisplayHeartbeat {
}
public
String
getHeapUsageGraph
()
{
return
m_builder
.
build
(
new
HeartbeatPayload
(
1
,
"Heap Usage"
,
"Minute"
,
"MB"
,
m_heapUsage
));
return
m_builder
.
build
(
new
HeartbeatPayload
(
1
,
"Heap Usage"
,
"Minute"
,
"MB"
,
m_heapUsage
));
}
public
String
getHttpTheadGraph
()
{
return
m_builder
.
build
(
new
HeartbeatPayload
(
0
,
"HTTP Thread"
,
"Minute"
,
"Count"
,
m_httpThreads
));
return
m_builder
.
build
(
new
HeartbeatPayload
(
0
,
"HTTP Thread"
,
"Minute"
,
"Count"
,
m_httpThreads
));
}
public
double
[]
getHttpThreads
()
{
...
...
@@ -341,7 +352,8 @@ public class DisplayHeartbeat {
}
public
String
getMemoryFreeGraph
()
{
return
m_builder
.
build
(
new
HeartbeatPayload
(
0
,
"Memory Free"
,
"Minute"
,
"MB"
,
m_memoryFree
));
return
m_builder
.
build
(
new
HeartbeatPayload
(
0
,
"Memory Free"
,
"Minute"
,
"MB"
,
m_memoryFree
));
}
public
double
[]
getNewGcCount
()
{
...
...
@@ -349,7 +361,8 @@ public class DisplayHeartbeat {
}
public
String
getNewGcCountGraph
()
{
return
m_builder
.
build
(
new
HeartbeatPayload
(
0
,
"NewGc Count"
,
"Minute"
,
"Count"
,
m_addNewGcCount
));
return
m_builder
.
build
(
new
HeartbeatPayload
(
0
,
"NewGc Count"
,
"Minute"
,
"Count"
,
m_addNewGcCount
));
}
public
double
[]
getNewThreads
()
{
...
...
@@ -361,7 +374,8 @@ public class DisplayHeartbeat {
}
public
String
getNoneHeapUsageGraph
()
{
return
m_builder
.
build
(
new
HeartbeatPayload
(
2
,
"None Heap Usage"
,
"Minute"
,
"MB"
,
m_noneHeapUsage
));
return
m_builder
.
build
(
new
HeartbeatPayload
(
2
,
"None Heap Usage"
,
"Minute"
,
"MB"
,
m_noneHeapUsage
));
}
public
double
[]
getOldGcCount
()
{
...
...
@@ -369,7 +383,8 @@ public class DisplayHeartbeat {
}
public
String
getOldGcCountGraph
()
{
return
m_builder
.
build
(
new
HeartbeatPayload
(
1
,
"OldGc Count"
,
"Minute"
,
"Count"
,
m_addOldGcCount
));
return
m_builder
.
build
(
new
HeartbeatPayload
(
1
,
"OldGc Count"
,
"Minute"
,
"Count"
,
m_addOldGcCount
));
}
public
List
<
Period
>
getPeriods
()
{
...
...
@@ -377,7 +392,8 @@ public class DisplayHeartbeat {
}
public
String
getPigeonTheadGraph
()
{
return
m_builder
.
build
(
new
HeartbeatPayload
(
2
,
"Pigeon Thread"
,
"Minute"
,
"Count"
,
m_pigeonThreads
));
return
m_builder
.
build
(
new
HeartbeatPayload
(
2
,
"Pigeon Thread"
,
"Minute"
,
"Count"
,
m_pigeonThreads
));
}
public
double
[]
getPigeonThreads
()
{
...
...
@@ -385,7 +401,8 @@ public class DisplayHeartbeat {
}
public
String
getStartedThreadGraph
()
{
return
m_builder
.
build
(
new
HeartbeatPayload
(
1
,
"Started Thread"
,
"Minute"
,
"Count"
,
m_newThreads
));
return
m_builder
.
build
(
new
HeartbeatPayload
(
1
,
"Started Thread"
,
"Minute"
,
"Count"
,
m_newThreads
));
}
public
double
[]
getSystemLoadAverage
()
{
...
...
@@ -393,17 +410,19 @@ public class DisplayHeartbeat {
}
public
String
getSystemLoadAverageGraph
()
{
return
m_builder
.
build
(
new
HeartbeatPayload
(
2
,
"System Load Average"
,
"Minute"
,
""
,
m_systemLoadAverage
));
return
m_builder
.
build
(
new
HeartbeatPayload
(
2
,
"System Load Average"
,
"Minute"
,
""
,
m_systemLoadAverage
));
}
public
String
getTotalThreadGraph
()
{
return
m_builder
.
build
(
new
HeartbeatPayload
(
2
,
"Total Started Thread"
,
"Minute"
,
"Count"
,
m_totalThreads
));
return
m_builder
.
build
(
new
HeartbeatPayload
(
2
,
"Total Started Thread"
,
"Minute"
,
"Count"
,
m_totalThreads
));
}
public
double
[]
getTotalThreads
()
{
return
m_totalThreads
;
}
public
Map
<
String
,
Map
<
String
,
String
>>
getDalGraph
()
{
Map
<
String
,
Map
<
String
,
String
>>
graphs
=
new
HashMap
<
String
,
Map
<
String
,
String
>>();
Map
<
String
,
double
[]>
dalData
=
m_extensions
.
get
(
DAL
);
...
...
@@ -415,22 +434,25 @@ public class DisplayHeartbeat {
for
(
Entry
<
String
,
double
[]>
entry
:
dalData
.
entrySet
())
{
String
key
=
entry
.
getKey
();
List
<
String
>
split
=
Splitters
.
by
(
'-'
).
trim
().
split
(
key
);
if
(
split
!=
null
&&
split
.
size
()
==
2
)
{
String
db
=
split
.
get
(
0
);
String
title
=
split
.
get
(
1
);
int
pos
=
key
.
lastIndexOf
(
'-'
);
if
(
pos
>
0
)
{
String
db
=
key
.
substring
(
0
,
pos
);
String
title
=
key
.
substring
(
pos
+
1
);
Map
<
String
,
String
>
map
=
graphs
.
get
(
db
);
if
(
map
==
null
)
{
map
=
new
HashMap
<
String
,
String
>();
graphs
.
put
(
split
.
get
(
0
)
,
map
);
graphs
.
put
(
db
,
map
);
}
if
(!
DAL_INDEX
.
containsKey
(
title
))
{
DAL_INDEX
.
put
(
title
,
DAL_INDEX_COUNTER
.
getAndIncrement
());
}
map
.
put
(
title
,
m_builder
.
build
(
new
HeartbeatPayload
(
DAL_INDEX
.
get
(
title
),
title
,
"Minute"
,
"Count"
,
entry
.
getValue
())));
map
.
put
(
title
,
m_builder
.
build
(
new
HeartbeatPayload
(
DAL_INDEX
.
get
(
title
),
title
,
"Minute"
,
"Count"
,
entry
.
getValue
())));
}
}
...
...
@@ -446,7 +468,8 @@ public class DisplayHeartbeat {
private
double
[]
m_values
;
public
HeartbeatPayload
(
int
index
,
String
title
,
String
axisXLabel
,
String
axisYLabel
,
double
[]
values
)
{
public
HeartbeatPayload
(
int
index
,
String
title
,
String
axisXLabel
,
String
axisYLabel
,
double
[]
values
)
{
super
(
title
,
axisXLabel
,
axisYLabel
);
m_idPrefix
=
title
;
...
...
cat-home/src/main/java/com/dianping/cat/report/task/alert/exception/AlertExceptionBuilder.java
浏览文件 @
4f31163a
...
...
@@ -127,7 +127,8 @@ public class AlertExceptionBuilder {
public
String
buildMailContent
(
String
exceptions
,
String
domain
,
String
contactInfo
)
{
String
content
=
buildContent
(
exceptions
,
domain
,
contactInfo
);
String
url
=
"http://cat.dianpingoa.com/cat/r/p?domain="
+
domain
;
String
date
=
new
SimpleDateFormat
(
"yyyyMMddHH"
).
format
(
new
Date
());
String
url
=
"http://cat.dianpingoa.com/cat/r/p?domain="
+
domain
+
"&date="
+
date
;
String
mailContent
=
content
+
"<br/>"
+
" <a href='"
+
url
+
"'>点击此处查看详情</a>"
;
return
mailContent
;
...
...
cat-home/src/main/java/com/dianping/cat/report/task/alert/exception/ExceptionAlert.java
浏览文件 @
4f31163a
...
...
@@ -8,8 +8,6 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
org.codehaus.plexus.logging.LogEnabled
;
import
org.codehaus.plexus.logging.Logger
;
import
org.unidal.helper.Threads.Task
;
import
org.unidal.lookup.annotation.Inject
;
...
...
@@ -30,7 +28,7 @@ import com.dianping.cat.service.ModelRequest;
import
com.dianping.cat.service.ModelResponse
;
import
com.dianping.cat.system.config.ExceptionConfigManager
;
public
class
ExceptionAlert
implements
Task
,
LogEnabled
{
public
class
ExceptionAlert
implements
Task
{
@Inject
private
ExceptionAlertConfig
m_alertConfig
;
...
...
@@ -54,8 +52,6 @@ public class ExceptionAlert implements Task, LogEnabled {
private
static
final
int
ALERT_PERIOD
=
1
;
private
Logger
m_logger
;
private
TopMetric
buildTopMetric
(
Date
date
)
{
TopReport
topReport
=
queryTopReport
(
date
);
TopMetric
topMetric
=
new
TopMetric
(
ALERT_PERIOD
,
Integer
.
MAX_VALUE
,
m_exceptionConfigManager
);
...
...
@@ -65,11 +61,6 @@ public class ExceptionAlert implements Task, LogEnabled {
return
topMetric
;
}
@Override
public
void
enableLogging
(
Logger
logger
)
{
m_logger
=
logger
;
}
public
String
getName
()
{
return
"exception-alert"
;
}
...
...
@@ -132,7 +123,7 @@ public class ExceptionAlert implements Task, LogEnabled {
m_alertManager
.
storeAlert
(
getName
(),
domain
,
exception
.
getName
(),
mailTitle
,
alertResult
);
}
}
catch
(
Exception
e
)
{
m_logger
.
error
(
e
.
getMessage
()
);
Cat
.
logError
(
e
);
}
}
t
.
setStatus
(
Transaction
.
SUCCESS
);
...
...
cat-home/src/main/java/com/dianping/cat/report/task/alert/thirdParty/HttpMonitor.java
0 → 100644
浏览文件 @
4f31163a
package
com.dianping.cat.report.task.alert.thirdParty
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.OutputStreamWriter
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
import
org.codehaus.plexus.util.StringUtils
;
import
org.unidal.helper.Files
;
public
class
HttpMonitor
{
public
String
readFromGet
(
String
url
)
{
HttpURLConnection
connection
=
null
;
InputStream
in
=
null
;
BufferedReader
reader
=
null
;
try
{
URL
address_url
=
new
URL
(
url
);
connection
=
(
HttpURLConnection
)
address_url
.
openConnection
();
connection
.
setRequestMethod
(
"GET"
);
connection
.
setConnectTimeout
(
5000
);
connection
.
setReadTimeout
(
5000
);
int
response_code
=
connection
.
getResponseCode
();
if
(
response_code
==
HttpURLConnection
.
HTTP_OK
)
{
in
=
connection
.
getInputStream
();
String
result
=
Files
.
forIO
().
readFrom
(
in
,
"utf-8"
);
return
result
;
}
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
finally
{
if
(
connection
!=
null
)
{
connection
.
disconnect
();
}
try
{
if
(
in
!=
null
)
{
in
.
close
();
}
if
(
reader
!=
null
)
{
reader
.
close
();
}
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
return
null
;
}
public
String
readFromPost
(
String
url
,
String
content
)
{
HttpURLConnection
connection
=
null
;
BufferedReader
reader
=
null
;
OutputStreamWriter
writer
=
null
;
InputStream
in
=
null
;
try
{
URL
postUrl
=
new
URL
(
url
);
connection
=
(
HttpURLConnection
)
postUrl
.
openConnection
();
connection
.
setDoOutput
(
true
);
connection
.
setDoInput
(
true
);
connection
.
setRequestMethod
(
"POST"
);
connection
.
setUseCaches
(
false
);
connection
.
setInstanceFollowRedirects
(
true
);
connection
.
setConnectTimeout
(
5000
);
connection
.
setReadTimeout
(
5000
);
if
(
StringUtils
.
isNotEmpty
(
content
))
{
writer
=
new
OutputStreamWriter
(
connection
.
getOutputStream
());
writer
.
write
(
content
);
writer
.
flush
();
}
int
response_code
=
connection
.
getResponseCode
();
if
(
response_code
==
HttpURLConnection
.
HTTP_OK
)
{
in
=
connection
.
getInputStream
();
String
result
=
Files
.
forIO
().
readFrom
(
in
,
"utf-8"
);
return
result
;
}
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
finally
{
if
(
connection
!=
null
)
{
connection
.
disconnect
();
}
try
{
if
(
reader
!=
null
)
{
reader
.
close
();
}
if
(
writer
!=
null
)
{
writer
.
close
();
}
if
(
in
!=
null
)
{
in
.
close
();
}
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
return
null
;
}
}
cat-home/src/main/java/com/dianping/cat/report/task/alert/thirdParty/ThirdPartyAlert.java
0 → 100644
浏览文件 @
4f31163a
package
com.dianping.cat.report.task.alert.thirdParty
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
java.util.concurrent.ArrayBlockingQueue
;
import
java.util.concurrent.BlockingQueue
;
import
java.util.concurrent.TimeUnit
;
import
org.codehaus.plexus.logging.LogEnabled
;
import
org.codehaus.plexus.logging.Logger
;
import
org.unidal.helper.Threads.Task
;
import
org.unidal.lookup.annotation.Inject
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.core.dal.Project
;
import
com.dianping.cat.core.dal.ProjectDao
;
import
com.dianping.cat.core.dal.ProjectEntity
;
import
com.dianping.cat.helper.TimeUtil
;
import
com.dianping.cat.home.alert.thirdParty.entity.Domain
;
import
com.dianping.cat.message.Event
;
import
com.dianping.cat.message.Transaction
;
import
com.dianping.cat.report.task.alert.sender.MailSender
;
import
com.site.helper.Splitters
;
public
class
ThirdPartyAlert
implements
Task
,
LogEnabled
{
@Inject
private
ProjectDao
m_projectDao
;
@Inject
protected
MailSender
m_mailSender
;
private
Logger
m_logger
;
private
static
final
long
DURATION
=
TimeUtil
.
ONE_MINUTE
;
private
BlockingQueue
<
ThirdPartyAlertEntity
>
m_entities
=
new
ArrayBlockingQueue
<
ThirdPartyAlertEntity
>(
5000
);
public
boolean
put
(
ThirdPartyAlertEntity
entity
)
{
boolean
result
=
true
;
try
{
boolean
temp
=
m_entities
.
offer
(
entity
,
5
,
TimeUnit
.
MILLISECONDS
);
if
(!
temp
)
{
result
=
temp
;
}
return
result
;
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
return
false
;
}
@Override
public
void
run
()
{
boolean
active
=
true
;
try
{
Thread
.
sleep
(
5000
);
}
catch
(
InterruptedException
e
)
{
active
=
false
;
}
while
(
active
)
{
long
current
=
System
.
currentTimeMillis
();
int
minute
=
Calendar
.
getInstance
().
get
(
Calendar
.
MINUTE
);
String
minuteStr
=
String
.
valueOf
(
minute
);
if
(
minute
<
10
)
{
minuteStr
=
'0'
+
minuteStr
;
}
Transaction
t
=
Cat
.
newTransaction
(
"ThirdPartyAlert"
,
"M"
+
minuteStr
);
try
{
List
<
ThirdPartyAlertEntity
>
alertEntities
=
new
ArrayList
<
ThirdPartyAlertEntity
>();
while
(
m_entities
.
size
()
>
0
)
{
ThirdPartyAlertEntity
entity
=
m_entities
.
poll
(
5
,
TimeUnit
.
MILLISECONDS
);
alertEntities
.
add
(
entity
);
}
Map
<
String
,
List
<
ThirdPartyAlertEntity
>>
domain2AlertMap
=
buildDomain2AlertMap
(
alertEntities
);
for
(
Entry
<
String
,
List
<
ThirdPartyAlertEntity
>>
entry
:
domain2AlertMap
.
entrySet
())
{
sendAlert
(
entry
.
getKey
(),
entry
.
getValue
());
}
t
.
setStatus
(
Transaction
.
SUCCESS
);
}
catch
(
Exception
e
)
{
t
.
setStatus
(
e
);
Cat
.
logError
(
e
);
}
finally
{
t
.
complete
();
}
long
duration
=
System
.
currentTimeMillis
()
-
current
;
try
{
if
(
duration
<
DURATION
)
{
Thread
.
sleep
(
DURATION
-
duration
);
}
}
catch
(
InterruptedException
e
)
{
active
=
false
;
}
}
}
private
Map
<
String
,
List
<
ThirdPartyAlertEntity
>>
buildDomain2AlertMap
(
List
<
ThirdPartyAlertEntity
>
alertEntities
)
{
Map
<
String
,
List
<
ThirdPartyAlertEntity
>>
domain2AlertMap
=
new
HashMap
<
String
,
List
<
ThirdPartyAlertEntity
>>();
for
(
ThirdPartyAlertEntity
entity
:
alertEntities
)
{
for
(
Domain
domain
:
entity
.
getDomains
())
{
String
domainId
=
domain
.
getId
();
List
<
ThirdPartyAlertEntity
>
alertList
=
domain2AlertMap
.
get
(
domainId
);
if
(
alertList
==
null
)
{
alertList
=
new
ArrayList
<
ThirdPartyAlertEntity
>();
domain2AlertMap
.
put
(
domainId
,
alertList
);
}
alertList
.
add
(
entity
);
}
}
return
domain2AlertMap
;
}
private
Project
queryProjectByDomain
(
String
projectName
)
{
Project
project
=
null
;
try
{
project
=
m_projectDao
.
findByDomain
(
projectName
,
ProjectEntity
.
READSET_FULL
);
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
return
project
;
}
public
String
buildMailContent
(
String
exceptions
,
String
domain
)
{
StringBuilder
sb
=
new
StringBuilder
();
String
time
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm"
).
format
(
new
Date
());
sb
.
append
(
"[CAT第三方告警] [项目: "
).
append
(
domain
).
append
(
"] : "
);
sb
.
append
(
exceptions
).
append
(
"[时间: "
).
append
(
time
).
append
(
"]"
);
return
sb
.
toString
();
}
private
void
sendAlert
(
String
domain
,
List
<
ThirdPartyAlertEntity
>
entities
)
{
Project
project
=
queryProjectByDomain
(
domain
);
List
<
String
>
emails
=
buildMailReceivers
(
project
);
String
mailTitle
=
buildMailTitle
(
domain
);
String
mailContent
=
buildMailContent
(
entities
.
toString
(),
domain
);
m_mailSender
.
sendAlert
(
emails
,
domain
,
mailTitle
,
mailContent
);
m_logger
.
info
(
mailTitle
+
" "
+
mailContent
+
" "
+
emails
);
Cat
.
logEvent
(
"ExceptionAlert"
,
domain
,
Event
.
SUCCESS
,
"[邮件告警] "
+
mailTitle
+
" "
+
mailContent
);
}
private
String
buildMailTitle
(
String
domain
)
{
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
"[CAT第三方告警] [项目: "
).
append
(
domain
).
append
(
"]"
);
return
sb
.
toString
();
}
private
List
<
String
>
buildMailReceivers
(
Project
project
)
{
List
<
String
>
mailReceivers
=
new
ArrayList
<
String
>();
mailReceivers
.
addAll
(
split
(
project
.
getEmail
()));
return
mailReceivers
;
}
private
List
<
String
>
split
(
String
str
)
{
List
<
String
>
result
=
new
ArrayList
<
String
>();
if
(
str
!=
null
)
{
result
.
addAll
(
Splitters
.
by
(
","
).
noEmptyItem
().
split
(
str
));
}
return
result
;
}
@Override
public
void
enableLogging
(
Logger
logger
)
{
m_logger
=
logger
;
}
@Override
public
String
getName
()
{
return
"thirdParty-alert"
;
}
@Override
public
void
shutdown
()
{
}
}
cat-home/src/main/java/com/dianping/cat/report/task/alert/thirdParty/ThirdPartyAlertEntity.java
0 → 100644
浏览文件 @
4f31163a
package
com.dianping.cat.report.task.alert.thirdParty
;
import
java.util.List
;
import
com.dianping.cat.home.alert.thirdParty.entity.Domain
;
public
class
ThirdPartyAlertEntity
{
private
String
m_type
;
private
List
<
Domain
>
m_domains
;
private
String
m_details
;
public
String
getType
()
{
return
m_type
;
}
public
String
getDetails
()
{
return
m_details
;
}
public
List
<
Domain
>
getDomains
()
{
return
m_domains
;
}
public
ThirdPartyAlertEntity
setType
(
String
type
)
{
m_type
=
type
;
return
this
;
}
public
ThirdPartyAlertEntity
setDetails
(
String
details
)
{
m_details
=
details
;
return
this
;
}
public
ThirdPartyAlertEntity
setDomains
(
List
<
Domain
>
domains
)
{
m_domains
=
domains
;
return
this
;
}
@Override
public
String
toString
()
{
return
"[type="
+
m_type
+
", details="
+
m_details
+
"]"
;
}
}
cat-home/src/main/java/com/dianping/cat/report/task/alert/thirdParty/ThirdPartyAlertTask.java
0 → 100644
浏览文件 @
4f31163a
package
com.dianping.cat.report.task.alert.thirdParty
;
import
java.util.List
;
import
java.util.Timer
;
import
java.util.TimerTask
;
import
org.codehaus.plexus.logging.LogEnabled
;
import
org.codehaus.plexus.logging.Logger
;
import
org.codehaus.plexus.util.StringUtils
;
import
org.unidal.helper.Threads.Task
;
import
org.unidal.lookup.annotation.Inject
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.helper.TimeUtil
;
import
com.dianping.cat.home.alert.thirdParty.entity.Http
;
import
com.dianping.cat.message.Transaction
;
import
com.dianping.cat.system.config.ThirdPartyConfigManager
;
public
class
ThirdPartyAlertTask
implements
Task
,
LogEnabled
{
@Inject
private
HttpMonitor
m_httpMonitor
;
@Inject
private
ThirdPartyAlert
m_thirdPartyAlert
;
@Inject
private
ThirdPartyConfigManager
m_configManager
;
private
static
final
long
DURATION
=
TimeUtil
.
ONE_MINUTE
;
private
Logger
m_logger
;
@Override
public
void
run
()
{
boolean
active
=
true
;
while
(
active
)
{
long
current
=
System
.
currentTimeMillis
();
Transaction
t
=
Cat
.
newTransaction
(
"Task"
,
"ThirdPartyAlert"
);
try
{
buildAlertEntities
(
current
);
t
.
setStatus
(
Transaction
.
SUCCESS
);
}
catch
(
Exception
e
)
{
t
.
setStatus
(
e
);
m_logger
.
error
(
e
.
getMessage
(),
e
);
}
finally
{
t
.
complete
();
}
long
duration
=
System
.
currentTimeMillis
()
-
current
;
try
{
if
(
duration
<
DURATION
)
{
Thread
.
sleep
(
DURATION
-
duration
);
}
}
catch
(
InterruptedException
e
)
{
active
=
false
;
}
}
}
public
void
putAlertEnity
(
ThirdPartyAlertEntity
entity
)
{
m_thirdPartyAlert
.
put
(
entity
);
}
private
String
connectHttpUrl
(
Http
http
)
{
String
type
=
http
.
getType
();
String
result
=
null
;
String
paras
=
http
.
getPars
();
if
(
StringUtils
.
isNotEmpty
(
paras
))
{
paras
=
paras
.
replaceAll
(
"[;]"
,
"&"
);
http
.
setPars
(
paras
);
}
try
{
if
(
"get"
.
equalsIgnoreCase
(
type
))
{
String
url
=
http
.
getUrl
();
if
(
StringUtils
.
isNotEmpty
(
paras
))
{
url
+=
"?"
+
paras
;
}
result
=
m_httpMonitor
.
readFromGet
(
url
);
}
else
if
(
"post"
.
equalsIgnoreCase
(
type
))
{
String
url
=
http
.
getUrl
();
result
=
m_httpMonitor
.
readFromPost
(
url
,
paras
);
}
}
catch
(
Exception
e
)
{
m_logger
.
error
(
e
.
getMessage
(),
e
);
}
return
result
;
}
private
void
buildAlertEntities
(
long
current
)
{
List
<
Http
>
https
=
m_configManager
.
queryHttps
();
for
(
Http
http
:
https
)
{
String
result
=
connectHttpUrl
(
http
);
if
(
StringUtils
.
isEmpty
(
result
))
{
new
HttpReconnector
(
this
,
http
,
current
+
DURATION
);
}
}
}
@Override
public
String
getName
()
{
return
"thirdParty-alert-task"
;
}
@Override
public
void
enableLogging
(
Logger
logger
)
{
m_logger
=
logger
;
}
@Override
public
void
shutdown
()
{
}
public
ThirdPartyAlertEntity
buildAlertEntity
(
Http
http
)
{
ThirdPartyAlertEntity
entity
=
new
ThirdPartyAlertEntity
();
String
url
=
http
.
getUrl
();
String
type
=
http
.
getType
();
String
pars
=
http
.
getPars
();
String
details
=
"HTTP URL["
+
url
+
"?"
+
pars
+
"] "
+
type
.
toUpperCase
()
+
"无法访问"
;
entity
.
setDomains
(
http
.
getDomains
()).
setType
(
type
).
setDetails
(
details
);
return
entity
;
}
public
class
HttpReconnector
{
private
Timer
m_timer
;
public
HttpReconnector
(
ThirdPartyAlertTask
alertTask
,
Http
http
,
long
deadLine
)
{
m_timer
=
new
Timer
();
m_timer
.
schedule
(
new
RemindTask
(
alertTask
,
http
,
deadLine
),
0
,
5
*
1000
);
}
class
RemindTask
extends
TimerTask
{
private
int
m_reconncetNum
=
2
;
private
ThirdPartyAlertTask
m_alertTask
;
private
Http
m_http
;
private
long
m_deadLine
;
public
RemindTask
(
ThirdPartyAlertTask
alertTask
,
Http
http
,
long
deadLine
)
{
m_alertTask
=
alertTask
;
m_http
=
http
;
m_deadLine
=
deadLine
;
}
public
void
run
()
{
if
(
m_reconncetNum
>
0
&&
System
.
currentTimeMillis
()
<
m_deadLine
)
{
m_reconncetNum
--;
String
result
=
m_alertTask
.
connectHttpUrl
(
m_http
);
if
(
StringUtils
.
isNotEmpty
(
result
))
{
m_timer
.
cancel
();
}
}
else
{
m_timer
.
cancel
();
m_alertTask
.
putAlertEnity
(
m_alertTask
.
buildAlertEntity
(
m_http
));
}
}
}
}
}
cat-home/src/main/java/com/dianping/cat/system/config/ThirdPartyConfigManager.java
0 → 100644
浏览文件 @
4f31163a
package
com.dianping.cat.system.config
;
import
java.util.List
;
import
org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable
;
import
org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException
;
import
org.unidal.dal.jdbc.DalNotFoundException
;
import
org.unidal.helper.Files
;
import
org.unidal.lookup.annotation.Inject
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.core.config.Config
;
import
com.dianping.cat.core.config.ConfigDao
;
import
com.dianping.cat.core.config.ConfigEntity
;
import
com.dianping.cat.home.alert.thirdParty.entity.Http
;
import
com.dianping.cat.home.alert.thirdParty.entity.Socket
;
import
com.dianping.cat.home.alert.thirdParty.entity.ThirdPartyConfig
;
import
com.dianping.cat.home.alert.thirdParty.transform.DefaultSaxParser
;
public
class
ThirdPartyConfigManager
implements
Initializable
{
@Inject
private
ConfigDao
m_configDao
;
private
int
m_configId
;
private
ThirdPartyConfig
m_thirdPartyConfig
;
private
static
final
String
CONFIG_NAME
=
"thirdPartyConfig"
;
public
List
<
Http
>
queryHttps
()
{
return
m_thirdPartyConfig
.
getHttps
();
}
public
List
<
Socket
>
querSockets
()
{
return
m_thirdPartyConfig
.
getSockets
();
}
public
ThirdPartyConfig
getConfig
()
{
return
m_thirdPartyConfig
;
}
public
boolean
insert
(
String
xml
)
{
try
{
m_thirdPartyConfig
=
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_thirdPartyConfig
.
toString
());
m_configDao
.
updateByPK
(
config
,
ConfigEntity
.
UPDATESET_FULL
);
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
return
false
;
}
}
return
true
;
}
@Override
public
void
initialize
()
throws
InitializationException
{
try
{
Config
config
=
m_configDao
.
findByName
(
CONFIG_NAME
,
ConfigEntity
.
READSET_FULL
);
String
content
=
config
.
getContent
();
m_thirdPartyConfig
=
DefaultSaxParser
.
parse
(
content
);
m_configId
=
config
.
getId
();
}
catch
(
DalNotFoundException
e
)
{
try
{
String
content
=
Files
.
forIO
().
readFrom
(
this
.
getClass
().
getResourceAsStream
(
"/config/default-thirdParty-config.xml"
),
"utf-8"
);
Config
config
=
m_configDao
.
createLocal
();
config
.
setName
(
CONFIG_NAME
);
config
.
setContent
(
content
);
m_configDao
.
insert
(
config
);
m_thirdPartyConfig
=
DefaultSaxParser
.
parse
(
content
);
m_configId
=
config
.
getId
();
}
catch
(
Exception
ex
)
{
Cat
.
logError
(
ex
);
}
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
if
(
m_thirdPartyConfig
==
null
)
{
m_thirdPartyConfig
=
new
ThirdPartyConfig
();
}
}
}
cat-home/src/main/java/com/dianping/cat/system/page/config/Action.java
浏览文件 @
4f31163a
...
...
@@ -96,9 +96,11 @@ public enum Action implements org.unidal.web.mvc.Action {
METRIC_GROUP_CONFIG_UPDATE
(
"metricGroupConfigUpdate"
),
NET_GRAPH_CONFIG_UPDATE
(
"netGraphConfigUpdate"
),
APP_CONFIG_UPDATE
(
"appConfigUpdate"
);
APP_CONFIG_UPDATE
(
"appConfigUpdate"
),
THIRD_PARTY_CONFIG_UPDATE
(
"thirdPartyConfigUpdate"
);
private
String
m_name
;
public
static
Action
getByName
(
String
name
,
Action
defaultAction
)
{
...
...
cat-home/src/main/java/com/dianping/cat/system/page/config/Handler.java
浏览文件 @
4f31163a
...
...
@@ -56,6 +56,7 @@ import com.dianping.cat.system.config.MetricGroupConfigManager;
import
com.dianping.cat.system.config.NetGraphConfigManager
;
import
com.dianping.cat.system.config.NetworkRuleConfigManager
;
import
com.dianping.cat.system.config.SystemRuleConfigManager
;
import
com.dianping.cat.system.config.ThirdPartyConfigManager
;
public
class
Handler
implements
PageHandler
<
Context
>
{
@Inject
...
...
@@ -118,6 +119,9 @@ public class Handler implements PageHandler<Context> {
@Inject
private
AlertTypeManager
m_alertTypeManager
;
@Inject
private
ThirdPartyConfigManager
m_thirdPartyConfigManager
;
private
void
deleteAggregationRule
(
Payload
payload
)
{
m_aggreationConfigManager
.
deleteAggregationRule
(
payload
.
getPattern
());
}
...
...
@@ -482,6 +486,13 @@ public class Handler implements PageHandler<Context> {
}
model
.
setContent
(
m_appConfigManager
.
getConfig
().
toString
());
break
;
case
THIRD_PARTY_CONFIG_UPDATE:
String
thirdPartyConfig
=
payload
.
getContent
();
if
(!
StringUtils
.
isEmpty
(
thirdPartyConfig
))
{
model
.
setOpState
(
m_thirdPartyConfigManager
.
insert
(
thirdPartyConfig
));
}
model
.
setContent
(
m_thirdPartyConfigManager
.
getConfig
().
toString
());
break
;
}
m_jspViewer
.
view
(
ctx
,
model
);
}
...
...
cat-home/src/main/java/com/dianping/cat/system/page/config/JspFile.java
浏览文件 @
4f31163a
...
...
@@ -63,7 +63,9 @@ public enum JspFile {
NET_GRAPH_CONFIG_UPDATE
(
"/jsp/system/netGraphConfig/netGraphConfig.jsp"
),
APP_CONFIG_UPDATE
(
"/jsp/system/appConfig/appConfig.jsp"
);
APP_CONFIG_UPDATE
(
"/jsp/system/appConfig/appConfig.jsp"
),
THIRD_PARTY_CONFIG_UPDATE
(
"/jsp/system/thirdParty/thirdPartyConfig.jsp"
);
private
String
m_path
;
...
...
cat-home/src/main/java/com/dianping/cat/system/page/config/JspViewer.java
浏览文件 @
4f31163a
...
...
@@ -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
THIRD_PARTY_CONFIG_UPDATE:
return
JspFile
.
THIRD_PARTY_CONFIG_UPDATE
.
getPath
();
}
throw
new
RuntimeException
(
"Unknown action: "
+
action
);
...
...
cat-home/src/main/resources/META-INF/dal/model/thirdParty-codegen.xml
0 → 100644
浏览文件 @
4f31163a
<?xml version="1.0" encoding="UTF-8"?>
<model>
<entity
name=
"third-party-config"
root=
"true"
>
<entity-ref
name=
"http"
type=
"list"
names=
"https"
/>
<entity-ref
name=
"socket"
type=
"list"
names=
"sockets"
/>
</entity>
<entity
name=
"http"
>
<attribute
name=
"url"
value-type=
"String"
/>
<attribute
name=
"type"
value-type=
"String"
/>
<attribute
name=
"pars"
value-type=
"String"
/>
<entity-ref
name=
"domain"
type=
"list"
names=
"domains"
/>
</entity>
<entity
name=
"domain"
>
<attribute
name=
"id"
value-type=
"String"
/>
</entity>
<entity
name=
"socket"
>
<attribute
name=
"ip"
value-type=
"String"
/>
<attribute
name=
"port"
value-type=
"int"
/>
<entity-ref
name=
"domain"
type=
"list"
names=
"domains"
/>
</entity>
</model>
cat-home/src/main/resources/META-INF/dal/model/thirdParty-manifest.xml
0 → 100644
浏览文件 @
4f31163a
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<file
path=
"thirdParty-codegen.xml"
/>
<file
path=
"thirdParty-model.xml"
/>
</manifest>
cat-home/src/main/resources/META-INF/dal/model/thirdParty-model.xml
0 → 100644
浏览文件 @
4f31163a
<?xml version="1.0" encoding="UTF-8"?>
<model
model-package=
"com.dianping.cat.home.alert.thirdParty"
enable-merger=
"false"
enable-sax-parser=
"true"
enable-base-visitor=
"false"
>
<entity
name=
"third-party-config"
root=
"true"
>
<entity-ref
name=
"http"
type=
"list"
names=
"https"
/>
<entity-ref
name=
"socket"
type=
"list"
names=
"sockets"
/>
</entity>
<entity
name=
"http"
>
<attribute
name=
"url"
value-type=
"String"
/>
<attribute
name=
"type"
value-type=
"String"
default-value=
"get"
/>
<attribute
name=
"pars"
value-type=
"String"
/>
<entity-ref
name=
"domain"
type=
"list"
names=
"domains"
/>
</entity>
<entity
name=
"domain"
>
<attribute
name=
"id"
value-type=
"String"
/>
</entity>
<entity
name=
"socket"
>
<attribute
name=
"ip"
value-type=
"String"
/>
<attribute
name=
"port"
value-type=
"int"
/>
<entity-ref
name=
"domain"
type=
"list"
names=
"domains"
/>
</entity>
</model>
cat-home/src/main/resources/META-INF/plexus/components.xml
浏览文件 @
4f31163a
...
...
@@ -193,6 +193,15 @@
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.system.config.ThirdPartyConfigManager
</role>
<implementation>
com.dianping.cat.system.config.ThirdPartyConfigManager
</implementation>
<requirements>
<requirement>
<role>
com.dianping.cat.core.config.ConfigDao
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.system.config.ConfigReloadTask
</role>
<implementation>
com.dianping.cat.system.config.ConfigReloadTask
</implementation>
...
...
@@ -4170,6 +4179,9 @@
<requirement>
<role>
com.dianping.cat.system.config.AlertTypeManager
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.system.config.ThirdPartyConfigManager
</role>
</requirement>
</requirements>
</component>
<component>
...
...
@@ -4247,6 +4259,15 @@
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.system.config.ThirdPartyConfigManager
</role>
<implementation>
com.dianping.cat.system.config.ThirdPartyConfigManager
</implementation>
<requirements>
<requirement>
<role>
com.dianping.cat.core.config.ConfigDao
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.system.page.plugin.Handler
</role>
<implementation>
com.dianping.cat.system.page.plugin.Handler
</implementation>
...
...
@@ -4506,6 +4527,37 @@
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.report.task.alert.thirdParty.ThirdPartyAlert
</role>
<implementation>
com.dianping.cat.report.task.alert.thirdParty.ThirdPartyAlert
</implementation>
<requirements>
<requirement>
<role>
com.dianping.cat.core.dal.ProjectDao
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.report.task.alert.sender.MailSender
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.report.task.alert.thirdParty.HttpMonitor
</role>
<implementation>
com.dianping.cat.report.task.alert.thirdParty.HttpMonitor
</implementation>
</component>
<component>
<role>
com.dianping.cat.report.task.alert.thirdParty.ThirdPartyAlertTask
</role>
<implementation>
com.dianping.cat.report.task.alert.thirdParty.ThirdPartyAlertTask
</implementation>
<requirements>
<requirement>
<role>
com.dianping.cat.report.task.alert.thirdParty.HttpMonitor
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.report.task.alert.thirdParty.ThirdPartyAlert
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.system.config.ThirdPartyConfigManager
</role>
</requirement>
</requirements>
</component>
<component>
<role>
org.unidal.initialization.Module
</role>
<role-hint>
cat-home
</role-hint>
...
...
@@ -7936,6 +7988,9 @@
<requirement>
<role>
com.dianping.cat.system.config.AlertTypeManager
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.system.config.ThirdPartyConfigManager
</role>
</requirement>
</requirements>
</component>
<component>
...
...
@@ -8013,6 +8068,15 @@
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.system.config.ThirdPartyConfigManager
</role>
<implementation>
com.dianping.cat.system.config.ThirdPartyConfigManager
</implementation>
<requirements>
<requirement>
<role>
com.dianping.cat.core.config.ConfigDao
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.system.page.plugin.Handler
</role>
<implementation>
com.dianping.cat.system.page.plugin.Handler
</implementation>
...
...
cat-home/src/main/resources/META-INF/wizard/model/wizard.xml
浏览文件 @
4f31163a
...
...
@@ -55,6 +55,9 @@
<sample-model>
/Users/leon/Desktop/AlertSummary.xml
</sample-model>
</model>
<model
package=
"com.dianping.cat.home.alert.type"
name=
"alert-type"
>
<sample-model>
/Users/leon/Documents/GitRepo/cat/cat-home/src/test/resources/config/alert-type.xml
</sample-model>
<sample-model>
src/test/resources/config/alert-type.xml
</sample-model>
</model>
<model
package=
"com.dianping.cat.home.alert.thirdParty"
name=
"thirdParty"
>
<sample-model>
src/test/resources/config/thirdParty-config.xml
</sample-model>
</model>
</wizard>
cat-home/src/main/resources/config/default-thirdParty-config.xml
0 → 100644
浏览文件 @
4f31163a
<third-party-config>
<http
url=
"http://www.51ping.com:8080"
type=
"get"
/>
<http
url=
"http://www.51ping.com:8080"
type=
"post"
/>
<socket
ip=
"10.10.10.1"
port=
"80"
/>
<socket
ip=
"10.10.10.1"
port=
"80"
/>
<socket
ip=
"10.10.10.1"
port=
"80"
/>
</third-party-config>
\ No newline at end of file
cat-home/src/main/webapp/WEB-INF/tags/body.tag
浏览文件 @
4f31163a
...
...
@@ -49,7 +49,7 @@
<li><a
style=
"padding:3px 30px"
href=
"/cat/r/network?domain=${model.domain}&ip=${model.ipAddress}&date=${model.date}&reportType=${payload.reportType}&op=${payload.action.name}"
>
network
</a></li>
<li><a
style=
"padding:3px 30px"
href=
"/cat/r/cdn?domain=${model.domain}&ip=${model.ipAddress}&date=${model.date}&reportType=${payload.reportType}&op=${payload.action.name}"
>
cdn
</a></li>
<li><a
style=
"padding:3px 30px"
href=
"/cat/r/system?domain=${model.domain}&ip=${model.ipAddress}&date=${model.date}&reportType=${payload.reportType}&op=${payload.action.name}"
>
system
</a></li>
<li><a
style=
"padding:3px 30px"
href=
"/cat/r/
change
?domain=${model.domain}&ip=${model.ipAddress}&date=${model.date}&reportType=${payload.reportType}&op=${payload.action.name}"
>
change
</a></li>
<li><a
style=
"padding:3px 30px"
href=
"/cat/r/
alteration
?domain=${model.domain}&ip=${model.ipAddress}&date=${model.date}&reportType=${payload.reportType}&op=${payload.action.name}"
>
change
</a></li>
<li><a
style=
"padding:3px 30px"
href=
"/cat/r/statistics?domain=${model.domain}&ip=${model.ipAddress}&date=${model.date}&reportType=${payload.reportType}&op=${payload.action.name}"
>
statistics
</a></li>
<li
class=
"nav-header"
>
System
</li>
<li><a
style=
"padding:3px 30px"
href=
"/cat/s/alarm?domain=${model.domain}&ip=${model.ipAddress}&date=${model.date}&reportType=${payload.reportType}&op=${payload.action.name}"
>
alarm
</a></li>
...
...
cat-home/src/main/webapp/jsp/system/configTree.jsp
浏览文件 @
4f31163a
...
...
@@ -12,6 +12,7 @@
<li
class=
"text-right"
id=
"urlPatternList"
><a
href=
"?op=urlPatterns"
><strong>
URL合并规则
</strong></a></li>
<li
class=
"text-right"
id=
"aggregationList"
><a
href=
"?op=aggregations"
><strong>
JS合并规则
</strong></a></li>
<li
class=
"text-right"
id=
"appConfigUpdate"
><a
href=
"?op=appConfigUpdate"
><strong>
APP监控配置
</strong></a></li>
<li
class=
"text-right"
id=
"thirdPartyConfigUpdate"
><a
href=
"?op=thirdPartyConfigUpdate"
><strong>
第三方监控配置
</strong></a></li>
<li
class=
'nav-header'
><h4>
业务监控配置
</h4></li>
<li
class=
"text-right"
id=
"metricConfigList"
><a
href=
"?op=metricConfigList"
><strong>
业务监控规则
</strong></a></li>
<li
class=
"text-right"
id=
"metricGroupConfigUpdate"
><a
href=
"?op=metricGroupConfigUpdate"
><strong>
业务指标分组
</strong></a></li>
...
...
cat-home/src/main/webapp/jsp/system/thirdParty/thirdPartyConfig.jsp
0 → 100644
浏览文件 @
4f31163a
<%@ 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=
"thirdPartyConfigUpdate"
id=
"form"
method=
"post"
action=
"${model.pageUri}?op=thirdPartyConfigUpdate"
>
<h4
class=
"text-center text-error"
id=
"state"
>
</h4>
<h4
class=
"text-center text-error"
>
第三方监控配置
</h4>
<table
class=
"table table-striped table-bordered table-condensed table-hover"
>
<tr>
<td><textarea
name=
"content"
style=
"width:auto"
rows=
"20"
cols=
"150"
>
${model.content}
</textarea></td>
</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
()
{
$
(
'
#thirdPartyConfigUpdate
'
).
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/test/resources/config/thirdParty-config.xml
0 → 100644
浏览文件 @
4f31163a
<third-party-config>
<http
url=
"http://www.51ping.com:8080"
type=
"get"
pars=
"name=name;sex=male"
>
<domain
id=
"cat1"
/>
<domain
id=
"cat2"
/>
</http>
<http
url=
"http://www.51ping.com:8080"
type=
"post"
pars=
"name=abc;sex=male"
/>
<socket
ip=
"10.10.10.1"
port=
"80"
>
<domain
id=
"cat1"
/>
<domain
id=
"cat2"
/>
</socket>
<socket
ip=
"10.10.10.1"
port=
"80"
/>
<socket
ip=
"10.10.10.1"
port=
"80"
/>
</third-party-config>
\ No newline at end of file
script/Cat.sql
浏览文件 @
4f31163a
...
...
@@ -346,6 +346,7 @@ CREATE TABLE `app_data_command_1` (
`status`
smallint
NOT
NULL
COMMENT
'数据状态'
,
`creation_date`
datetime
NOT
NULL
COMMENT
'数据插入时间'
,
PRIMARY
KEY
(
`id`
),
KEY
IX_period_minute
(
period
,
minute_order
),
KEY
IX_period_city_minute
(
period
,
city
,
minute_order
),
KEY
IX_period_operator_minute
(
period
,
operator
,
minute_order
),
KEY
IX_period_network_minute
(
period
,
network
,
minute_order
),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录