feat: 报警脚本超时时间改为可配置 (#1253)
* Update docker-compose.yaml * Update docker-compose.yaml * feat: 报警脚本超时时间改为可配置 * feat: docker 镜像Alerting 增加 超时时间 Co-authored-by: ulricqin <ulricqin@qq.com> Co-authored-by: JeffreyBool <zhanggaoyuan@mediatrack.cn>
This commit is contained in:
parent
352415662a
commit
8a145d5ba2
|
@ -75,6 +75,8 @@ InsecureSkipVerify = true
|
||||||
Batch = 5
|
Batch = 5
|
||||||
|
|
||||||
[Alerting]
|
[Alerting]
|
||||||
|
# timeout settings, unit: ms, default: 30000ms
|
||||||
|
Timeout=30000
|
||||||
TemplatesDir = "./etc/template"
|
TemplatesDir = "./etc/template"
|
||||||
NotifyConcurrency = 10
|
NotifyConcurrency = 10
|
||||||
# use builtin go code notify
|
# use builtin go code notify
|
||||||
|
|
|
@ -75,6 +75,8 @@ InsecureSkipVerify = true
|
||||||
Batch = 5
|
Batch = 5
|
||||||
|
|
||||||
[Alerting]
|
[Alerting]
|
||||||
|
# timeout settings, unit: ms, default: 30000ms
|
||||||
|
Timeout=30000
|
||||||
TemplatesDir = "./etc/template"
|
TemplatesDir = "./etc/template"
|
||||||
NotifyConcurrency = 10
|
NotifyConcurrency = 10
|
||||||
# use builtin go code notify
|
# use builtin go code notify
|
||||||
|
|
|
@ -312,6 +312,7 @@ type SMTPConfig struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Alerting struct {
|
type Alerting struct {
|
||||||
|
Timeout int64
|
||||||
TemplatesDir string
|
TemplatesDir string
|
||||||
NotifyConcurrency int
|
NotifyConcurrency int
|
||||||
NotifyBuiltinChannels []string
|
NotifyBuiltinChannels []string
|
||||||
|
|
|
@ -398,6 +398,10 @@ func alertingCallScript(stdinBytes []byte) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if config.C.Alerting.Timeout == 0 {
|
||||||
|
config.C.Alerting.Timeout = 30000
|
||||||
|
}
|
||||||
|
|
||||||
fpath := config.C.Alerting.CallScript.ScriptPath
|
fpath := config.C.Alerting.CallScript.ScriptPath
|
||||||
cmd := exec.Command(fpath)
|
cmd := exec.Command(fpath)
|
||||||
cmd.Stdin = bytes.NewReader(stdinBytes)
|
cmd.Stdin = bytes.NewReader(stdinBytes)
|
||||||
|
@ -413,7 +417,7 @@ func alertingCallScript(stdinBytes []byte) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err, isTimeout := sys.WrapTimeout(cmd, time.Duration(30)*time.Second)
|
err, isTimeout := sys.WrapTimeout(cmd, time.Duration(config.C.Alerting.Timeout)*time.Millisecond)
|
||||||
|
|
||||||
if isTimeout {
|
if isTimeout {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|
Loading…
Reference in New Issue