Golang bosun-org-cmd-bosun-conf.Notifications类(方法)实例源码

下面列出了Golang bosun-org-cmd-bosun-conf.Notifications 类(方法)源码代码实例,从而了解它的用法。

作者:nicolle    项目:bosu   
func (s *Schedule) groupActionNotifications(aks []models.AlertKey) (map[*conf.Notification][]*models.IncidentState, error) {
	groupings := make(map[*conf.Notification][]*models.IncidentState)
	for _, ak := range aks {
		alert := s.RuleConf.GetAlert(ak.Name())
		status, err := s.DataAccess.State().GetLatestIncident(ak)
		if err != nil {
			return nil, err
		}
		if alert == nil || status == nil {
			continue
		}
		var n *conf.Notifications
		if status.WorstStatus == models.StWarning || alert.CritNotification == nil {
			n = alert.WarnNotification
		} else {
			n = alert.CritNotification
		}
		if n == nil {
			continue
		}
		nots := n.Get(s.RuleConf, ak.Group())
		for _, not := range nots {
			if !not.RunOnActions {
				continue
			}
			groupings[not] = append(groupings[not], status)
		}
	}
	return groupings, nil
}

作者:eswd    项目:bosu   
func (s *Schedule) groupActionNotifications(aks []models.AlertKey) map[*conf.Notification][]*State {
	groupings := make(map[*conf.Notification][]*State)
	for _, ak := range aks {
		alert := s.Conf.Alerts[ak.Name()]
		status := s.GetStatus(ak)
		if alert == nil || status == nil {
			continue
		}
		var n *conf.Notifications
		if status.Status() == StWarning {
			n = alert.WarnNotification
		} else {
			n = alert.CritNotification
		}
		if n == nil {
			continue
		}
		nots := n.Get(s.Conf, ak.Group())
		for _, not := range nots {
			if !not.RunOnActions {
				continue
			}
			groupings[not] = append(groupings[not], status)
		}
	}
	return groupings
}


问题


面经


文章

微信
公众号

扫码关注公众号