当前位置: 首页>>代码示例>>Golang>>正文


Golang Event.ExpressionId方法代码示例

本文整理汇总了Golang中github.com/Cepave/common/model.Event.ExpressionId方法的典型用法代码示例。如果您正苦于以下问题:Golang Event.ExpressionId方法的具体用法?Golang Event.ExpressionId怎么用?Golang Event.ExpressionId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/Cepave/common/model.Event的用法示例。


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

示例1: Put

func (this *SafeEvents) Put(event *model.Event) {
	if event.Status == "OK" {
		this.Delete(event.Id)
		return
	}

	dto := &EventDto{}
	dto.Id = event.Id
	dto.Endpoint = event.Endpoint
	dto.Metric = event.Metric()
	dto.Counter = event.Counter()
	dto.Func = event.Func()
	dto.LeftValue = utils.ReadableFloat(event.LeftValue)
	dto.Operator = event.Operator()
	dto.RightValue = utils.ReadableFloat(event.RightValue())
	dto.Note = event.Note()

	dto.MaxStep = event.MaxStep()
	dto.CurrentStep = event.CurrentStep
	dto.Priority = event.Priority()

	dto.Status = event.Status
	dto.Timestamp = event.EventTime

	dto.ExpressionId = event.ExpressionId()
	dto.StrategyId = event.StrategyId()
	dto.TemplateId = event.TplId()

	dto.Link = Link(event)

	this.Lock()
	defer this.Unlock()
	this.M[dto.Id] = dto
}
开发者ID:myhung,项目名称:alarm,代码行数:34,代码来源:eventdto.go

示例2: Link

func Link(event *model.Event) string {
	tplId := event.TplId()
	if tplId != 0 {
		return fmt.Sprintf("%s/template/view/%d", Config().Api.Portal, tplId)
	}

	eid := event.ExpressionId()
	if eid != 0 {
		return fmt.Sprintf("%s/expression/view/%d", Config().Api.Portal, eid)
	}

	return ""
}
开发者ID:myhung,项目名称:alarm,代码行数:13,代码来源:eventdto.go

示例3: Callback

func Callback(event *model.Event, action *api.Action) string {
	if action.Url == "" {
		return "callback url is blank"
	}

	L := make([]string, 0)
	if len(event.PushedTags) > 0 {
		for k, v := range event.PushedTags {
			L = append(L, fmt.Sprintf("%s:%s", k, v))
		}
	}

	tags := ""
	if len(L) > 0 {
		tags = strings.Join(L, ",")
	}

	req := httplib.Get(action.Url).SetTimeout(3*time.Second, 20*time.Second)

	req.Param("endpoint", event.Endpoint)
	req.Param("metric", event.Metric())
	req.Param("func", event.Func())
	req.Param("leftValue", fmt.Sprintf("%.3f", event.LeftValue))
	req.Param("operator", event.Operator())
	req.Param("rightValue", fmt.Sprintf("%.3f", event.RightValue()))
	req.Param("note", event.Note())
	req.Param("status", event.Status)
	req.Param("step", fmt.Sprintf("%d", event.CurrentStep))
	req.Param("priority", fmt.Sprintf("%d", event.Priority()))
	req.Param("time", event.FormattedTime())
	req.Param("tpl_id", fmt.Sprintf("%d", event.TplId()))
	req.Param("exp_id", fmt.Sprintf("%d", event.ExpressionId()))
	req.Param("stra_id", fmt.Sprintf("%d", event.StrategyId()))
	req.Param("tags", tags)

	resp, e := req.String()

	success := "success"
	if e != nil {
		success = fmt.Sprintf("fail:%s", e.Error())
	}
	message := fmt.Sprintf("curl %s %s. resp: %s", action.Url, success, resp)

	return message
}
开发者ID:myhung,项目名称:alarm,代码行数:45,代码来源:callback.go

示例4: InsertEvent

func InsertEvent(eve *coommonModel.Event) {
	log := logger.Logger()
	q := orm.NewOrm()
	q.Using("falcon_portal")
	var event []EventCases
	q.Raw("select * from event_cases where id = ?", eve.Id).QueryRows(&event)
	if len(event) == 0 {
		//create cases
		sqltemplete := `INSERT INTO event_cases (
					id,
					endpoint,
					metric,
					func,
					cond,
					note,
					max_step,
					current_step,
					priority,
					status,
					timestamp,
					update_at,
					tpl_creator,
					expression_id,
					strategy_id,
					template_id
					) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`
		res1, err := q.Raw(
			sqltemplete,
			eve.Id,
			eve.Endpoint,
			counterGen(eve.Metric(), utils.SortedTags(eve.PushedTags)),
			eve.Func(),
			//cond
			fmt.Sprintf("%v %v %v", eve.LeftValue, eve.Operator(), eve.RightValue()),
			eve.Strategy.Note,
			eve.MaxStep(),
			eve.CurrentStep,
			eve.Priority(),
			eve.Status,
			//start_at
			time.Unix(eve.EventTime, 0),
			//update_at
			time.Unix(eve.EventTime, 0),
			eve.Strategy.Tpl.Creator,
			eve.ExpressionId(),
			eve.StrategyId(),
			//template_id
			eve.TplId()).Exec()
		log.Debug(fmt.Sprintf("%v, %v", res1, err))

		//insert case
		res2, err := insertEvent(q, eve)
		log.Debug(fmt.Sprintf("%v, %v", res2, err))

	} else {
		sqltemplete := `UPDATE event_cases SET
				update_at = ?,
				max_step = ?,
				current_step = ?,
				note = ?,
				cond = ?,
				status = ?`
		//reopen case
		if event[0].ProcessStatus == "resolved" || event[0].ProcessStatus == "ignored" {
			sqltemplete = fmt.Sprintf("%v ,process_status = '%s', process_note = %d", sqltemplete, "unresolved", 0)
		}
		if eve.CurrentStep == 1 {

			sqltemplete = fmt.Sprintf("%v ,timestamp = ? WHERE id = ?", sqltemplete)
			//update start time of cases
			res1, err := q.Raw(
				sqltemplete,
				time.Unix(eve.EventTime, 0),
				eve.MaxStep(),
				eve.CurrentStep,
				eve.Strategy.Note,
				fmt.Sprintf("%v %v %v", eve.LeftValue, eve.Operator(), eve.RightValue()),
				eve.Status,
				time.Unix(eve.EventTime, 0),
				eve.Id).Exec()
			log.Debug(fmt.Sprintf("%v, %v", res1, err))
			//insert case
			res2, err := insertEvent(q, eve)
			log.Debug(fmt.Sprintf("%v, %v", res2, err))
		} else {
			sqltemplete = fmt.Sprintf("%v WHERE id = ?", sqltemplete)
			res1, err := q.Raw(
				sqltemplete,
				time.Unix(eve.EventTime, 0),
				eve.MaxStep(),
				eve.CurrentStep,
				eve.Strategy.Note,
				fmt.Sprintf("%v %v %v", eve.LeftValue, eve.Operator(), eve.RightValue()),
				eve.Status,
				eve.Id).Exec()
			log.Debug(fmt.Sprintf("%v, %v", res1, err))
			//insert case
			res2, err := insertEvent(q, eve)
			log.Debug(fmt.Sprintf("%v, %v", res2, err))
		}
//.........这里部分代码省略.........
开发者ID:donh,项目名称:alarm,代码行数:101,代码来源:event_operation.go


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