• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang event.Incident类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/eliothedeman/bangarang/event.Incident的典型用法代码示例。如果您正苦于以下问题:Golang Incident类的具体用法?Golang Incident怎么用?Golang Incident使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Incident类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: ProcessIncident

func (p *Pipeline) ProcessIncident(in *event.Incident) {

	// start tracking this incident in memory so we can call back to it
	p.tracker.TrackIncident(in)

	// dedup the incident
	if p.Dedupe(in) {

		// update the incident in the index
		if in.Status != event.OK {
			p.index.PutIncident(in)
		} else {
			p.index.DeleteIncidentById(in.IndexName())
		}

		// fetch the escalation to take
		esc, ok := p.escalations.Collection()[in.Escalation]
		if ok {

			// send to every alarm in the escalation
			for _, a := range esc {
				a.Send(in)
			}
		} else {
			logrus.Error("unknown escalation", in.Escalation)
		}
	}
}
开发者ID:postfix,项目名称:bangarang,代码行数:28,代码来源:pipeline.go


示例2: GetIncidentResolver

func (t *Tracker) GetIncidentResolver(i *event.Incident) chan *event.Incident {
	var res chan *event.Incident
	t.Query(func(r *Tracker) {
		res, _ = r.incidentResolvers[string(i.IndexName())]
	})
	return res
}
开发者ID:nolenroyalty,项目名称:bangarang,代码行数:7,代码来源:tracker.go


示例3: 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


示例4: Dedupe

// returns true if this is a new incident, false if it is a duplicate
func (p *Pipeline) Dedupe(i *event.Incident) bool {
	old := p.index.GetIncident(i.IndexName())

	if old == nil {
		return i.Status != event.OK
	}

	return old.Status != i.Status
}
开发者ID:postfix,项目名称:bangarang,代码行数:10,代码来源:pipeline.go


示例5: 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


示例6: PutIncident

func (p *Pipeline) PutIncident(in *event.Incident) {
	if in.Id == 0 {
		in.Id = p.index.GetIncidentCounter()
		p.index.UpdateIncidentCounter(in.Id + 1)
	}
	p.index.PutIncident(in)
}
开发者ID:postfix,项目名称:bangarang,代码行数:7,代码来源:pipeline.go


示例7: TrackIncident

// TrackIncident will allow the tracker to keep state about an incident
func (t *Tracker) TrackIncident(i *event.Incident) {
	if i.GetResolve() != nil {
		t.Query(func(r *Tracker) {

			// Don't keep track of "OK" incident resolvers, as ok's can't be resolved
			if i.Status != event.OK {
				r.incidentResolvers[string(i.IndexName())] = i.GetResolve()
			}
			r.totalIncidents.inc()
		})
	}
}
开发者ID:nolenroyalty,项目名称:bangarang,代码行数:13,代码来源:tracker.go


示例8: 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


示例9: 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


示例10: processIncident

// processIncident forwards a deduped incident on to every escalation
func (p *Pipeline) processIncident(in *event.Incident) {
	in.GetEvent().SetState(event.StateIncident)

	// start tracking this incident in memory so we can call back to it
	p.tracker.TrackIncident(in)

	// dedup the incident
	if p.Dedupe(in) {

		// update the incident in the index
		if in.Status != event.OK {
			p.index.PutIncident(in)
		} else {
			p.index.DeleteIncidentById(in.IndexName())
		}

		// send it on to every escalation
		for _, esc := range p.escalations {
			esc.PassIncident(in)
		}
	}

	in.GetEvent().SetState(event.StateComplete)
}
开发者ID:nolenroyalty,项目名称:bangarang,代码行数:25,代码来源:pipeline.go


示例11: 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


示例12: PassIncident

func (t *testingPasser) PassIncident(i *event.Incident) {
	if t.incidents == nil {
		t.incidents = map[string]*event.Incident{}
	}
	t.incidents[string(i.IndexName())] = i
}
开发者ID:nolenroyalty,项目名称:bangarang,代码行数:6,代码来源:policy_test.go



注:本文中的github.com/eliothedeman/bangarang/event.Incident类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang db.QueryParser类代码示例发布时间:2022-05-23
下一篇:
Golang event.Event类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap