Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DiDi
nightingale
提交
b00b7817
N
nightingale
项目概览
DiDi
/
nightingale
11 个月 前同步成功
通知
46
Star
7053
Fork
1161
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
nightingale
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
b00b7817
编写于
1月 15, 2021
作者:
Q
qinyening
提交者:
GitHub
1月 15, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support screen and alert template (#517)
上级
6b1e432f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
67 addition
and
1 deletion
+67
-1
src/modules/judge/judge.go
src/modules/judge/judge.go
+1
-1
src/modules/monapi/config/yaml.go
src/modules/monapi/config/yaml.go
+11
-0
src/modules/monapi/http/router.go
src/modules/monapi/http/router.go
+6
-0
src/modules/monapi/http/router_tpl.go
src/modules/monapi/http/router_tpl.go
+49
-0
未找到文件。
src/modules/judge/judge.go
浏览文件 @
b00b7817
...
@@ -117,7 +117,7 @@ func pconf() {
...
@@ -117,7 +117,7 @@ func pconf() {
func
start
()
{
func
start
()
{
runner
.
Init
()
runner
.
Init
()
fmt
.
Println
(
"
transfer
start, use configuration file:"
,
*
conf
)
fmt
.
Println
(
"
judge
start, use configuration file:"
,
*
conf
)
fmt
.
Println
(
"runner.Cwd:"
,
runner
.
Cwd
)
fmt
.
Println
(
"runner.Cwd:"
,
runner
.
Cwd
)
fmt
.
Println
(
"runner.Hostname:"
,
runner
.
Hostname
)
fmt
.
Println
(
"runner.Hostname:"
,
runner
.
Hostname
)
}
}
...
...
src/modules/monapi/config/yaml.go
浏览文件 @
b00b7817
...
@@ -29,6 +29,12 @@ type ConfYaml struct {
...
@@ -29,6 +29,12 @@ type ConfYaml struct {
Link
linkSection
`yaml:"link"`
Link
linkSection
`yaml:"link"`
IndexMod
string
`yaml:"indexMod"`
IndexMod
string
`yaml:"indexMod"`
I18n
i18n
.
I18nSection
`yaml:"i18n"`
I18n
i18n
.
I18nSection
`yaml:"i18n"`
Tpl
tplSection
`yaml:"tpl"`
}
type
tplSection
struct
{
AlertPath
string
`yaml:"alertPath"`
ScreenPath
string
`yaml:"screenPath"`
}
}
type
mergeSection
struct
{
type
mergeSection
struct
{
...
@@ -175,6 +181,11 @@ func Parse(ymlfile string) error {
...
@@ -175,6 +181,11 @@ func Parse(ymlfile string) error {
"converge"
:
true
,
// 历史告警的数据库表,对于已收敛的告警,默认删掉,不保留,省得告警太多
"converge"
:
true
,
// 历史告警的数据库表,对于已收敛的告警,默认删掉,不保留,省得告警太多
})
})
viper
.
SetDefault
(
"tpl"
,
map
[
string
]
string
{
"alertPath"
:
"./etc/alert"
,
"screenPath"
:
"./etc/screen"
,
})
err
=
viper
.
Unmarshal
(
&
yaml
)
err
=
viper
.
Unmarshal
(
&
yaml
)
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"Unmarshal %v"
,
err
)
return
fmt
.
Errorf
(
"Unmarshal %v"
,
err
)
...
...
src/modules/monapi/http/router.go
浏览文件 @
b00b7817
...
@@ -144,6 +144,12 @@ func Config(r *gin.Engine) {
...
@@ -144,6 +144,12 @@ func Config(r *gin.Engine) {
aggr
.
GET
(
"/:id"
,
aggrCalcGet
)
aggr
.
GET
(
"/:id"
,
aggrCalcGet
)
}
}
tpl
:=
r
.
Group
(
"/api/mon/tpl"
)
{
tpl
.
GET
(
""
,
tplNameGets
)
tpl
.
GET
(
"/content"
,
tplGet
)
}
aggrs
:=
r
.
Group
(
"/api/mon/aggrs"
)
.
Use
()
aggrs
:=
r
.
Group
(
"/api/mon/aggrs"
)
.
Use
()
{
{
aggrs
.
GET
(
""
,
aggrCalcsWithEndpointGet
)
aggrs
.
GET
(
""
,
aggrCalcsWithEndpointGet
)
...
...
src/modules/monapi/http/router_tpl.go
0 → 100644
浏览文件 @
b00b7817
package
http
import
(
"github.com/didi/nightingale/src/modules/monapi/config"
"github.com/gin-gonic/gin"
"github.com/toolkits/pkg/file"
)
func
tplNameGets
(
c
*
gin
.
Context
)
{
tplType
:=
mustQueryStr
(
c
,
"tplType"
)
var
files
[]
string
var
err
error
switch
tplType
{
case
"alert"
:
files
,
err
=
file
.
FilesUnder
(
config
.
Get
()
.
Tpl
.
AlertPath
)
dangerous
(
err
)
case
"screen"
:
files
,
err
=
file
.
FilesUnder
(
config
.
Get
()
.
Tpl
.
ScreenPath
)
dangerous
(
err
)
default
:
bomb
(
"tpl type not found"
)
}
renderData
(
c
,
files
,
err
)
}
func
tplGet
(
c
*
gin
.
Context
)
{
tplName
:=
mustQueryStr
(
c
,
"tplName"
)
tplType
:=
mustQueryStr
(
c
,
"tplType"
)
var
filePath
string
switch
tplType
{
case
"alert"
:
filePath
=
config
.
Get
()
.
Tpl
.
AlertPath
+
"/"
+
tplName
case
"screen"
:
filePath
=
config
.
Get
()
.
Tpl
.
ScreenPath
+
"/"
+
tplName
default
:
bomb
(
"tpl type not found"
)
}
if
!
file
.
IsExist
(
filePath
)
{
bomb
(
"tpl not found"
)
}
content
,
err
:=
file
.
ToString
(
filePath
)
renderData
(
c
,
content
,
err
)
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录