Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
enoch
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DevOps
enoch
Commits
ff466845
Commit
ff466845
authored
Mar 27, 2019
by
Node- 门 忠鑫
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
# 修改输出格式
parent
188bc08b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
32 deletions
+13
-32
operator.go
service/alarm/operator.go
+8
-28
query_engine.go
service/alarm/query_engine.go
+5
-4
No files found.
service/alarm/operator.go
View file @
ff466845
package
alarm
package
alarm
import
(
import
(
"fmt"
"git.quantgroup.cn/DevOps/enoch/service/log"
"git.quantgroup.cn/DevOps/enoch/service/log"
"strconv"
"strconv"
"strings"
)
)
type
Compare
struct
{
type
Compare
struct
{
...
@@ -54,49 +54,29 @@ func parseToFloat(value string) float64 {
...
@@ -54,49 +54,29 @@ func parseToFloat(value string) float64 {
type
MsgBuilder
struct
{
type
MsgBuilder
struct
{
}
}
func
(
MsgBuilder
)
Less
(
alter
string
,
real
string
)
string
{
func
(
MsgBuilder
)
Less
(
alter
string
,
real
string
)
string
{
str
:=
strings
.
Builder
{}
return
fmt
.
Sprintf
(
" 当前值:%.3f, 低于阈值:%s"
,
parseToFloat
(
real
),
alter
)
str
.
WriteString
(
"的值为:"
)
str
.
WriteString
(
real
)
str
.
WriteString
(
"已经低于阈值:"
)
str
.
WriteString
(
alter
)
return
str
.
String
()
}
}
/**
/**
real > alter
real > alter
*/
*/
func
(
MsgBuilder
)
Greater
(
alter
string
,
real
string
)
string
{
func
(
MsgBuilder
)
Greater
(
alter
string
,
real
string
)
string
{
str
:=
strings
.
Builder
{}
return
fmt
.
Sprintf
(
" 当前值:%.3f, 高于阈值:%s"
,
parseToFloat
(
real
),
alter
)
str
.
WriteString
(
"的值为:"
)
str
.
WriteString
(
real
)
str
.
WriteString
(
"已经高于阈值:"
)
str
.
WriteString
(
alter
)
return
str
.
String
()
}
}
/**
/**
real = alter
real = alter
*/
*/
func
(
MsgBuilder
)
Equal
(
alter
string
,
real
string
)
string
{
func
(
MsgBuilder
)
Equal
(
alter
string
,
real
string
)
string
{
str
:=
strings
.
Builder
{}
return
fmt
.
Sprintf
(
" 当前值:%.3f, 等于阈值:%.3s"
,
parseToFloat
(
real
),
alter
)
str
.
WriteString
(
"的值为:"
)
str
.
WriteString
(
real
)
str
.
WriteString
(
"已经达到阈值:"
)
str
.
WriteString
(
alter
)
return
str
.
String
()
}
}
func
(
MsgBuilder
)
Between
(
floor
string
,
ceil
string
,
real
string
)
string
{
func
(
MsgBuilder
)
Between
(
floor
string
,
ceil
string
,
real
string
)
string
{
str
:=
strings
.
Builder
{}
return
fmt
.
Sprintf
(
" 当前值:%.3f, 介于于阈值:%s 和 %s 之间"
,
parseToFloat
(
real
),
ceil
,
floor
)
str
.
WriteString
(
"的值为:"
)
str
.
WriteString
(
real
)
str
.
WriteString
(
"已经介于阈值:"
)
str
.
WriteString
(
ceil
)
str
.
WriteString
(
"~"
)
str
.
WriteString
(
floor
)
str
.
WriteString
(
"之间"
)
return
str
.
String
()
}
}
/**
/**
...
...
service/alarm/query_engine.go
View file @
ff466845
...
@@ -29,7 +29,7 @@ func DealResult(res []client.Result, strategies []Strategy) {
...
@@ -29,7 +29,7 @@ func DealResult(res []client.Result, strategies []Strategy) {
for
_
,
series
:=
range
result
.
Series
{
for
_
,
series
:=
range
result
.
Series
{
uniqueTag
:=
series
.
Tags
[
tags
[
0
]]
uniqueTag
:=
series
.
Tags
[
tags
[
0
]]
tagValues
:=
getTagValues
(
tags
,
series
.
Tags
)
tagValues
:=
getTagValues
(
tags
,
series
.
Tags
)
if
needIgnore
(
ignoreTag
,
tags
)
{
if
needIgnore
(
ignoreTag
,
tag
Value
s
)
{
continue
continue
}
}
value
:=
series
.
Values
[
0
][
1
]
value
:=
series
.
Values
[
0
][
1
]
...
@@ -57,11 +57,11 @@ func DealResult(res []client.Result, strategies []Strategy) {
...
@@ -57,11 +57,11 @@ func DealResult(res []client.Result, strategies []Strategy) {
for
i
:=
0
;
i
<
strategy
.
SqlLen
;
i
++
{
for
i
:=
0
;
i
<
strategy
.
SqlLen
;
i
++
{
resIndex
+=
i
resIndex
+=
i
for
_
,
series
:=
range
res
[
resIndex
]
.
Series
{
for
_
,
series
:=
range
res
[
resIndex
]
.
Series
{
if
needIgnore
(
ignoreTag
,
tags
)
{
continue
}
uniqueTag
:=
series
.
Tags
[
tags
[
0
]]
uniqueTag
:=
series
.
Tags
[
tags
[
0
]]
tagValues
:=
getTagValues
(
tags
,
series
.
Tags
)
tagValues
:=
getTagValues
(
tags
,
series
.
Tags
)
if
needIgnore
(
ignoreTag
,
tagValues
)
{
continue
}
tagValueMap
[
uniqueTag
]
=
tagValues
tagValueMap
[
uniqueTag
]
=
tagValues
value
:=
series
.
Values
[
0
][
1
]
value
:=
series
.
Values
[
0
][
1
]
...
@@ -147,6 +147,7 @@ func hasNilValue(params []reflect.Value) bool {
...
@@ -147,6 +147,7 @@ func hasNilValue(params []reflect.Value) bool {
return
c
.
IsValid
()
return
c
.
IsValid
()
}
}
return
false
return
false
}
}
func
needIgnore
(
ignoreTag
map
[
string
]
bool
,
tags
[]
string
)
bool
{
func
needIgnore
(
ignoreTag
map
[
string
]
bool
,
tags
[]
string
)
bool
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment