Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
153b640b
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,发现更多精彩内容 >>
提交
153b640b
编写于
6月 12, 2014
作者:
L
leon.li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add 2 new RuleType for fluctuate case
上级
af0544e0
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
107 addition
and
9 deletion
+107
-9
cat-home/src/main/java/com/dianping/cat/report/task/alert/RuleType.java
...ain/java/com/dianping/cat/report/task/alert/RuleType.java
+104
-2
cat-home/src/test/java/com/dianping/cat/report/alert/RuleConfigTest.java
...st/java/com/dianping/cat/report/alert/RuleConfigTest.java
+2
-2
cat-home/src/test/resources/config/demo-rule-monitor.xml
cat-home/src/test/resources/config/demo-rule-monitor.xml
+1
-5
未找到文件。
cat-home/src/main/java/com/dianping/cat/report/task/alert/RuleType.java
浏览文件 @
153b640b
...
...
@@ -191,7 +191,7 @@ public enum RuleType {
}
},
a
bsoluteMaxValue
{
A
bsoluteMaxValue
{
@Override
protected
String
buildRuleMessage
(
double
[]
values
,
double
[]
baselines
,
double
ruleValue
)
{
StringBuilder
sb
=
new
StringBuilder
();
...
...
@@ -223,7 +223,7 @@ public enum RuleType {
}
},
a
bsoluteMinValue
{
A
bsoluteMinValue
{
@Override
protected
String
buildRuleMessage
(
double
[]
values
,
double
[]
baselines
,
double
ruleValue
)
{
StringBuilder
sb
=
new
StringBuilder
();
...
...
@@ -253,6 +253,108 @@ public enum RuleType {
public
String
getId
()
{
return
"MinVal"
;
}
},
FluctuateIncreasePercentage
{
private
double
[]
buildFlucAscPers
(
double
[]
values
)
{
int
length
=
values
.
length
;
double
[]
ascPers
=
new
double
[
length
-
1
];
double
baseVal
=
values
[
length
-
1
];
for
(
int
i
=
0
;
i
<=
length
-
2
;
i
++)
{
ascPers
[
i
]
=
(
baseVal
/
values
[
i
]
-
1
)
*
100
;
}
return
ascPers
;
}
@Override
protected
String
buildRuleMessage
(
double
[]
values
,
double
[]
baselines
,
double
ruleValue
)
{
StringBuilder
sb
=
new
StringBuilder
();
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
sb
.
append
(
"[实际值:"
).
append
(
convertDoublesToString
(
values
)).
append
(
"] "
);
sb
.
append
(
"[波动上升百分比:"
).
append
(
convertPercentsToString
(
buildFlucAscPers
(
values
))).
append
(
"] "
);
sb
.
append
(
"[波动上升百分比阈值: "
+
m_df
.
format
(
ruleValue
)
+
"% ]"
);
sb
.
append
(
"[告警时间:"
).
append
(
sdf
.
format
(
new
Date
())
+
"]"
);
return
sb
.
toString
();
}
@Override
public
Pair
<
Boolean
,
String
>
executeRule
(
double
[]
values
,
double
[]
baselines
,
double
ruleValue
)
{
int
length
=
values
.
length
;
if
(
length
<=
1
)
{
return
new
Pair
<
Boolean
,
String
>(
false
,
""
);
}
double
baseVal
=
values
[
length
-
1
];
for
(
int
i
=
0
;
i
<=
length
-
2
;
i
++)
{
if
(
baseVal
/
values
[
i
]
-
1
<
ruleValue
/
100
)
{
return
new
Pair
<
Boolean
,
String
>(
false
,
""
);
}
}
return
new
Pair
<
Boolean
,
String
>(
true
,
buildRuleMessage
(
values
,
baselines
,
ruleValue
));
}
@Override
public
String
getId
()
{
return
"FluAscPer"
;
}
},
FluctuateDecreasePercentage
{
private
double
[]
buildFlucDescPers
(
double
[]
values
)
{
int
length
=
values
.
length
;
double
[]
descPers
=
new
double
[
length
-
1
];
double
baseVal
=
values
[
length
-
1
];
for
(
int
i
=
0
;
i
<=
length
-
2
;
i
++)
{
descPers
[
i
]
=
(
1
-
baseVal
/
values
[
i
])
*
100
;
}
return
descPers
;
}
@Override
protected
String
buildRuleMessage
(
double
[]
values
,
double
[]
baselines
,
double
ruleValue
)
{
StringBuilder
sb
=
new
StringBuilder
();
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
sb
.
append
(
"[实际值:"
).
append
(
convertDoublesToString
(
values
)).
append
(
"] "
);
sb
.
append
(
"[波动下降百分比:"
).
append
(
convertPercentsToString
(
buildFlucDescPers
(
values
))).
append
(
"] "
);
sb
.
append
(
"[波动下降百分比阈值: "
+
m_df
.
format
(
ruleValue
)
+
"% ]"
);
sb
.
append
(
"[告警时间:"
).
append
(
sdf
.
format
(
new
Date
())
+
"]"
);
return
sb
.
toString
();
}
@Override
public
Pair
<
Boolean
,
String
>
executeRule
(
double
[]
values
,
double
[]
baselines
,
double
ruleValue
)
{
int
length
=
values
.
length
;
if
(
length
<=
1
)
{
return
new
Pair
<
Boolean
,
String
>(
false
,
""
);
}
double
baseVal
=
values
[
length
-
1
];
for
(
int
i
=
0
;
i
<=
length
-
2
;
i
++)
{
if
(
1
-
baseVal
/
values
[
i
]
<
ruleValue
/
100
)
{
return
new
Pair
<
Boolean
,
String
>(
false
,
""
);
}
}
return
new
Pair
<
Boolean
,
String
>(
true
,
buildRuleMessage
(
values
,
baselines
,
ruleValue
));
}
@Override
public
String
getId
()
{
return
"FluDescPer"
;
}
};
static
Map
<
String
,
RuleType
>
s_map
=
new
LinkedHashMap
<
String
,
RuleType
>();
...
...
cat-home/src/test/java/com/dianping/cat/report/alert/RuleConfigTest.java
浏览文件 @
153b640b
...
...
@@ -51,8 +51,8 @@ public class RuleConfigTest {
Assert
.
assertNotNull
(
configMap
);
double
baseline
[]
=
{
200
,
20
0
};
double
value
[]
=
{
100
,
10
0
};
double
baseline
[]
=
{
200
,
35
0
};
double
value
[]
=
{
100
,
5
0
};
Pair
<
Boolean
,
String
>
result
=
m_check
.
checkData
(
value
,
baseline
,
configMap
.
get
(
"demo1"
));
Assert
.
assertEquals
(
result
.
getKey
().
booleanValue
(),
true
);
}
...
...
cat-home/src/test/resources/config/demo-rule-monitor.xml
浏览文件 @
153b640b
...
...
@@ -9,11 +9,7 @@
<config
starttime=
"00:00"
endtime=
"24:00"
>
<condition>
<sub-condition
type=
"DescPer"
>
40
</sub-condition>
<sub-condition
type=
"DescPer"
>
40
</sub-condition>
</condition>
<condition>
<sub-condition
type=
"DescVal"
>
200
</sub-condition>
<sub-condition
type=
"FluDescPer"
>
50
</sub-condition>
</condition>
</config>
</rule>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录