Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jobily
Nightingale
提交
6c2c8f99
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,发现更多精彩内容 >>
提交
6c2c8f99
编写于
12月 07, 2021
作者:
U
Ulric Qin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add feishu support
上级
766bf9e4
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
52 addition
and
2 deletion
+52
-2
etc/script/notify.py
etc/script/notify.py
+41
-1
etc/template/feishu.tpl
etc/template/feishu.tpl
+6
-0
etc/webapi.conf
etc/webapi.conf
+5
-1
未找到文件。
etc/script/notify.py
浏览文件 @
6c2c8f99
...
...
@@ -11,7 +11,8 @@ notify_channel_funcs = {
"sms"
:
"sms"
,
"voice"
:
"voice"
,
"dingtalk"
:
"dingtalk"
,
"wecom"
:
"wecom"
"wecom"
:
"wecom"
,
"feishu"
:
"feishu"
}
mail_host
=
"smtp.163.com"
...
...
@@ -118,6 +119,45 @@ class Sender(object):
except
urllib2
.
HTTPError
,
error
:
print
(
error
)
@
classmethod
def
send_feishu
(
cls
,
payload
):
users
=
payload
.
get
(
'event'
).
get
(
"notify_users_obj"
)
tokens
=
{}
phones
=
{}
for
u
in
users
:
if
u
.
get
(
"phone"
):
phones
[
u
.
get
(
"phone"
)]
=
1
contacts
=
u
.
get
(
"contacts"
)
if
contacts
.
get
(
"feishu_robot_token"
,
""
):
tokens
[
contacts
.
get
(
"feishu_robot_token"
,
""
)]
=
1
opener
=
urllib2
.
build_opener
(
urllib2
.
HTTPHandler
())
method
=
"POST"
for
t
in
tokens
:
url
=
"https://open.feishu.cn/open-apis/bot/v2/hook/{}"
.
format
(
t
)
body
=
{
"msg_type"
:
"text"
,
"content"
:
{
"text"
:
payload
.
get
(
'tpls'
).
get
(
"feishu.tpl"
,
"feishu.tpl not found"
)
},
"at"
:
{
"atMobiles"
:
phones
.
keys
(),
"isAtAll"
:
False
}
}
request
=
urllib2
.
Request
(
url
,
data
=
json
.
dumps
(
body
))
request
.
add_header
(
"Content-Type"
,
'application/json;charset=utf-8'
)
request
.
get_method
=
lambda
:
method
try
:
connection
=
opener
.
open
(
request
)
print
(
connection
.
read
())
except
urllib2
.
HTTPError
,
error
:
print
(
error
)
@
classmethod
def
send_sms
(
cls
,
payload
):
users
=
payload
.
get
(
'event'
).
get
(
"notify_users_obj"
)
...
...
etc/template/feishu.tpl
0 → 100644
浏览文件 @
6c2c8f99
级别状态: S{{.Severity}} {
{
if
.
IsRecovered
}
}Recovered{
{
else
}
}Triggered{
{
end
}
}
规则名称: {{.RuleName}}{
{
if
.
RuleNote
}
}
规则备注: {{.RuleNote}}{
{
end
}
}
监控指标: {{.TagsJSON}}
触发时间: {
{
timeformat
.
TriggerTime
}
}
触发时值: {{.TriggerValue}}
\ No newline at end of file
etc/webapi.conf
浏览文件 @
6c2c8f99
...
...
@@ -8,7 +8,7 @@ RunMode = "release"
AdminRole
=
"Admin"
# Linkage with notify.py script
NotifyChannels
= [
"email"
,
"dingtalk"
,
"wecom"
]
NotifyChannels
= [
"email"
,
"dingtalk"
,
"wecom"
,
"feishu"
]
[[
ContactKeys
]]
Label
=
"Wecom Robot Token"
...
...
@@ -18,6 +18,10 @@ Key = "wecom_robot_token"
Label
=
"Dingtalk Robot Token"
Key
=
"dingtalk_robot_token"
[[
ContactKeys
]]
Label
=
"Feishu Robot Token"
Key
=
"feishu_robot_token"
[
Log
]
# log write dir
Dir
=
"logs"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录