示例#1
0
文件: build.go 项目: megamsys/urknall
func eventNotify(inputs map[string]string, host string) error {
	var email, hostid string
	for k, v := range inputs {
		switch k {
		case constants.USERMAIL:
			email = v
		case constants.HOST_ID:
			hostid = v
		}
	}
	mi := make(map[string]string)
	js := make(pairs.JsonPairs, 0)
	m := make(map[string][]string, 2)
	m["status"] = []string{status.String()}
	m["description"] = []string{status.Description(host)}
	js.NukeAndSet(m) //just nuke the matching output key:

	mi[constants.HOST_IP] = host
	mi[constants.HOST_ID] = hostid
	mi[constants.ACCOUNT_ID] = email
	mi[constants.EVENT_TYPE] = status.Event_type()
	newEvent := events.NewMulti(
		[]*events.Event{
			&events.Event{
				AccountsId:  email,
				EventAction: alerts.STATUS,
				EventType:   constants.EventUser,
				EventData:   alerts.EventData{M: mi, D: js.ToString()},
				Timestamp:   time.Now().Local(),
			},
		})
	return newEvent.Write()
}
示例#2
0
func EventNotify(status utils.Status) error {
	mi := make(map[string]string)

	js := make(pairs.JsonPairs, 0)
	m := make(map[string][]string, 2)
	m["status"] = []string{status.String()}
	m["description"] = []string{status.Description(meta.MC.Name)}
	js.NukeAndSet(m) //just nuke the matching output key:

	mi[constants.ASSEMBLY_ID] = meta.MC.CartonId
	mi[constants.ACCOUNT_ID] = meta.MC.AccountId
	mi[constants.EVENT_TYPE] = status.Event_type()

	newEvent := events.NewMulti(
		[]*events.Event{
			&events.Event{
				AccountsId:  "",
				EventAction: alerts.STATUS,
				EventType:   constants.EventUser,
				EventData:   alerts.EventData{M: mi, D: js.ToString()},
				Timestamp:   time.Now().Local(),
			},
		})
	return newEvent.Write()
}