Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
756dcc38
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,发现更多精彩内容 >>
提交
756dcc38
编写于
6月 10, 2014
作者:
J
jialinsun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修复exception alert bug,重构代码。忽略Agent部分修改
上级
bfad1677
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
172 addition
and
75 deletion
+172
-75
cat-agent/src/main/java/com/dianping/cat/agent/AbstractTask.java
...nt/src/main/java/com/dianping/cat/agent/AbstractTask.java
+1
-1
cat-agent/src/main/java/com/dianping/cat/agent/Agent.java
cat-agent/src/main/java/com/dianping/cat/agent/Agent.java
+6
-3
cat-agent/src/main/java/com/dianping/cat/agent/Configuration.java
...t/src/main/java/com/dianping/cat/agent/Configuration.java
+1
-1
cat-agent/src/main/java/com/dianping/cat/agent/NetworkInterfaceManager.java
.../java/com/dianping/cat/agent/NetworkInterfaceManager.java
+1
-1
cat-agent/src/main/java/com/dianping/cat/agent/StateTask.java
...agent/src/main/java/com/dianping/cat/agent/StateTask.java
+1
-1
cat-agent/src/main/java/com/dianping/cat/agent/jvm/jvmTask.java
...ent/src/main/java/com/dianping/cat/agent/jvm/jvmTask.java
+6
-3
cat-agent/src/main/java/com/dianping/cat/agent/nginx/nginxTask.java
...src/main/java/com/dianping/cat/agent/nginx/nginxTask.java
+13
-0
cat-agent/src/main/java/com/dianping/cat/agent/system/PerformanceTask.java
...n/java/com/dianping/cat/agent/system/PerformanceTask.java
+3
-0
cat-home/src/main/java/com/dianping/cat/report/page/network/nettopology/NetGraphBuilder.java
.../cat/report/page/network/nettopology/NetGraphBuilder.java
+0
-1
cat-home/src/main/java/com/dianping/cat/report/page/network/nettopology/NetGraphManager.java
.../cat/report/page/network/nettopology/NetGraphManager.java
+0
-2
cat-home/src/main/java/com/dianping/cat/report/page/system/Payload.java
...ain/java/com/dianping/cat/report/page/system/Payload.java
+1
-1
cat-home/src/main/java/com/dianping/cat/report/page/top/TopMetric.java
...main/java/com/dianping/cat/report/page/top/TopMetric.java
+6
-0
cat-home/src/main/java/com/dianping/cat/report/task/alert/exception/ExceptionAlert.java
...nping/cat/report/task/alert/exception/ExceptionAlert.java
+85
-55
cat-home/src/main/java/com/dianping/cat/system/config/ExceptionConfigManager.java
...om/dianping/cat/system/config/ExceptionConfigManager.java
+18
-5
cat-home/src/main/java/com/dianping/cat/system/page/config/Handler.java
...ain/java/com/dianping/cat/system/page/config/Handler.java
+0
-1
cat-home/src/main/webapp/jsp/report/metric/metric.jsp
cat-home/src/main/webapp/jsp/report/metric/metric.jsp
+2
-0
cat-home/src/main/webapp/jsp/report/network/metric.jsp
cat-home/src/main/webapp/jsp/report/network/metric.jsp
+7
-0
cat-home/src/main/webapp/jsp/report/network/nettopology.jsp
cat-home/src/main/webapp/jsp/report/network/nettopology.jsp
+21
-0
未找到文件。
cat-agent/src/main/java/com/dianping/cat/agent/
system/
AbstractTask.java
→
cat-agent/src/main/java/com/dianping/cat/agent/AbstractTask.java
浏览文件 @
756dcc38
package
com.dianping.cat.agent
.system
;
package
com.dianping.cat.agent
;
import
java.io.BufferedReader
;
import
java.io.InputStreamReader
;
...
...
cat-agent/src/main/java/com/dianping/cat/agent/
system/System
Agent.java
→
cat-agent/src/main/java/com/dianping/cat/agent/Agent.java
浏览文件 @
756dcc38
package
com.dianping.cat.agent
.system
;
package
com.dianping.cat.agent
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
public
class
SystemAgent
{
import
com.dianping.cat.agent.jvm.jvmTask
;
import
com.dianping.cat.agent.system.PerformanceTask
;
public
class
Agent
{
public
static
final
int
THREAD_NUM
=
3
;
...
...
@@ -17,7 +20,7 @@ public class SystemAgent {
executorService
.
execute
(
new
PerformanceTask
(
config
));
executorService
.
execute
(
new
StateTask
(
config
));
executorService
.
execute
(
new
JVM
Task
(
config
));
executorService
.
execute
(
new
jvm
Task
(
config
));
executorService
.
shutdown
();
}
}
cat-agent/src/main/java/com/dianping/cat/agent/
system/
Configuration.java
→
cat-agent/src/main/java/com/dianping/cat/agent/Configuration.java
浏览文件 @
756dcc38
package
com.dianping.cat.agent
.system
;
package
com.dianping.cat.agent
;
import
java.io.BufferedInputStream
;
import
java.io.FileInputStream
;
...
...
cat-agent/src/main/java/com/dianping/cat/agent/
system/
NetworkInterfaceManager.java
→
cat-agent/src/main/java/com/dianping/cat/agent/NetworkInterfaceManager.java
浏览文件 @
756dcc38
package
com.dianping.cat.agent
.system
;
package
com.dianping.cat.agent
;
import
java.net.Inet4Address
;
import
java.net.InetAddress
;
...
...
cat-agent/src/main/java/com/dianping/cat/agent/
system/
StateTask.java
→
cat-agent/src/main/java/com/dianping/cat/agent/StateTask.java
浏览文件 @
756dcc38
package
com.dianping.cat.agent
.system
;
package
com.dianping.cat.agent
;
import
java.io.BufferedReader
;
import
java.io.File
;
...
...
cat-agent/src/main/java/com/dianping/cat/agent/
system/JVM
Task.java
→
cat-agent/src/main/java/com/dianping/cat/agent/
jvm/jvm
Task.java
浏览文件 @
756dcc38
package
com.dianping.cat.agent.
syste
m
;
package
com.dianping.cat.agent.
jv
m
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
public
class
JVMTask
extends
AbstractTask
{
import
com.dianping.cat.agent.AbstractTask
;
import
com.dianping.cat.agent.Configuration
;
public
JVMTask
(
Configuration
config
)
{
public
class
jvmTask
extends
AbstractTask
{
public
jvmTask
(
Configuration
config
)
{
super
(
config
);
m_domain
=
config
.
getJvmDomain
();
}
...
...
cat-agent/src/main/java/com/dianping/cat/agent/nginx/nginxTask.java
0 → 100644
浏览文件 @
756dcc38
package
com.dianping.cat.agent.nginx
;
import
com.dianping.cat.agent.AbstractTask
;
import
com.dianping.cat.agent.Configuration
;
public
class
nginxTask
extends
AbstractTask
{
public
nginxTask
(
Configuration
config
)
{
super
(
config
);
// TODO Auto-generated constructor stub
}
}
cat-agent/src/main/java/com/dianping/cat/agent/system/PerformanceTask.java
浏览文件 @
756dcc38
...
...
@@ -8,6 +8,9 @@ import org.hyperic.sigar.Sigar;
import
org.hyperic.sigar.SigarException
;
import
org.hyperic.sigar.Swap
;
import
com.dianping.cat.agent.AbstractTask
;
import
com.dianping.cat.agent.Configuration
;
public
class
PerformanceTask
extends
AbstractTask
{
private
Sigar
m_sigar
;
...
...
cat-home/src/main/java/com/dianping/cat/report/page/network/nettopology/NetGraphBuilder.java
浏览文件 @
756dcc38
...
...
@@ -11,7 +11,6 @@ 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.report.task.alert.AlertInfo
;
import
com.dianping.cat.consumer.metric.model.entity.MetricItem
;
import
com.dianping.cat.consumer.metric.model.entity.MetricReport
;
import
com.dianping.cat.home.nettopo.entity.Anchor
;
...
...
cat-home/src/main/java/com/dianping/cat/report/page/network/nettopology/NetGraphManager.java
浏览文件 @
756dcc38
...
...
@@ -20,8 +20,6 @@ import org.unidal.tuple.Pair;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.Constants
;
import
com.dianping.cat.ServerConfigManager
;
import
com.dianping.cat.advanced.metric.config.entity.MetricItemConfig
;
import
com.dianping.cat.consumer.metric.MetricConfigManager
;
import
com.dianping.cat.consumer.metric.model.entity.MetricReport
;
import
com.dianping.cat.helper.TimeUtil
;
import
com.dianping.cat.home.nettopo.entity.NetGraph
;
...
...
cat-home/src/main/java/com/dianping/cat/report/page/system/Payload.java
浏览文件 @
756dcc38
...
...
@@ -20,7 +20,7 @@ public class Payload extends AbstractReportPayload<Action> {
private
String
m_domain
=
"Cat"
;
@FieldMeta
(
"productLine"
)
private
String
m_productLine
;
private
String
m_productLine
=
"中间件"
;
@FieldMeta
(
"type"
)
private
String
m_type
=
"system"
;
...
...
cat-home/src/main/java/com/dianping/cat/report/page/top/TopMetric.java
浏览文件 @
756dcc38
...
...
@@ -162,6 +162,12 @@ public class TopMetric extends BaseVisitor {
private
double
m_value
;
@Override
public
String
toString
()
{
return
"Item [m_domain="
+
m_domain
+
", m_value="
+
m_value
+
", m_alert="
+
m_alert
+
", m_configManager="
+
m_configManager
+
", m_exceptions="
+
m_exceptions
+
"]"
;
}
private
int
m_alert
;
private
ExceptionConfigManager
m_configManager
;
...
...
cat-home/src/main/java/com/dianping/cat/report/task/alert/exception/ExceptionAlert.java
浏览文件 @
756dcc38
...
...
@@ -14,6 +14,7 @@ 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
org.unidal.tuple.Pair
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.Constants
;
...
...
@@ -78,68 +79,96 @@ public class ExceptionAlert implements Task, LogEnabled {
m_logger
=
logger
;
}
private
List
<
AlertException
>
findOrCreateDomain
(
Map
<
String
,
List
<
AlertException
>>
exceptions
,
String
domain
)
{
if
(
exceptions
.
get
(
domain
)
==
null
)
{
List
<
AlertException
>
exception
=
new
ArrayList
<
AlertException
>();
private
Pair
<
Double
,
Double
>
queryDomainTotalLimit
(
String
domain
)
{
ExceptionLimit
totalExceptionLimit
=
m_exceptionConfigManager
.
queryDomainTotalLimit
(
domain
);
Pair
<
Double
,
Double
>
limits
=
new
Pair
<
Double
,
Double
>();
double
totalWarnLimit
=
-
1
;
double
totalErrorLimit
=
-
1
;
exceptions
.
put
(
domain
,
exception
);
return
exception
;
if
(
totalExceptionLimit
!=
null
)
{
totalWarnLimit
=
totalExceptionLimit
.
getWarning
();
totalErrorLimit
=
totalExceptionLimit
.
getError
();
}
return
exceptions
.
get
(
domain
);
limits
.
setKey
(
totalWarnLimit
);
limits
.
setValue
(
totalErrorLimit
);
return
limits
;
}
private
Map
<
String
,
List
<
AlertException
>>
getAlertExceptions
(
Collection
<
List
<
Item
>>
items
)
{
Map
<
String
,
List
<
AlertException
>>
alertExceptions
=
new
LinkedHashMap
<
String
,
List
<
AlertException
>>();
for
(
List
<
Item
>
item
:
items
)
{
for
(
Item
i
:
item
)
{
String
domain
=
i
.
getDomain
();
ExceptionLimit
totalExceptionLimit
=
m_exceptionConfigManager
.
queryDomainTotalLimit
(
domain
);
int
totalWarnLimit
=
-
1
;
int
totalErrorLimit
=
-
1
;
int
totalException
=
0
;
if
(
totalExceptionLimit
!=
null
)
{
totalWarnLimit
=
totalExceptionLimit
.
getWarning
();
totalErrorLimit
=
totalExceptionLimit
.
getError
();
}
private
Pair
<
Double
,
Double
>
queryDomainExceptionLimit
(
String
domain
,
String
exceptionName
)
{
ExceptionLimit
exceptionLimit
=
m_exceptionConfigManager
.
queryDomainExceptionLimit
(
domain
,
exceptionName
);
Pair
<
Double
,
Double
>
limits
=
new
Pair
<
Double
,
Double
>();
double
warnLimit
=
-
1
;
double
errorLimit
=
-
1
;
for
(
Entry
<
String
,
Double
>
entry
:
i
.
getException
().
entrySet
())
{
String
exceptionName
=
entry
.
getKey
();
ExceptionExclude
result
=
m_exceptionConfigManager
.
queryDomainExceptionExclude
(
domain
,
exceptionName
);
if
(
exceptionLimit
!=
null
)
{
warnLimit
=
exceptionLimit
.
getWarning
();
errorLimit
=
exceptionLimit
.
getError
();
}
limits
.
setKey
(
warnLimit
);
limits
.
setValue
(
errorLimit
);
if
(
result
!=
null
)
{
continue
;
}
return
limits
;
}
double
value
=
entry
.
getValue
().
doubleValue
();
double
warnLimit
=
-
1
;
double
errorLimit
=
-
1
;
ExceptionLimit
exceptionLimit
=
m_exceptionConfigManager
.
queryDomainExceptionLimit
(
domain
,
exceptionName
);
totalException
+=
entry
.
getValue
();
if
(
exceptionLimit
!=
null
)
{
warnLimit
=
exceptionLimit
.
getWarning
();
errorLimit
=
exceptionLimit
.
getError
();
if
(
errorLimit
>
0
&&
value
>
errorLimit
)
{
findOrCreateDomain
(
alertExceptions
,
domain
).
add
(
new
AlertException
(
exceptionName
,
ERROR_FLAG
,
value
));
}
else
if
(
warnLimit
>
0
&&
value
>
warnLimit
)
{
findOrCreateDomain
(
alertExceptions
,
domain
).
add
(
new
AlertException
(
exceptionName
,
WARN_FLAG
,
value
));
}
}
}
private
boolean
isExcludedException
(
String
domain
,
String
exceptionName
)
{
ExceptionExclude
result
=
m_exceptionConfigManager
.
queryDomainExceptionExclude
(
domain
,
exceptionName
);
if
(
totalErrorLimit
>
0
&&
totalException
>
totalErrorLimit
)
{
findOrCreateDomain
(
alertExceptions
,
domain
).
add
(
new
AlertException
(
TOTAL_EXCEPTION_NAME
,
ERROR_FLAG
,
totalException
));
}
else
if
(
totalWarnLimit
>
0
&&
totalException
>
totalWarnLimit
)
{
findOrCreateDomain
(
alertExceptions
,
domain
).
add
(
new
AlertException
(
TOTAL_EXCEPTION_NAME
,
WARN_FLAG
,
totalException
));
}
if
(
result
!=
null
)
{
return
true
;
}
else
{
return
false
;
}
}
private
List
<
AlertException
>
buildDomainAlertExceptionList
(
Item
item
)
{
String
domain
=
item
.
getDomain
();
List
<
AlertException
>
alertExceptions
=
new
ArrayList
<
AlertException
>();
Pair
<
Double
,
Double
>
totalLimitPair
=
queryDomainTotalLimit
(
domain
);
double
totalWarnLimit
=
totalLimitPair
.
getKey
();
double
totalErrorLimit
=
totalLimitPair
.
getValue
();
double
totalException
=
0
;
// different exception -> numbers
for
(
Entry
<
String
,
Double
>
entry
:
item
.
getException
().
entrySet
())
{
String
exceptionName
=
entry
.
getKey
();
if
(
isExcludedException
(
domain
,
exceptionName
))
{
continue
;
}
double
value
=
entry
.
getValue
().
doubleValue
();
Pair
<
Double
,
Double
>
limitPair
=
queryDomainExceptionLimit
(
domain
,
exceptionName
);
double
warnLimit
=
limitPair
.
getKey
();
double
errorLimit
=
limitPair
.
getValue
();
totalException
+=
value
;
if
(
errorLimit
>
0
&&
value
>
errorLimit
)
{
alertExceptions
.
add
(
new
AlertException
(
exceptionName
,
ERROR_FLAG
,
value
));
}
else
if
(
warnLimit
>
0
&&
value
>
warnLimit
)
{
alertExceptions
.
add
(
new
AlertException
(
exceptionName
,
WARN_FLAG
,
value
));
}
}
if
(
totalErrorLimit
>
0
&&
totalException
>
totalErrorLimit
)
{
alertExceptions
.
add
(
new
AlertException
(
TOTAL_EXCEPTION_NAME
,
ERROR_FLAG
,
totalException
));
}
else
if
(
totalWarnLimit
>
0
&&
totalException
>
totalWarnLimit
)
{
alertExceptions
.
add
(
new
AlertException
(
TOTAL_EXCEPTION_NAME
,
WARN_FLAG
,
totalException
));
}
return
alertExceptions
;
}
private
Map
<
String
,
List
<
AlertException
>>
buildAlertExceptions
(
List
<
Item
>
items
)
{
Map
<
String
,
List
<
AlertException
>>
alertExceptions
=
new
LinkedHashMap
<
String
,
List
<
AlertException
>>();
// different domain -> [excepitons:numbers]
for
(
Item
item
:
items
)
{
List
<
AlertException
>
domainAlertExceptions
=
buildDomainAlertExceptionList
(
item
);
if
(!
domainAlertExceptions
.
isEmpty
())
{
alertExceptions
.
put
(
item
.
getDomain
(),
domainAlertExceptions
);
}
}
return
alertExceptions
;
...
...
@@ -196,7 +225,8 @@ public class ExceptionAlert implements Task, LogEnabled {
try
{
TopMetric
topMetric
=
buildTopMetric
(
new
Date
(
current
-
TimeUtil
.
ONE_MINUTE
*
2
));
Collection
<
List
<
Item
>>
items
=
topMetric
.
getError
().
getResult
().
values
();
Map
<
String
,
List
<
AlertException
>>
alertExceptions
=
getAlertExceptions
(
items
);
List
<
Item
>
item
=
items
.
iterator
().
next
();
Map
<
String
,
List
<
AlertException
>>
alertExceptions
=
buildAlertExceptions
(
item
);
for
(
Entry
<
String
,
List
<
AlertException
>>
entry
:
alertExceptions
.
entrySet
())
{
try
{
...
...
cat-home/src/main/java/com/dianping/cat/system/config/ExceptionConfigManager.java
浏览文件 @
756dcc38
...
...
@@ -34,8 +34,6 @@ public class ExceptionConfigManager implements Initializable {
public
static
String
TOTAL_STRING
=
"Total"
;
public
static
String
ALL_STRING
=
"All"
;
public
boolean
deleteExceptionLimit
(
String
domain
,
String
exceptionName
)
{
DomainConfig
domainConfig
=
m_exceptionConfig
.
findOrCreateDomainConfig
(
domain
);
domainConfig
.
removeExceptionLimit
(
exceptionName
);
...
...
@@ -131,20 +129,35 @@ public class ExceptionConfigManager implements Initializable {
return
result
;
}
private
ExceptionExclude
queryDefaultExceptionExclude
(
String
exceptionName
)
{
DomainConfig
domainConfig
=
m_exceptionConfig
.
getDomainConfigs
().
get
(
DEFAULT_STRING
);
ExceptionExclude
result
=
null
;
if
(
domainConfig
!=
null
)
{
result
=
domainConfig
.
getExceptionExcludes
().
get
(
exceptionName
);
}
return
result
;
}
public
ExceptionExclude
queryDomainExceptionExclude
(
String
domain
,
String
exceptionName
)
{
DomainConfig
domainConfig
=
m_exceptionConfig
.
getDomainConfigs
().
get
(
domain
);
ExceptionExclude
result
=
null
;
// has no this domain config
if
(
domainConfig
==
null
)
{
domainConfig
=
m_exceptionConfig
.
getDomainConfigs
().
get
(
DEFAULT_STRING
);
result
=
queryDefaultExceptionExclude
(
exceptionName
);
}
if
(
domainConfig
!=
null
)
{
result
=
domainConfig
.
getExceptionExcludes
().
get
(
exceptionName
);
// domain config has no exclude for exception, check default exclude config
if
(
result
==
null
)
{
result
=
domainConfig
.
getExceptionExcludes
().
get
(
ALL_STRING
);
result
=
queryDefaultExceptionExclude
(
exceptionName
);
}
}
if
(
domain
.
equalsIgnoreCase
(
"PromoServer"
)
&&
result
==
null
)
{
System
.
out
.
println
(
m_exceptionConfig
.
getDomainConfigs
());
}
return
result
;
}
...
...
cat-home/src/main/java/com/dianping/cat/system/page/config/Handler.java
浏览文件 @
756dcc38
...
...
@@ -396,7 +396,6 @@ public class Handler implements PageHandler<Context> {
case
EXCEPTION_EXCLUDE_ADD:
List
<
String
>
exceptionExcludeList
=
queryExceptionList
();
exceptionExcludeList
.
add
(
ExceptionConfigManager
.
ALL_STRING
);
model
.
setExceptionList
(
exceptionExcludeList
);
model
.
setDomainList
(
queryDoaminList
());
break
;
...
...
cat-home/src/main/webapp/jsp/report/metric/metric.jsp
浏览文件 @
756dcc38
...
...
@@ -97,6 +97,8 @@
<div
id=
"${item.id}"
class=
"metricGraph"
></div>
</div>
</c:forEach>
</div>
</div>
</div>
</a:body>
</c:otherwise></c:choose>
...
...
cat-home/src/main/webapp/jsp/report/network/metric.jsp
浏览文件 @
756dcc38
...
...
@@ -95,6 +95,7 @@
</div>
</c:forEach>
</div>
</div>
</div>
</a:body>
</c:otherwise></c:choose>
...
...
@@ -131,6 +132,12 @@
}
</script>
<style
type=
"text/css"
>
.row-fluid
.span2
{
width
:
10%
;
}
.row-fluid
.span10
{
width
:
87%
;
}
.well
{
padding
:
10px
10px
10px
19
p
;
}
...
...
cat-home/src/main/webapp/jsp/report/network/nettopology.jsp
浏览文件 @
756dcc38
...
...
@@ -155,4 +155,25 @@ function showOpNav() {
</c:choose>
</script>
<style
type=
"text/css"
>
.row-fluid
.span2
{
width
:
10%
;
}
.row-fluid
.span10
{
width
:
87%
;
}
.well
{
padding
:
10px
10px
10px
19
p
;
}
.nav-list
li
a
{
padding
:
2px
15px
;
}
.nav
li
+
.nav-header
{
margin-top
:
2px
;
}
.nav-header
{
padding
:
5px
3px
;
}
</style>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录