Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jobily
Nightingale
提交
5bd9c5fe
N
Nightingale
项目概览
jobily
/
Nightingale
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
Nightingale
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
5bd9c5fe
编写于
12月 08, 2020
作者:
qd_lm
提交者:
GitHub
12月 08, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
支持全局数据统计 1.rdb分类资源数量 2.告警数量 (#447)
上级
68bccb4d
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
77 addition
and
9 deletion
+77
-9
src/models/mon_event.go
src/models/mon_event.go
+16
-2
src/models/mon_event_cur.go
src/models/mon_event_cur.go
+16
-2
src/modules/monapi/http/router_event.go
src/modules/monapi/http/router_event.go
+2
-2
src/modules/rdb/http/router.go
src/modules/rdb/http/router.go
+2
-0
src/modules/rdb/http/router_resource.go
src/modules/rdb/http/router_resource.go
+41
-3
未找到文件。
src/models/mon_event.go
浏览文件 @
5bd9c5fe
...
...
@@ -102,7 +102,14 @@ func (e *Event) GetEventDetail() ([]EventDetail, error) {
}
func
EventTotal
(
stime
,
etime
int64
,
nodePath
,
query
,
eventType
string
,
priorities
,
sendTypes
[]
string
)
(
int64
,
error
)
{
session
:=
DB
[
"mon"
]
.
Where
(
"etime > ? and etime < ? and (node_path = ? or node_path like ?)"
,
stime
,
etime
,
nodePath
,
nodePath
+
".%"
)
sql
:=
"etime > ? and etime < ?"
sqlParamValue
:=
[]
interface
{}{
stime
,
etime
}
if
nodePath
!=
""
{
sql
+=
" and (node_path = ? or node_path like ?) "
sqlParamValue
=
[]
interface
{}{
stime
,
etime
,
nodePath
,
nodePath
+
".%"
}
}
session
:=
DB
[
"mon"
]
.
Where
(
sql
,
sqlParamValue
...
)
if
len
(
priorities
)
>
0
&&
priorities
[
0
]
!=
""
{
session
=
session
.
In
(
"priority"
,
priorities
)
}
...
...
@@ -134,7 +141,14 @@ func EventTotal(stime, etime int64, nodePath, query, eventType string, prioritie
func
EventGets
(
stime
,
etime
int64
,
nodePath
,
query
,
eventType
string
,
priorities
,
sendTypes
[]
string
,
limit
,
offset
int
)
([]
Event
,
error
)
{
var
objs
[]
Event
session
:=
DB
[
"mon"
]
.
Where
(
"etime > ? and etime < ? and (node_path = ? or node_path like ?)"
,
stime
,
etime
,
nodePath
,
nodePath
+
".%"
)
sql
:=
"etime > ? and etime < ?"
sqlParamValue
:=
[]
interface
{}{
stime
,
etime
}
if
nodePath
!=
""
{
sql
+=
" and (node_path = ? or node_path like ?) "
sqlParamValue
=
[]
interface
{}{
stime
,
etime
,
nodePath
,
nodePath
+
".%"
}
}
session
:=
DB
[
"mon"
]
.
Where
(
sql
,
sqlParamValue
...
)
if
len
(
priorities
)
>
0
&&
priorities
[
0
]
!=
""
{
session
=
session
.
In
(
"priority"
,
priorities
)
}
...
...
src/models/mon_event_cur.go
浏览文件 @
5bd9c5fe
...
...
@@ -163,7 +163,14 @@ func SaveEventCurStatus(hashid uint64, status string) error {
}
func
EventCurTotal
(
stime
,
etime
int64
,
nodePath
,
query
string
,
priorities
,
sendTypes
[]
string
)
(
int64
,
error
)
{
session
:=
DB
[
"mon"
]
.
Where
(
"etime > ? and etime < ? and (node_path = ? or node_path like ?) and ignore_alert=0"
,
stime
,
etime
,
nodePath
,
nodePath
+
".%"
)
sql
:=
"etime > ? and etime < ? and ignore_alert=0"
sqlParamValue
:=
[]
interface
{}{
stime
,
etime
}
if
nodePath
!=
""
{
sql
+=
" and (node_path = ? or node_path like ?) "
sqlParamValue
=
[]
interface
{}{
stime
,
etime
,
nodePath
,
nodePath
+
".%"
}
}
session
:=
DB
[
"mon"
]
.
Where
(
sql
,
sqlParamValue
...
)
if
len
(
priorities
)
>
0
&&
priorities
[
0
]
!=
""
{
session
=
session
.
In
(
"priority"
,
priorities
)
}
...
...
@@ -191,7 +198,14 @@ func EventCurTotal(stime, etime int64, nodePath, query string, priorities, sendT
func
EventCurGets
(
stime
,
etime
int64
,
nodePath
,
query
string
,
priorities
,
sendTypes
[]
string
,
limit
,
offset
int
)
([]
EventCur
,
error
)
{
var
obj
[]
EventCur
session
:=
DB
[
"mon"
]
.
Where
(
"etime > ? and etime < ? and (node_path = ? or node_path like ?) and ignore_alert=0"
,
stime
,
etime
,
nodePath
,
nodePath
+
".%"
)
sql
:=
"etime > ? and etime < ? and ignore_alert=0"
sqlParamValue
:=
[]
interface
{}{
stime
,
etime
}
if
nodePath
!=
""
{
sql
+=
" and (node_path = ? or node_path like ?) "
sqlParamValue
=
[]
interface
{}{
stime
,
etime
,
nodePath
,
nodePath
+
".%"
}
}
session
:=
DB
[
"mon"
]
.
Where
(
sql
,
sqlParamValue
...
)
if
len
(
priorities
)
>
0
&&
priorities
[
0
]
!=
""
{
session
=
session
.
In
(
"priority"
,
priorities
)
}
...
...
src/modules/monapi/http/router_event.go
浏览文件 @
5bd9c5fe
...
...
@@ -52,7 +52,7 @@ func eventCurGets(c *gin.Context) {
stime
:=
mustQueryInt64
(
c
,
"stime"
)
etime
:=
mustQueryInt64
(
c
,
"etime"
)
nodePath
:=
mustQueryStr
(
c
,
"nodepath
"
)
nodePath
:=
queryStr
(
c
,
"nodepath"
,
"
"
)
limit
:=
queryInt
(
c
,
"limit"
,
20
)
...
...
@@ -146,7 +146,7 @@ func eventHisGets(c *gin.Context) {
stime
:=
mustQueryInt64
(
c
,
"stime"
)
etime
:=
mustQueryInt64
(
c
,
"etime"
)
nodePath
:=
mustQueryStr
(
c
,
"nodepath
"
)
nodePath
:=
queryStr
(
c
,
"nodepath"
,
"
"
)
limit
:=
queryInt
(
c
,
"limit"
,
20
)
...
...
src/modules/rdb/http/router.go
浏览文件 @
5bd9c5fe
...
...
@@ -129,6 +129,8 @@ func Config(r *gin.Engine) {
userLogin
.
PUT
(
"/resources/note"
,
resourceNotePut
)
userLogin
.
GET
(
"/resources/bindings"
,
resourceBindingsGet
)
userLogin
.
GET
(
"/resources/orphan"
,
resourceOrphanGet
)
userLogin
.
GET
(
"/resources/cate-count"
,
renderAllResourcesCountByCate
)
}
v1
:=
r
.
Group
(
"/v1/rdb"
)
.
Use
(
shouldBeService
())
...
...
src/modules/rdb/http/router_resource.go
浏览文件 @
5bd9c5fe
...
...
@@ -5,6 +5,7 @@ import (
"strings"
"github.com/gin-gonic/gin"
"github.com/toolkits/pkg/logger"
"github.com/toolkits/pkg/slice"
"github.com/toolkits/pkg/str"
...
...
@@ -487,9 +488,9 @@ type nodeResourcesCountResp struct {
Count
int
`json:"count"`
}
func
renderNodeResourcesCountByCate
(
c
*
gin
.
Context
)
{
needSourceList
:=
[]
string
{
"physical"
,
"virtual"
,
"redis"
,
"mongo"
,
"mysql"
,
"container"
,
"sw"
,
"volume"
}
var
needSourceList
=
[]
string
{
"physical"
,
"virtual"
,
"redis"
,
"mongo"
,
"mysql"
,
"container"
,
"sw"
,
"volume"
}
func
renderNodeResourcesCountByCate
(
c
*
gin
.
Context
)
{
nodeId
:=
urlParamInt64
(
c
,
"id"
)
node
:=
Node
(
nodeId
)
leadIds
,
err
:=
node
.
LeafIds
()
...
...
@@ -503,7 +504,44 @@ func renderNodeResourcesCountByCate(c *gin.Context) {
ress
,
err
:=
models
.
ResourceUnderNodeGets
(
leadIds
,
query
,
batch
,
field
,
limit
,
0
)
dangerous
(
err
)
aggDat
:=
make
(
map
[
string
]
int
,
len
(
ress
))
aggDat
:=
make
(
map
[
string
]
int
,
len
(
needSourceList
))
for
_
,
res
:=
range
ress
{
cate
:=
res
.
Cate
if
cate
!=
""
{
if
_
,
ok
:=
aggDat
[
cate
];
!
ok
{
aggDat
[
cate
]
=
0
}
aggDat
[
cate
]
++
}
}
for
_
,
need
:=
range
needSourceList
{
if
_
,
ok
:=
aggDat
[
need
];
!
ok
{
aggDat
[
need
]
=
0
}
}
var
list
[]
*
nodeResourcesCountResp
for
n
,
c
:=
range
aggDat
{
ns
:=
new
(
nodeResourcesCountResp
)
ns
.
Name
=
n
ns
.
Count
=
c
list
=
append
(
list
,
ns
)
}
renderData
(
c
,
list
,
nil
)
}
func
renderAllResourcesCountByCate
(
c
*
gin
.
Context
)
{
aggDat
:=
make
(
map
[
string
]
int
,
len
(
needSourceList
))
ress
,
err
:=
models
.
ResourceGets
(
""
,
nil
)
if
err
!=
nil
{
logger
.
Error
(
err
)
dangerous
(
err
)
}
for
_
,
res
:=
range
ress
{
cate
:=
res
.
Cate
if
cate
!=
""
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录