當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Incident.FormatDescription方法代碼示例

本文整理匯總了Golang中github.com/eliothedeman/bangarang/event.Incident.FormatDescription方法的典型用法代碼示例。如果您正苦於以下問題:Golang Incident.FormatDescription方法的具體用法?Golang Incident.FormatDescription怎麽用?Golang Incident.FormatDescription使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/eliothedeman/bangarang/event.Incident的用法示例。


在下文中一共展示了Incident.FormatDescription方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Send

// Send an email via smtp
func (e *Email) Send(i *event.Incident) error {

	//For now set the description as both the subject and body
	headers := make(map[string]string)
	headers["From"] = e.conf.Sender
	headers["To"] = strings.Join(e.conf.Recipients, ",")
	headers["Subject"] = i.FormatDescription()
	headers["MIME-Version"] = "1.0"
	headers["Content-Type"] = "text/plain; charset=\"utf-8\""
	headers["Content-Transfer-Encoding"] = "base64"

	// make the body a json encoded representation of the incidnent
	body, err := json.MarshalIndent(i, "", "    ")
	if err != nil {
		logrus.Errorf("Unable to encode incidnet for email %s", err.Error())
	}

	log.Println("sending email")
	err = smtp.SendMail(e.conf.Host+":"+strconv.Itoa(e.conf.Port), *e.Auth,
		e.conf.Sender, e.conf.Recipients, []byte(writeEmailBuffer(headers, string(body))))
	if err != nil {
		logrus.Errorf("Unable to send email via smtp %s", err)
	}
	log.Println("done sending mail")
	return err
}
開發者ID:postfix,項目名稱:bangarang,代碼行數:27,代碼來源:email.go

示例2: Send

func (p *PagerDuty) Send(i *event.Incident) error {
	var pdPevent *pagerduty.Event
	switch i.Status {
	case event.CRITICAL, event.WARNING:
		pdPevent = pagerduty.NewTriggerEvent(p.conf.Key, i.FormatDescription())
	case event.OK:
		pdPevent = pagerduty.NewResolveEvent(p.conf.Key, i.FormatDescription())
	}
	pdPevent.IncidentKey = string(string(i.IndexName()))

	_, _, err := pagerduty.Submit(pdPevent)
	return err
}
開發者ID:nolenroyalty,項目名稱:bangarang,代碼行數:13,代碼來源:pager_duty.go

示例3: PassIncident

// PassIncident takes an incident into the escalation for processing
func (e *EscalationPolicy) PassIncident(i *event.Incident) {

	// only process incidents that this policy subscribes to
	if e.isSubscribed(i) {

		// send if off to every escalation known about
		for _, ep := range e.Escalations {
			err := ep.Send(i)
			if err != nil {
				logrus.Errorf("Unable to forward incident %s to escalation %+v", i.FormatDescription(), ep)
			}
		}
	}
}
開發者ID:nolenroyalty,項目名稱:bangarang,代碼行數:15,代碼來源:escalation.go

示例4: Send

func (c *Console) Send(i *event.Incident) error {

	switch i.Status {
	case event.OK:
		logrus.Info(i.FormatDescription())
	case event.WARNING:
		logrus.Warn(i.FormatDescription())
	case event.CRITICAL:
		logrus.Error(i.FormatDescription())
	}

	return nil
}
開發者ID:postfix,項目名稱:bangarang,代碼行數:13,代碼來源:console.go

示例5: formatName

// bangarang.annotation.{status}.{host}.{service}
func formatName(i *event.Incident) string {
	return strings.Replace(fmt.Sprintf("%s.%s.%s.%s", ANNOTATION_PREFIX, event.Status(i.Status), i.Tags.Get("host"), strings.Replace(i.FormatDescription(), ".", "_", -1)), " ", "_", -1)
}
開發者ID:nolenroyalty,項目名稱:bangarang,代碼行數:4,代碼來源:graphana_graphite_annotation.go


注:本文中的github.com/eliothedeman/bangarang/event.Incident.FormatDescription方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。