diff --git a/cmd/bosun/conf/conf.go b/cmd/bosun/conf/conf.go index 6d6f4a5dd2..a0d941e2d4 100644 --- a/cmd/bosun/conf/conf.go +++ b/cmd/bosun/conf/conf.go @@ -316,6 +316,7 @@ type Notification struct { Timeout time.Duration ContentType string RunOnActions bool + UseBody bool next string email string @@ -1085,6 +1086,8 @@ func (c *Conf) loadNotification(s *parse.SectionNode) { n.Body = tmpl case "runOnActions": n.RunOnActions = v == "true" + case "useBody": + n.UseBody = v == "true" default: c.errorf("unknown key %s", k) } diff --git a/cmd/bosun/conf/notify.go b/cmd/bosun/conf/notify.go index 82335ff43b..bbf4476faf 100644 --- a/cmd/bosun/conf/notify.go +++ b/cmd/bosun/conf/notify.go @@ -30,30 +30,42 @@ func (n *Notification) Notify(subject, body string, emailsubject, emailbody []by go n.DoEmail(emailsubject, emailbody, c, ak, attachments...) } if n.Post != nil { - go n.DoPost([]byte(subject), ak) + go n.DoPost(n.GetPayload(subject, body), ak) } if n.Get != nil { go n.DoGet(ak) } if n.Print { - go n.DoPrint(subject) + if n.UseBody { + go n.DoPrint("Subject: " + subject + ", Body: " + body) + } else { + go n.DoPrint(subject) + } + } +} + +func (n *Notification) GetPayload(subject, body string) (payload []byte) { + if n.UseBody { + return []byte(body) + } else { + return []byte(subject) } } -func (n *Notification) DoPrint(subject string) { - slog.Infoln(subject) +func (n *Notification) DoPrint(payload string) { + slog.Infoln(payload) } -func (n *Notification) DoPost(subject []byte, ak string) { +func (n *Notification) DoPost(payload []byte, ak string) { if n.Body != nil { buf := new(bytes.Buffer) - if err := n.Body.Execute(buf, string(subject)); err != nil { + if err := n.Body.Execute(buf, string(payload)); err != nil { slog.Errorln(err) return } - subject = buf.Bytes() + payload = buf.Bytes() } - resp, err := http.Post(n.Post.String(), n.ContentType, bytes.NewBuffer(subject)) + resp, err := http.Post(n.Post.String(), n.ContentType, bytes.NewBuffer(payload)) if resp != nil && resp.Body != nil { defer resp.Body.Close() } diff --git a/cmd/bosun/web/static.go b/cmd/bosun/web/static.go index 08e8cdeaf1..100c015f01 100644 --- a/cmd/bosun/web/static.go +++ b/cmd/bosun/web/static.go @@ -4917,7 +4917,7 @@ edhY5S/+PbPoq2Tal5xvmt3piswjT8hTQcvM/n8AAAD//7n7cuC9JgAA "/js/ace/mode-bosun.js": { local: "web/static/js/ace/mode-bosun.js", - size: 4402, + size: 4410, modtime: 0, compressed: ` H4sIAAAJbogA/7RX23LbNhO+tp6C4e+/EiWa6m1jO55kUk8yTdtM7NyUpB0eIBERBdAA6EMN99m7Cx5M @@ -4928,24 +4928,24 @@ gwZMwwDVcxrPOS/qNwOmyK3awgpda1GyRFHOJjWoa9WYrlVBOtb9yC4lsaQSNFH24Wh0HQkL4K1jq1aa JOUNF6km64jmp4KvNVhR5JTmRBeULRtcHL8tRYS70Iyf5YQUOs55siLpx1K9/yh1lOf8pn0r2YrxG3ae CSIznqda0TV5zdK3gN6AwlTBmSQf6JoCORKJJDujLCGtNlkXOSpI8E2eZBqghPr86cMv5A5DbDxJ2euc CAUi3Inx6DpKBNeq0U4EwN9EgumUFISlssXDmd+4oguaVFszzGxc2xPXfOD5lUP6p7+vNF0yLsjnegLC -Y7d8uqpdWsbJujCxJUoXgjKlE84gRur8riCaQVoZR/FS6Zin3U02vugCyjL+SpKtpWck2TDtbzjJ3cHS -HTAUerjnia2xZi4rG0B6cQpJbVhEiAwe4KuyqB9nRFAolIZSk8mtSiN4E7G0zfN2OVZAuzTGJUkWsSUE -kpfgsZQuFvqqXR2XNFeUPdK5XkKcr/WCCnD0AoKUQMnkQmPl6BzqYR3d6jVJaQRD2sS8ICKBOGDiS5OD -ssRiECRaQTGZilEQ/6XgsMsolhqKpuCQQ6ngBXDDR149WAQEpGbXLcemeluSucQ607k0W2rXQVcTzRq/ -dbLbd6D76CC3t3u3b6cTOIBXGZXevqg70j3WHywVyrZeWj687aFob0/xFWEvLXtVRd92jVSQJbkF6cUE -nNX2rpllO/UCzFyYB8rgNihoRmyUP7jbyLBPGsU58SgDAuD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8cjuBvBDc+MJFBl1FyMnBHcwcugvCVO6pvmd7wtW5ACuZQb/dN+Xtuxt334Wv3f31V/hVMb1+Q +4UKME4dP3IA7GsPMnSEf19Rqq71bdPUd+8yQbGYAArrthjBgkwHwfZqae0Q/fhhhL4HLrkHxCsEVV3B5 +66ZLTbhyCibE3wEAAP//qATqLToRAAA= `, }, diff --git a/cmd/bosun/web/static/js/ace/mode-bosun.js b/cmd/bosun/web/static/js/ace/mode-bosun.js index c5e55c1806..b4fb64fc40 100644 --- a/cmd/bosun/web/static/js/ace/mode-bosun.js +++ b/cmd/bosun/web/static/js/ace/mode-bosun.js @@ -14,7 +14,7 @@ var BosunHighlightRules = function() { var inAlertKeywords = "macro|template|crit|warn|depends|squelch|critNotification|" + "warnNotification|unknown|unjoinedOk|ignoreUnknown|log" - var inNotificationKeywords = "email|post|get|print|contentType|next|timeout|body"; + var inNotificationKeywords = "email|post|get|print|contentType|next|timeout|body|useBody"; var inTemplateKeywords = "subject|body";