Browse Source

noticer: 更详细的通知内容

结点失败通知加上通知人
pull/1/head
miraclesu 8 years ago
parent
commit
f816c3934c
  1. 17
      models/job.go
  2. 1
      models/noticer.go

17
models/job.go

@ -550,12 +550,14 @@ func (j *Job) Notify(t time.Time, msg string) {
ts := t.Format(time.RFC3339)
body := "job: " + j.Key() + "\n" +
"job name: " + j.Name + "\n" +
"job cmd: " + j.Command + "\n" +
"node: " + j.runOn + "\n" +
"time: " + ts + "\n" +
"err: " + msg
m := Message{
Subject: "node[" + j.runOn + "] job[" + j.ID + "] time[" + ts + "] exec failed",
Subject: "node[" + j.runOn + "] job[" + j.ShortName() + "] time[" + ts + "] exec failed",
Body: body,
To: j.To,
}
@ -683,3 +685,16 @@ func (j *Job) ValidRules() error {
}
return nil
}
func (j *Job) ShortName() string {
if len(j.Name) <= 10 {
return j.Name
}
names := []rune(j.Name)
if len(names) <= 10 {
return j.Name
}
return string(names[:10]) + "..."
}

1
models/noticer.go

@ -191,6 +191,7 @@ func monitorNodes(n Noticer) {
if ok {
n.Send(&Message{
Subject: "node[" + id + "] fault at time[" + time.Now().Format(time.RFC3339) + "]",
To: conf.Config.Mail.To,
})
}
}

Loading…
Cancel
Save