本文整理汇总了Golang中bosun/org/cmd/bosun/conf.Notification.Notify方法的典型用法代码示例。如果您正苦于以下问题:Golang Notification.Notify方法的具体用法?Golang Notification.Notify怎么用?Golang Notification.Notify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bosun/org/cmd/bosun/conf.Notification
的用法示例。
在下文中一共展示了Notification.Notify方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: utnotify
// utnotify is single notification for N unknown groups into a single notification
func (s *Schedule) utnotify(groups map[string]models.AlertKeys, n *conf.Notification) {
var total int
now := utcNow()
for _, group := range groups {
// Don't know what the following line does, just copied from unotify
s.Group[now] = group
total += len(group)
}
subject := fmt.Sprintf("%v unknown alert instances suppressed", total)
body := new(bytes.Buffer)
if err := unknownMultiGroup.Execute(body, struct {
Groups map[string]models.AlertKeys
Threshold int
}{
groups,
s.SystemConf.GetUnknownThreshold(),
}); err != nil {
slog.Errorln(err)
}
n.Notify(subject, body.String(), []byte(subject), body.Bytes(), s.SystemConf, "unknown_treshold")
}
示例3: unotify
func (s *Schedule) unotify(name string, group models.AlertKeys, n *conf.Notification) {
subject := new(bytes.Buffer)
body := new(bytes.Buffer)
now := utcNow()
s.Group[now] = group
t := s.RuleConf.GetUnknownTemplate()
if t == nil {
t = defaultUnknownTemplate
}
data := s.unknownData(now, name, group)
if t.Body != nil {
if err := t.Body.Execute(body, &data); err != nil {
slog.Infoln("unknown template error:", err)
}
}
if t.Subject != nil {
if err := t.Subject.Execute(subject, &data); err != nil {
slog.Infoln("unknown template error:", err)
}
}
n.Notify(subject.String(), body.String(), subject.Bytes(), body.Bytes(), s.SystemConf, name)
}
示例4: unotify
func (s *Schedule) unotify(name string, group expr.AlertKeys, n *conf.Notification) {
subject := new(bytes.Buffer)
body := new(bytes.Buffer)
now := time.Now().UTC()
s.Group[now] = group
t := s.Conf.UnknownTemplate
if t == nil {
t = defaultUnknownTemplate
}
data := s.unknownData(now, name, group)
if t.Body != nil {
if err := t.Body.Execute(body, &data); err != nil {
log.Println("unknown template error:", err)
}
}
if t.Subject != nil {
if err := t.Subject.Execute(subject, &data); err != nil {
log.Println("unknown template error:", err)
}
}
n.Notify(subject.String(), body.String(), subject.Bytes(), body.Bytes(), s.Conf, name)
}
示例5: notify
func (s *Schedule) notify(st *State, n *conf.Notification) {
n.Notify(st.Subject, st.Body, st.EmailSubject, st.EmailBody, s.Conf, string(st.AlertKey()), st.Attachments...)
}