本文整理汇总了Golang中bosun/org/models.IncidentState.EmailBody方法的典型用法代码示例。如果您正苦于以下问题:Golang IncidentState.EmailBody方法的具体用法?Golang IncidentState.EmailBody怎么用?Golang IncidentState.EmailBody使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bosun/org/models.IncidentState
的用法示例。
在下文中一共展示了IncidentState.EmailBody方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: notify
func (s *Schedule) notify(st *models.IncidentState, n *conf.Notification) {
if len(st.EmailSubject) == 0 {
st.EmailSubject = []byte(st.Subject)
}
if len(st.EmailBody) == 0 {
st.EmailBody = []byte(st.Body)
}
n.Notify(st.Subject, st.Body, st.EmailSubject, st.EmailBody, s.SystemConf, string(st.AlertKey), st.Attachments...)
}
示例2: executeTemplates
func (s *Schedule) executeTemplates(state *models.IncidentState, event *models.Event, a *conf.Alert, r *RunHistory) {
if event.Status != models.StUnknown {
var errs []error
metric := "template.render"
//Render subject
endTiming := collect.StartTimer(metric, opentsdb.TagSet{"alert": a.Name, "type": "subject"})
subject, err := s.ExecuteSubject(r, a, state, false)
if err != nil {
slog.Infof("%s: %v", state.AlertKey, err)
errs = append(errs, err)
} else if subject == nil {
err = fmt.Errorf("Empty subject on %s", state.AlertKey)
slog.Error(err)
errs = append(errs, err)
}
endTiming()
//Render body
endTiming = collect.StartTimer(metric, opentsdb.TagSet{"alert": a.Name, "type": "body"})
body, _, err := s.ExecuteBody(r, a, state, false)
if err != nil {
slog.Infof("%s: %v", state.AlertKey, err)
errs = append(errs, err)
} else if subject == nil {
err = fmt.Errorf("Empty body on %s", state.AlertKey)
slog.Error(err)
errs = append(errs, err)
}
endTiming()
//Render email body
endTiming = collect.StartTimer(metric, opentsdb.TagSet{"alert": a.Name, "type": "emailbody"})
emailbody, attachments, err := s.ExecuteBody(r, a, state, true)
if err != nil {
slog.Infof("%s: %v", state.AlertKey, err)
errs = append(errs, err)
} else if subject == nil {
err = fmt.Errorf("Empty email body on %s", state.AlertKey)
slog.Error(err)
errs = append(errs, err)
}
endTiming()
//Render email subject
endTiming = collect.StartTimer(metric, opentsdb.TagSet{"alert": a.Name, "type": "emailsubject"})
emailsubject, err := s.ExecuteSubject(r, a, state, true)
if err != nil {
slog.Infof("%s: %v", state.AlertKey, err)
errs = append(errs, err)
} else if subject == nil {
err = fmt.Errorf("Empty email subject on %s", state.AlertKey)
slog.Error(err)
errs = append(errs, err)
}
endTiming()
if errs != nil {
endTiming = collect.StartTimer(metric, opentsdb.TagSet{"alert": a.Name, "type": "bad"})
subject, body, err = s.ExecuteBadTemplate(errs, r, a, state)
endTiming()
if err != nil {
subject = []byte(fmt.Sprintf("unable to create template error notification: %v", err))
}
emailbody = body
attachments = nil
}
state.Subject = string(subject)
state.Body = string(body)
//don't save email seperately if they are identical
if string(state.EmailBody) != state.Body {
state.EmailBody = emailbody
}
if string(state.EmailSubject) != state.Subject {
state.EmailSubject = emailsubject
}
state.Attachments = attachments
}
}